From 0f67e1038a99a1650869c1ce5006ed4edb0e854d Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 26 Mar 2024 10:56:07 +0100 Subject: [PATCH] suggestions --- .../settings/Profile/CustomStatus/SetDatePage.tsx | 4 ++-- .../settings/Profile/CustomStatus/SetTimePage.tsx | 3 --- .../Profile/CustomStatus/StatusClearAfterPage.tsx | 11 ++++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pages/settings/Profile/CustomStatus/SetDatePage.tsx b/src/pages/settings/Profile/CustomStatus/SetDatePage.tsx index 5e165de3cc85..ae0b910dc01f 100644 --- a/src/pages/settings/Profile/CustomStatus/SetDatePage.tsx +++ b/src/pages/settings/Profile/CustomStatus/SetDatePage.tsx @@ -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; }; @@ -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); }; diff --git a/src/pages/settings/Profile/CustomStatus/SetTimePage.tsx b/src/pages/settings/Profile/CustomStatus/SetTimePage.tsx index b05a21967ee1..101f7269616d 100644 --- a/src/pages/settings/Profile/CustomStatus/SetTimePage.tsx +++ b/src/pages/settings/Profile/CustomStatus/SetTimePage.tsx @@ -43,10 +43,7 @@ function SetTimePage({customStatus}: SetTimePageProps) { /> diff --git a/src/pages/settings/Profile/CustomStatus/StatusClearAfterPage.tsx b/src/pages/settings/Profile/CustomStatus/StatusClearAfterPage.tsx index 8c6d382ffa01..598050686825 100644 --- a/src/pages/settings/Profile/CustomStatus/StatusClearAfterPage.tsx +++ b/src/pages/settings/Profile/CustomStatus/StatusClearAfterPage.tsx @@ -31,6 +31,7 @@ type StatusType = { }; type StatusClearAfterPageOnyxProps = { + /** User's custom status */ customStatus: OnyxEntry; }; @@ -61,8 +62,8 @@ const useValidateCustomDate = (data: string) => { setCustomTimeError(timeValidationErrorKey); return { - dateValidationErrorKey, - timeValidationErrorKey, + dateError: dateValidationErrorKey, + timeError: timeValidationErrorKey, }; }; @@ -109,7 +110,7 @@ function StatusClearAfterPage({customStatus}: StatusClearAfterPageProps) { ); const onSubmit = () => { - const {dateValidationErrorKey: dateError, timeValidationErrorKey: timeError} = validateCustomDate(); + const {dateError, timeError} = validateCustomDate(); if (dateError || timeError) { return; } @@ -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); @@ -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); }