From 90ca66687d124302f772e8bde5f3af833e09c176 Mon Sep 17 00:00:00 2001 From: Rita Date: Wed, 6 Nov 2024 09:30:59 +0100 Subject: [PATCH] refactor(sanity): update date format --- .../core/releases/components/dialog/ReleaseForm.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx b/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx index bdd39b90b19..abca6f5cde0 100644 --- a/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx +++ b/packages/sanity/src/core/releases/components/dialog/ReleaseForm.tsx @@ -1,5 +1,4 @@ import {InfoOutlineIcon} from '@sanity/icons' -import {type FormNodeValidation} from '@sanity/types' import {Card, Flex, Stack, TabList, TabPanel, Text} from '@sanity/ui' import {format, isValid, parse} from 'date-fns' import {useCallback, useMemo, useState} from 'react' @@ -27,15 +26,10 @@ export function ReleaseForm(props: { // only editing existing releases will provide a value.slug const {t} = useTranslation() - // todo: you can create a release without a title, but not without a date if the type is scheduled - const [dateErrors, setDateErrors] = useState([]) - const [buttonReleaseType, setButtonReleaseType] = useState(releaseType ?? 'asap') const calendarLabels: CalendarLabels = useMemo(() => getCalendarLabels(t), [t]) - const [inputValue, setInputValue] = useState( - publishAt ? new Date(publishAt) : undefined, - ) + const [inputValue, setInputValue] = useState(publishAt ? new Date(publishAt) : new Date()) const handleBundleInputChange = useCallback( (event: React.FocusEvent) => { @@ -142,8 +136,8 @@ export function ReleaseForm(props: { onChange={handleBundlePublishAtCalendarChange} onInputChange={handleBundleInputChange} calendarLabels={calendarLabels} - value={publishAt ? new Date(publishAt) : undefined} - inputValue={inputValue ? format(inputValue, 'PP HH:mm') : ''} + value={publishAt ? new Date(publishAt) : new Date()} + inputValue={format(inputValue, 'dd/MM/yyyy, HH:mm O')} constrainSize={false} />