Add close now button to contract edit time
This commit is contained in:
parent
c16e5189f7
commit
138f34fc66
|
@ -356,18 +356,22 @@ function EditableCloseDate(props: {
|
||||||
closeTime && dayJsCloseTime.format('HH:mm')
|
closeTime && dayJsCloseTime.format('HH:mm')
|
||||||
)
|
)
|
||||||
|
|
||||||
const newCloseTime = closeDate
|
|
||||||
? dayjs(`${closeDate}T${closeHoursMinutes}`).valueOf()
|
|
||||||
: undefined
|
|
||||||
|
|
||||||
const isSameYear = dayJsCloseTime.isSame(dayJsNow, 'year')
|
const isSameYear = dayJsCloseTime.isSame(dayJsNow, 'year')
|
||||||
const isSameDay = dayJsCloseTime.isSame(dayJsNow, 'day')
|
const isSameDay = dayJsCloseTime.isSame(dayJsNow, 'day')
|
||||||
|
|
||||||
const onSave = () => {
|
let newCloseTime = closeDate
|
||||||
|
? dayjs(`${closeDate}T${closeHoursMinutes}`).valueOf()
|
||||||
|
: undefined
|
||||||
|
function onSave(customTime?: number) {
|
||||||
|
if (customTime) {
|
||||||
|
newCloseTime = customTime
|
||||||
|
setCloseDate(dayjs(newCloseTime).format('YYYY-MM-DD'))
|
||||||
|
setCloseHoursMinutes(dayjs(newCloseTime).format('HH:mm'))
|
||||||
|
}
|
||||||
if (!newCloseTime) return
|
if (!newCloseTime) return
|
||||||
|
|
||||||
if (newCloseTime === closeTime) setIsEditingCloseTime(false)
|
if (newCloseTime === closeTime) setIsEditingCloseTime(false)
|
||||||
else if (newCloseTime > Date.now()) {
|
else {
|
||||||
const content = contract.description
|
const content = contract.description
|
||||||
const formattedCloseDate = dayjs(newCloseTime).format('YYYY-MM-DD h:mm a')
|
const formattedCloseDate = dayjs(newCloseTime).format('YYYY-MM-DD h:mm a')
|
||||||
|
|
||||||
|
@ -416,13 +420,21 @@ function EditableCloseDate(props: {
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
<Button
|
<Button
|
||||||
className="mt-2"
|
className="mt-4"
|
||||||
size={'xs'}
|
size={'xs'}
|
||||||
color={'indigo'}
|
color={'indigo'}
|
||||||
onClick={onSave}
|
onClick={() => onSave()}
|
||||||
>
|
>
|
||||||
Done
|
Done
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
className="mt-4"
|
||||||
|
size={'xs'}
|
||||||
|
color={'gray-white'}
|
||||||
|
onClick={() => onSave(Date.now())}
|
||||||
|
>
|
||||||
|
Close Now
|
||||||
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Modal>
|
</Modal>
|
||||||
<DateTimeTooltip
|
<DateTimeTooltip
|
||||||
|
|
Loading…
Reference in New Issue
Block a user