Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
pasyukevich committed Feb 13, 2024
1 parent cf150a2 commit 8344608
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/TaskPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ export default withCurrentUserPersonalDetails(
withOnyx<TaskPreviewProps, TaskPreviewOnyxProps>({
taskReport: {
key: ({taskReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`,
}
},
})(TaskPreview),
);
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskAssigneeSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const TaskAssigneeSelectorModalWithOnyx = withOnyx<TaskAssigneeSelectorModalProp
},
task: {
key: ONYXKEYS.TASK,
}
},
})(TaskAssigneeSelectorModal);

export default withCurrentUserPersonalDetails(TaskAssigneeSelectorModalWithOnyx);
26 changes: 4 additions & 22 deletions src/pages/tasks/TaskTitlePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, {useCallback, useRef} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
Expand All @@ -21,15 +19,9 @@ import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNot
import * as Task from '@userActions/Task';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy, PolicyRole} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

type TaskTitlePageOnyxProps = {
/** The policy of parent report */
rootParentReportPolicy: OnyxEntry<PolicyRole>;
};

type TaskTitlePageProps = WithReportOrNotFoundProps & WithCurrentUserPersonalDetailsProps & TaskTitlePageOnyxProps;
type TaskTitlePageProps = WithReportOrNotFoundProps & WithCurrentUserPersonalDetailsProps;

type Values = {
title: string;
Expand All @@ -39,7 +31,7 @@ type Errors = {
title?: string;
};

function TaskTitlePage({report, rootParentReportPolicy, currentUserPersonalDetails}: TaskTitlePageProps) {
function TaskTitlePage({report, currentUserPersonalDetails}: TaskTitlePageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand Down Expand Up @@ -74,7 +66,7 @@ function TaskTitlePage({report, rootParentReportPolicy, currentUserPersonalDetai

const inputRef = useRef<AnimatedTextInputRef | null>(null);
const isOpen = ReportUtils.isOpenTaskReport(report);
const canModifyTask = Task.canModifyTask(report, currentUserPersonalDetails.accountID, rootParentReportPolicy?.role);
const canModifyTask = Task.canModifyTask(report, currentUserPersonalDetails.accountID);
const isTaskNonEditable = ReportUtils.isTaskReport(report) && (!canModifyTask || !isOpen);

return (
Expand Down Expand Up @@ -126,16 +118,6 @@ function TaskTitlePage({report, rootParentReportPolicy, currentUserPersonalDetai

TaskTitlePage.displayName = 'TaskTitlePage';

const ComponentWithOnyx = withOnyx<TaskTitlePageProps, TaskTitlePageOnyxProps>({
rootParentReportPolicy: {
key: ({report}) => {
const rootParentReport = ReportUtils.getRootParentReport(report);
return `${ONYXKEYS.COLLECTION.POLICY}${rootParentReport ? rootParentReport.policyID : '0'}`;
},
selector: (policy: OnyxEntry<Policy>) => ({role: policy?.role}),
},
})(TaskTitlePage);

const ComponentWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(ComponentWithOnyx);
const ComponentWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(TaskTitlePage);

export default withReportOrNotFound()(ComponentWithCurrentUserPersonalDetails);
11 changes: 2 additions & 9 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ type Connection = {

type AutoReportingOffset = number | ValueOf<typeof CONST.POLICY.AUTO_REPORTING_OFFSET>;

type PolicyValue = ValueOf<typeof CONST.POLICY.ROLE>;

type Policy = {
/** The ID of the policy */
id: string;
Expand All @@ -55,7 +53,7 @@ type Policy = {
name: string;

/** The current user's role in the policy */
role: PolicyValue;
role: ValueOf<typeof CONST.POLICY.ROLE>;

/** The policy type */
type: ValueOf<typeof CONST.POLICY.TYPE>;
Expand Down Expand Up @@ -177,11 +175,6 @@ type Policy = {
connections?: Record<string, Connection>;
};

type PolicyRole = {
/** The role of current user */
role?: PolicyValue;
};

export default Policy;

export type {Unit, CustomUnit, PolicyRole};
export type {Unit, CustomUnit};
2 changes: 0 additions & 2 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import type {PersonalDetailsList} from './PersonalDetails';
import type PersonalDetails from './PersonalDetails';
import type PlaidData from './PlaidData';
import type Policy from './Policy';
import type {PolicyRole} from './Policy';
import type {PolicyCategories, PolicyCategory} from './PolicyCategory';
import type {PolicyMembers} from './PolicyMember';
import type PolicyMember from './PolicyMember';
Expand Down Expand Up @@ -125,7 +124,6 @@ export type {
PersonalDetailsList,
PlaidData,
Policy,
PolicyRole,
PolicyCategories,
PolicyCategory,
PolicyMember,
Expand Down

0 comments on commit 8344608

Please sign in to comment.