Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Mar 26, 2024
1 parent d77203d commit 0f67e10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/pages/settings/Profile/CustomStatus/SetDatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ROUTES from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/SettingsStatusClearDateForm';
import type * as OnyxTypes from '@src/types/onyx';

type Date = {
type DateTime = {
dateTime: string;
};

Expand All @@ -33,7 +33,7 @@ function SetDatePage({customStatus}: SetDatePageProps) {
const {translate} = useLocalize();
const customClearAfter = customStatus?.clearAfter ?? '';

const onSubmit = (value: Date) => {
const onSubmit = (value: DateTime) => {
User.updateDraftCustomStatus({clearAfter: DateUtils.combineDateAndTime(customClearAfter, value.dateTime)});
Navigation.goBack(ROUTES.SETTINGS_STATUS_CLEAR_AFTER);
};
Expand Down
3 changes: 0 additions & 3 deletions src/pages/settings/Profile/CustomStatus/SetTimePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ function SetTimePage({customStatus}: SetTimePageProps) {
/>
<View style={styles.flex1}>
<TimePicker
// @ts-expect-error TODO: remove this comment once TimePicker (https://github.com/Expensify/App/issues/36129) is migrated to TS
inputID="timePicker"
defaultValue={clearAfter}
style={styles.flexGrow1}
onSubmit={onSubmit}
/>
</View>
Expand Down
11 changes: 6 additions & 5 deletions src/pages/settings/Profile/CustomStatus/StatusClearAfterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type StatusType = {
};

type StatusClearAfterPageOnyxProps = {
/** User's custom status */
customStatus: OnyxEntry<OnyxTypes.CustomStatusDraft>;
};

Expand Down Expand Up @@ -61,8 +62,8 @@ const useValidateCustomDate = (data: string) => {
setCustomTimeError(timeValidationErrorKey);

return {
dateValidationErrorKey,
timeValidationErrorKey,
dateError: dateValidationErrorKey,
timeError: timeValidationErrorKey,
};
};

Expand Down Expand Up @@ -109,7 +110,7 @@ function StatusClearAfterPage({customStatus}: StatusClearAfterPageProps) {
);

const onSubmit = () => {
const {dateValidationErrorKey: dateError, timeValidationErrorKey: timeError} = validateCustomDate();
const {dateError, timeError} = validateCustomDate();
if (dateError || timeError) {
return;
}
Expand All @@ -118,7 +119,7 @@ function StatusClearAfterPage({customStatus}: StatusClearAfterPageProps) {
calculatedDraftDate = draftClearAfter;
} else {
const selectedRange = statusType.find((item) => item.isSelected);
calculatedDraftDate = DateUtils.getDateFromStatusType(selectedRange?.value ?? 'never');
calculatedDraftDate = DateUtils.getDateFromStatusType(selectedRange?.value ?? CONST.CUSTOM_STATUS_TYPES.NEVER);
}
User.updateDraftCustomStatus({clearAfter: calculatedDraftDate});
Navigation.goBack(ROUTES.SETTINGS_STATUS);
Expand All @@ -135,7 +136,7 @@ function StatusClearAfterPage({customStatus}: StatusClearAfterPageProps) {
User.updateDraftCustomStatus({clearAfter: DateUtils.getOneHourFromNow()});
} else {
const selectedRange = statusType.find((item) => item.value === mode.value);
const calculatedDraftDate = DateUtils.getDateFromStatusType(selectedRange?.value ?? 'never');
const calculatedDraftDate = DateUtils.getDateFromStatusType(selectedRange?.value ?? CONST.CUSTOM_STATUS_TYPES.NEVER);
User.updateDraftCustomStatus({clearAfter: calculatedDraftDate});
Navigation.goBack(ROUTES.SETTINGS_STATUS);
}
Expand Down

0 comments on commit 0f67e10

Please sign in to comment.