diff --git a/web/components/contract/contract-details.tsx b/web/components/contract/contract-details.tsx index 354f4394..7705b538 100644 --- a/web/components/contract/contract-details.tsx +++ b/web/components/contract/contract-details.tsx @@ -191,7 +191,7 @@ export function ContractDetails(props: { )} @@ -277,14 +276,22 @@ function EditableCloseDate(props: { const [isEditingCloseTime, setIsEditingCloseTime] = useState(false) const [closeDate, setCloseDate] = useState( - closeTime && dayJsCloseTime.format('YYYY-MM-DDTHH:mm') + closeTime && dayJsCloseTime.format('YYYY-MM-DD') ) + const [closeHoursMinutes, setCloseHoursMinutes] = useState( + closeTime && dayJsCloseTime.format('HH:mm') + ) + + const newCloseTime = closeDate + ? dayjs(`${closeDate}T${closeHoursMinutes}`).valueOf() + : undefined const isSameYear = dayJsCloseTime.isSame(dayJsNow, 'year') const isSameDay = dayJsCloseTime.isSame(dayJsNow, 'day') const onSave = () => { - const newCloseTime = dayjs(closeDate).valueOf() + if (!newCloseTime) return + if (newCloseTime === closeTime) setIsEditingCloseTime(false) else if (newCloseTime > Date.now()) { const content = contract.description @@ -309,16 +316,24 @@ function EditableCloseDate(props: { return ( <> {isEditingCloseTime ? ( -
+ e.stopPropagation()} - onChange={(e) => setCloseDate(e.target.value || '')} + onChange={(e) => setCloseDate(e.target.value)} min={Date.now()} value={closeDate} /> -
+ e.stopPropagation()} + onChange={(e) => setCloseHoursMinutes(e.target.value)} + min="00:00" + value={closeHoursMinutes} + /> + ) : ( Date.now() ? 'Trading ends:' : 'Trading ended:'} @@ -342,7 +357,7 @@ function EditableCloseDate(props: { color={'gray-white'} onClick={() => setIsEditingCloseTime(true)} > - Edit + ))}