From 872d9cd7ac697f77b0ebefb1eefbfdb7cf7a40fd Mon Sep 17 00:00:00 2001 From: Rabah Zeineddine Date: Fri, 13 Oct 2023 00:07:36 -0300 Subject: [PATCH] fix: update date based on timezone update --- src/components/inputs/TzDateInput/index.tsx | 9 +++++++++ src/components/inputs/TzTimeInput/index.tsx | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/components/inputs/TzDateInput/index.tsx b/src/components/inputs/TzDateInput/index.tsx index ce64b7b..e4e975a 100644 --- a/src/components/inputs/TzDateInput/index.tsx +++ b/src/components/inputs/TzDateInput/index.tsx @@ -53,6 +53,15 @@ export function TzDateInput(props: TzDateInputProps) { } }, [field.value]) + useEffect(() => { + if (timezoneSourceInput.field.value && value) { + const tzDate = dayjs.tz(field.value, timezoneSourceInput.field.value) + setFormValue(props.source, tzDate?.toISOString(), { + shouldDirty: true, + }) + } + }, [timezoneSourceInput.field.value]) + return ( { + if (timezoneSourceInput.field.value && value) { + const tzDate = dayjs.tz(field.value, timezoneSourceInput.field.value) + setFormValue(props.source, tzDate?.toISOString(), { + shouldDirty: true, + }) + } + }, [timezoneSourceInput.field.value]) + return (