diff --git a/web/src/app/schedules/temp-sched/TempSchedAddNewShift.tsx b/web/src/app/schedules/temp-sched/TempSchedAddNewShift.tsx index c2ae871e47..d733d113f7 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddNewShift.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddNewShift.tsx @@ -1,11 +1,6 @@ import React, { useEffect, useState } from 'react' import { Button, Checkbox, FormControlLabel, Grid } from '@mui/material' -import Accordion from '@mui/material/Accordion' -import AccordionActions from '@mui/material/AccordionActions' -import AccordionSummary from '@mui/material/AccordionSummary' -import AccordionDetails from '@mui/material/AccordionDetails' import Typography from '@mui/material/Typography' -import ExpandMoreIcon from '@mui/icons-material/ExpandMore' import ToggleIcon from '@mui/icons-material/CompareArrows' import _ from 'lodash' import { dtToDuration, Shift, TempSchedValue } from './sharedUtils' @@ -155,155 +150,142 @@ export default function TempSchedAddNewShift({ value={shift} onChange={(val: Shift) => setShift(val)} > - setShowForm(!showForm)} - expanded={showForm} - > - } - data-cy='add-shift-expander' - > + + - ADD SHIFT + Add Shift - - - - - - - - } - label={ - - Configure custom shift - - } - onChange={() => setCustom(!custom)} - /> - - - { - if (!manualEntry) { - const diff = DateTime.fromISO(value, { zone }).diff( - DateTime.fromISO(formValue.start, { zone }), - ) - formValue.end = DateTime.fromISO(formValue.end, { zone }) - .plus(diff) - .toISO() - } - return value - }} - timeZone={zone} - disabled={q.loading || !custom} - hint={isLocalZone ? '' : fmtLocal(value?.start)} - /> - - - {manualEntry ? ( - - {!isLocalZone && fmtLocal(value?.end)} -
- setManualEntry(false)} - endIcon={} - > - Configure as duration - -
- - ) : null - } - timeZone={zone} - disabled={q.loading || !custom} - /> - ) : ( - { - const nextValDT = DateTime.fromISO(nextVal, { zone }) - const formValDT = DateTime.fromISO(formValue?.start ?? '', { - zone, - }) - const duration = dtToDuration(formValDT, nextValDT) - return duration === -1 ? '' : duration.toString() - }} - // value held in state - mapOnChangeValue={( - nextVal: string, - formValue: TempSchedValue, - ) => { - if (!nextVal) return '' - return DateTime.fromISO(formValue.start, { zone }) - .plus({ hours: parseFloat(nextVal) }) - .toISO() - }} - step='any' - min={0} - disabled={q.loading || !custom} - hint={ - custom ? ( +
+ + + + + } + label={ + + Configure custom shift + + } + onChange={() => setCustom(!custom)} + /> + + + { + if (!manualEntry) { + const diff = DateTime.fromISO(value, { zone }).diff( + DateTime.fromISO(formValue.start, { zone }), + ) + formValue.end = DateTime.fromISO(formValue.end, { zone }) + .plus(diff) + .toISO() + } + return value + }} + timeZone={zone} + disabled={q.loading || !custom} + hint={isLocalZone ? '' : fmtLocal(value?.start)} + /> + + + {manualEntry ? ( + + {!isLocalZone && fmtLocal(value?.end)} +
setManualEntry(true)} + data-cy='toggle-duration-on' + onClick={() => setManualEntry(false)} endIcon={} > - Configure as date/time + Configure as duration - ) : null - } - /> - )} - - - - +
+ + ) : null + } + timeZone={zone} + disabled={q.loading || !custom} + /> + ) : ( + { + const nextValDT = DateTime.fromISO(nextVal, { zone }) + const formValDT = DateTime.fromISO(formValue?.start ?? '', { + zone, + }) + const duration = dtToDuration(formValDT, nextValDT) + return duration === -1 ? '' : duration.toString() + }} + // value held in state + mapOnChangeValue={( + nextVal: string, + formValue: TempSchedValue, + ) => { + if (!nextVal) return '' + return DateTime.fromISO(formValue.start, { zone }) + .plus({ hours: parseFloat(nextVal) }) + .toISO() + }} + step='any' + min={0} + disabled={q.loading || !custom} + hint={ + custom ? ( + setManualEntry(true)} + endIcon={} + > + Configure as date/time + + ) : null + } + /> + )} +
+ - -
+ + + ) } diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index 1e19dc235f..aec9762b2e 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -37,6 +37,7 @@ import { InputLabel, FormControl, SelectChangeEvent, + Divider, } from '@mui/material' const mutation = gql` @@ -440,7 +441,11 @@ export default function TempSchedDialog({ - + + + + +