Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/temp-sched: Fix schedule not merging bug #3473

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions web/src/app/schedules/ScheduleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ export default function ScheduleDetails({
const [slackEnabled] = useConfigValue('Slack.Enable')
const [webhookEnabled] = useConfigValue('Webhook.Enable')

const [editTempSched, setEditTempSched] = useState(false)

const [configTempSchedule, setConfigTempSchedule] =
useState<TempSchedValue | null>(null)
const { zone } = useScheduleTZ(scheduleID)
const onNewTempSched = useCallback(
() => setConfigTempSchedule(defaultTempSchedValue(zone)),
[],
)
const onEditTempSched = useCallback(
(v: TempSchedValue) => setConfigTempSchedule(v),
[],
)
const onNewTempSched = useCallback(() => {
setEditTempSched(false)
setConfigTempSchedule(defaultTempSchedValue(zone))
}, [])
const onEditTempSched = useCallback((v: TempSchedValue) => {
setEditTempSched(true)
setConfigTempSchedule(v)
}, [])

const [deleteTempSchedule, setDeleteTempSchedule] =
useState<TempSchedValue | null>(null)
Expand Down Expand Up @@ -128,6 +130,7 @@ export default function ScheduleDetails({
value={configTempSchedule}
onClose={() => setConfigTempSchedule(null)}
scheduleID={scheduleID}
edit={editTempSched}
/>
)}
{deleteTempSchedule && (
Expand Down
8 changes: 4 additions & 4 deletions web/src/app/schedules/temp-sched/TempSchedDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Alert from '@mui/material/Alert'
import AlertTitle from '@mui/material/AlertTitle'
import _ from 'lodash'
import { DateTime, Interval } from 'luxon'

import { fieldErrors, nonFieldErrors } from '../../util/errutil'
import FormDialog from '../../dialogs/FormDialog'
import { contentText, dtToDuration, Shift, TempSchedValue } from './sharedUtils'
Expand Down Expand Up @@ -70,6 +69,7 @@ type TempScheduleDialogProps = {
onClose: () => void
scheduleID: string
value: TempSchedValue
edit?: boolean
}

const clampForward = (nowISO: string, iso: string): string => {
Expand All @@ -87,17 +87,17 @@ export default function TempSchedDialog({
onClose,
scheduleID,
value: _value,
edit = false,
}: TempScheduleDialogProps): JSX.Element {
const classes = useStyles()
const edit = !_.isEmpty(_value)
const { q, zone, isLocalZone } = useScheduleTZ(scheduleID)
const [now] = useState(DateTime.utc().startOf('minute').toISO())
const [showForm, setShowForm] = useState(false)
const [value, setValue] = useState({
start: clampForward(now, _value.start),
end: _value.end,
clearStart: _value.start,
clearEnd: _value.end,
clearStart: edit ? _value.start : null,
clearEnd: edit ? _value.end : null,
shifts: _value.shifts
.map((s) =>
_.pick(s, 'start', 'end', 'userID', 'truncated', 'displayStart'),
Expand Down