Skip to content

Commit

Permalink
feat: creating new scheduled release defaults time to start of next h…
Browse files Browse the repository at this point in the history
…our (#8577)
  • Loading branch information
jordanl17 authored Feb 11, 2025
1 parent 2ba4b9d commit 224a4e5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {InfoOutlineIcon} from '@sanity/icons'
import {Card, Flex, Stack, TabList, TabPanel, Text} from '@sanity/ui'
import {addMinutes, isValid} from 'date-fns'
import {addHours, isValid, startOfHour} from 'date-fns'
import {useCallback, useEffect, useState} from 'react'

import {Tab, Tooltip} from '../../../../ui-components'
Expand Down Expand Up @@ -39,9 +39,10 @@ export function ReleaseForm(props: {
const handleButtonReleaseTypeChange = useCallback(
(pickedReleaseType: ReleaseType) => {
setButtonReleaseType(pickedReleaseType)
// select time 1 minute from now so that form doesn't immediately
// evaluate to error
const nextInputValue = addMinutes(new Date().setSeconds(0, 0), 1)

// select the start of the next hour
const nextInputValue = startOfHour(addHours(new Date(), 1))

if (pickedReleaseType === 'scheduled') {
setIntendedPublishAt(nextInputValue)
}
Expand Down

0 comments on commit 224a4e5

Please sign in to comment.