From 6c9b5a5da6b9f3bde79e9f52560ac6585248ac71 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Wed, 1 Sep 2021 15:58:20 -0500 Subject: [PATCH 01/13] Add no coverage error and checkbox on page --- .../temp-sched/TempSchedAddShiftsStep.tsx | 75 +++++++++++++++---- .../schedules/temp-sched/TempSchedDialog.tsx | 39 +++++++++- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 0a80eb29db..59583d9956 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -5,23 +5,33 @@ import { Grid, Typography, makeStyles, + FormControlLabel, + Checkbox, + FormHelperText, } from '@material-ui/core' import ArrowRightAltIcon from '@material-ui/icons/ArrowRightAlt' import { contentText, Shift, StepContainer } from './sharedUtils' -import { FormContainer } from '../../forms' +import { FormContainer, FormField } from '../../forms' import _ from 'lodash' import TempSchedShiftsList from './TempSchedShiftsList' import TempSchedAddShiftForm from './TempSchedAddShiftForm' import { DateTime, Interval } from 'luxon' import { FieldError } from '../../util/errutil' import { isISOAfter } from '../../util/shifts' +import { Alert, AlertTitle } from '@material-ui/lab' const useStyles = makeStyles((theme) => ({ contentText, avatar: { backgroundColor: theme.palette.primary.main, }, + shiftsListContainer: { + height: '100%', + display: 'flex', + flexDirection: 'column', + }, listOuterContainer: { + height: '100%', position: 'relative', overflowY: 'auto', }, @@ -36,6 +46,9 @@ const useStyles = makeStyles((theme) => ({ maxHeight: '100%', paddingRight: '2rem', }, + testerror: { + margin: '.5rem', + }, })) type AddShiftsStepProps = { @@ -46,6 +59,11 @@ type AddShiftsStepProps = { scheduleID: string edit?: boolean + + isAllowingNoCoverage: boolean + setIsAllowingNoCoverage: (isAllowing: boolean) => void + isShowingNoCoverageWarning: boolean + hasNoCoverageGaps: boolean } type DTShift = { @@ -102,6 +120,10 @@ export default function TempSchedAddShiftsStep({ end, value, edit, + isAllowingNoCoverage, + setIsAllowingNoCoverage, + isShowingNoCoverageWarning, + hasNoCoverageGaps, }: AddShiftsStepProps): JSX.Element { const classes = useStyles() const [shift, setShift] = useState(null as Shift | null) @@ -211,21 +233,46 @@ export default function TempSchedAddShiftsStep({ {/* shifts list container */} - -
- { - setShift(shift) - onChange(value.filter((s) => !shiftEquals(shift, s))) - }} - edit={edit} - /> + +
+
+ { + setShift(shift) + onChange(value.filter((s) => !shiftEquals(shift, s))) + }} + edit={edit} + /> +
+ {isShowingNoCoverageWarning && hasNoCoverageGaps && ( + + There are gaps in coverage + + asd sdasdasdas dasdas dasdsadsadas dasdasdassa ddsadasdas asd + sdasdasdas dasdas dasdsadsadas dasdasdassa ddsadasdas{' '} + + setIsAllowingNoCoverage(e.target.checked)} + name='isAwareOfNoCoverage' + /> + } + /> + + )}
+ {/* + + */} ) diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index c3a622ba6a..491ba5cd3b 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -13,6 +13,7 @@ import { parseInterval } from '../../util/shifts' import { DateTime } from 'luxon' import { getNextWeekday } from '../../util/luxon-helpers' import { useScheduleTZ } from './hooks' +import { getCoverageGapItems } from './shiftsListUtil' // allows changing the index programatically const VirtualizeAnimatedViews = virtualize(SwipeableViews) @@ -82,6 +83,25 @@ export default function TempSchedDialog({ }, }) + const [isAllowingNoCoverage, setIsAllowingNoCoverage] = useState(false) + const [isShowingNoCoverageWarning, setIsShowingNoCoverageWarning] = + useState(false) + + const hasNoCoverageGaps = + getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 + + const handleSubmit = (): void => { + if (hasNoCoverageGaps && !isAllowingNoCoverage) { + setIsShowingNoCoverageWarning(true) + return + } + if (isShowingNoCoverageWarning && isAllowingNoCoverage) { + setIsShowingNoCoverageWarning(false) + } + + submit() + } + type SlideRenderer = { index: number key: number @@ -108,6 +128,10 @@ export default function TempSchedDialog({ start={value.start} end={value.end} edit={edit} + isAllowingNoCoverage={isAllowingNoCoverage} + setIsAllowingNoCoverage={setIsAllowingNoCoverage} + isShowingNoCoverageWarning={isShowingNoCoverageWarning} + hasNoCoverageGaps={hasNoCoverageGaps} /> ) } @@ -116,13 +140,24 @@ export default function TempSchedDialog({ return
} + const noCoverageErrs = + hasNoCoverageGaps && isShowingNoCoverageWarning + ? [ + new Error( + 'There are gaps in coverage. You must check to confirm you are ok with this', + ), + ] + : [] const nonFieldErrs = nonFieldErrors(error).map((e) => ({ message: e.message, })) const fieldErrs = fieldErrors(error).map((e) => ({ message: `${e.field}: ${e.message}`, })) - const errs = nonFieldErrs.concat(fieldErrs).concat(shiftErrors) + const errs = nonFieldErrs + .concat(fieldErrs) + .concat(shiftErrors) + .concat(noCoverageErrs) return ( } - onSubmit={() => submit()} + onSubmit={handleSubmit} onNext={step === 1 ? null : () => setStep(step + 1)} onBack={(edit ? step === 1 : step === 0) ? null : () => setStep(step - 1)} /> From 807e624ee232ea12b32962704055b6759a1e53f4 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Wed, 8 Sep 2021 11:07:18 -0500 Subject: [PATCH 02/13] Add tests for new "no coverage" functionality --- web/src/cypress/integration/temporarySchedule.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/cypress/integration/temporarySchedule.ts b/web/src/cypress/integration/temporarySchedule.ts index b1bd787115..e10e18b475 100644 --- a/web/src/cypress/integration/temporarySchedule.ts +++ b/web/src/cypress/integration/temporarySchedule.ts @@ -106,11 +106,14 @@ function testTemporarySchedule(screen: string): void { ) cy.get('[data-cy="loading-button"]').contains('Next').click() cy.get(addShiftsSelector).should('be.visible.and.contain', 'STEP 2 OF 2') + cy.get('[data-cy="no-coverage-checkbox"]').should('not.exist') cy.dialogForm({ userID: manualAddUser.name }, addShiftsSelector) cy.get('[data-cy="shifts-list"]').should('not.contain', manualAddUser.name) cy.get('button[data-cy="add-shift"]').click() cy.get('[data-cy="shifts-list"]').should('contain', manualAddUser.name) - cy.dialogFinish('Submit') + cy.get('[data-cy="loading-button"]').contains('Submit').click() + cy.get('[data-cy="no-coverage-checkbox"]').should('be.visible').click() + cy.dialogFinish('Retry') cy.visit('/schedules/' + schedule.id + '?start=' + start.toISO()) cy.get('div').contains('Temporary Schedule').click() cy.get('div[data-cy="shift-tooltip"]').should('be.visible') @@ -155,7 +158,9 @@ function testTemporarySchedule(screen: string): void { ) cy.get('button[data-cy="add-shift"]').click() cy.get('[data-cy="shifts-list"]').should('contain', manualAddUser.name) - cy.dialogFinish('Submit') + cy.get('[data-cy="loading-button"]').contains('Submit').click() + cy.get('[data-cy="no-coverage-checkbox"]').should('be.visible').click() + cy.dialogFinish('Retry') cy.reload() // ensure calendar update cy.get('div').contains(manualAddUser.name).click() cy.get('div[data-cy="shift-tooltip"]').should('be.visible') From 7d9631ee17d840455b1bd979e85d0c40177f41d7 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Wed, 8 Sep 2021 11:07:29 -0500 Subject: [PATCH 03/13] Edit text and design --- .../temp-sched/TempSchedAddShiftsStep.tsx | 17 ++++++++++------- .../schedules/temp-sched/TempSchedDialog.tsx | 6 +----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 59583d9956..3a54307650 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -11,7 +11,7 @@ import { } from '@material-ui/core' import ArrowRightAltIcon from '@material-ui/icons/ArrowRightAlt' import { contentText, Shift, StepContainer } from './sharedUtils' -import { FormContainer, FormField } from '../../forms' +import { FormContainer } from '../../forms' import _ from 'lodash' import TempSchedShiftsList from './TempSchedShiftsList' import TempSchedAddShiftForm from './TempSchedAddShiftForm' @@ -46,8 +46,9 @@ const useStyles = makeStyles((theme) => ({ maxHeight: '100%', paddingRight: '2rem', }, - testerror: { - margin: '.5rem', + noCoverageError: { + marginTop: '.5rem', + marginBottom: '.5rem', }, })) @@ -250,17 +251,19 @@ export default function TempSchedAddShiftsStep({
{isShowingNoCoverageWarning && hasNoCoverageGaps && ( - - There are gaps in coverage + + Gaps in coverage - asd sdasdasdas dasdas dasdsadsadas dasdasdassa ddsadasdas asd - sdasdasdas dasdas dasdsadsadas dasdasdassa ddsadasdas{' '} + There are gaps in coverage. During these gaps nobody will + receive alerts. If you still want to proceed, check the box and + then click Retry. setIsAllowingNoCoverage(e.target.checked)} name='isAwareOfNoCoverage' diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index 491ba5cd3b..e79d8a8267 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -142,11 +142,7 @@ export default function TempSchedDialog({ const noCoverageErrs = hasNoCoverageGaps && isShowingNoCoverageWarning - ? [ - new Error( - 'There are gaps in coverage. You must check to confirm you are ok with this', - ), - ] + ? [new Error('This temporary schedule has gaps in coverage.')] : [] const nonFieldErrs = nonFieldErrors(error).map((e) => ({ message: e.message, From 03e5d7a4724f4152ec1a74cc4866fab7c77bb454 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Thu, 9 Sep 2021 14:30:33 -0500 Subject: [PATCH 04/13] Update web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx Co-authored-by: David Talbot --- web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 3a54307650..219e476878 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -273,9 +273,6 @@ export default function TempSchedAddShiftsStep({ )}
- {/* - - */} ) From 5d3779ebaba56ef0ebd011ce5509cac43ad7f712 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Thu, 9 Sep 2021 14:39:33 -0500 Subject: [PATCH 05/13] Update web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx Co-authored-by: David Talbot --- web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 219e476878..e3ca048519 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -266,7 +266,7 @@ export default function TempSchedAddShiftsStep({ data-cy='no-coverage-checkbox' checked={isAllowingNoCoverage} onChange={(e) => setIsAllowingNoCoverage(e.target.checked)} - name='isAwareOfNoCoverage' + name='allowCoverageGaps' /> } /> From 3ce4da3c839fa3aa387d701bbbb8cc9d87a45625 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Thu, 9 Sep 2021 15:08:16 -0500 Subject: [PATCH 06/13] Refactor TempSchedAddShiftsStep props interface --- .../temp-sched/TempSchedAddShiftsStep.tsx | 20 +++++++++---------- .../schedules/temp-sched/TempSchedDialog.tsx | 15 +++++++------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 3a54307650..0d8e975711 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -61,10 +61,9 @@ type AddShiftsStepProps = { scheduleID: string edit?: boolean - isAllowingNoCoverage: boolean - setIsAllowingNoCoverage: (isAllowing: boolean) => void - isShowingNoCoverageWarning: boolean - hasNoCoverageGaps: boolean + showCoverageGapsWarning?: boolean + coverageGapsAllowed?: boolean + setCoverageGapsAllowed: (isAllowed: boolean) => void } type DTShift = { @@ -121,10 +120,9 @@ export default function TempSchedAddShiftsStep({ end, value, edit, - isAllowingNoCoverage, - setIsAllowingNoCoverage, - isShowingNoCoverageWarning, - hasNoCoverageGaps, + coverageGapsAllowed, + setCoverageGapsAllowed, + showCoverageGapsWarning, }: AddShiftsStepProps): JSX.Element { const classes = useStyles() const [shift, setShift] = useState(null as Shift | null) @@ -250,7 +248,7 @@ export default function TempSchedAddShiftsStep({ /> - {isShowingNoCoverageWarning && hasNoCoverageGaps && ( + {showCoverageGapsWarning && ( Gaps in coverage @@ -264,8 +262,8 @@ export default function TempSchedAddShiftsStep({ control={ setIsAllowingNoCoverage(e.target.checked)} + checked={coverageGapsAllowed} + onChange={(e) => setCoverageGapsAllowed(e.target.checked)} name='isAwareOfNoCoverage' /> } diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index e79d8a8267..acd911f543 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -87,11 +87,11 @@ export default function TempSchedDialog({ const [isShowingNoCoverageWarning, setIsShowingNoCoverageWarning] = useState(false) - const hasNoCoverageGaps = + const hasCoverageGaps = getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 const handleSubmit = (): void => { - if (hasNoCoverageGaps && !isAllowingNoCoverage) { + if (hasCoverageGaps && !isAllowingNoCoverage) { setIsShowingNoCoverageWarning(true) return } @@ -128,10 +128,11 @@ export default function TempSchedDialog({ start={value.start} end={value.end} edit={edit} - isAllowingNoCoverage={isAllowingNoCoverage} - setIsAllowingNoCoverage={setIsAllowingNoCoverage} - isShowingNoCoverageWarning={isShowingNoCoverageWarning} - hasNoCoverageGaps={hasNoCoverageGaps} + coverageGapsAllowed={isAllowingNoCoverage} + setCoverageGapsAllowed={setIsAllowingNoCoverage} + showCoverageGapsWarning={ + isShowingNoCoverageWarning && hasCoverageGaps + } /> ) } @@ -141,7 +142,7 @@ export default function TempSchedDialog({ } const noCoverageErrs = - hasNoCoverageGaps && isShowingNoCoverageWarning + hasCoverageGaps && isShowingNoCoverageWarning ? [new Error('This temporary schedule has gaps in coverage.')] : [] const nonFieldErrs = nonFieldErrors(error).map((e) => ({ From 19fbac0c6cb175edfd077b614b51f037652a0270 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Mon, 20 Sep 2021 11:22:40 -0500 Subject: [PATCH 07/13] Addressed override PR refactors --- .../temp-sched/TempSchedAddShiftsStep.tsx | 21 ++++++++++++------ .../schedules/temp-sched/TempSchedDialog.tsx | 22 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 5440622895..5785b60e4c 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -17,8 +17,10 @@ import TempSchedShiftsList from './TempSchedShiftsList' import TempSchedAddShiftForm from './TempSchedAddShiftForm' import { DateTime, Interval } from 'luxon' import { FieldError } from '../../util/errutil' -import { isISOAfter } from '../../util/shifts' +import { isISOAfter, parseInterval } from '../../util/shifts' import { Alert, AlertTitle } from '@material-ui/lab' +import { useScheduleTZ } from './hooks' +import { getCoverageGapItems } from './shiftsListUtil' const useStyles = makeStyles((theme) => ({ contentText, @@ -61,9 +63,9 @@ type AddShiftsStepProps = { scheduleID: string edit?: boolean - showCoverageGapsWarning?: boolean coverageGapsAllowed?: boolean setCoverageGapsAllowed: (isAllowed: boolean) => void + isShowingCoverageGapsWarning: boolean } type DTShift = { @@ -122,11 +124,12 @@ export default function TempSchedAddShiftsStep({ edit, coverageGapsAllowed, setCoverageGapsAllowed, - showCoverageGapsWarning, + isShowingCoverageGapsWarning, }: AddShiftsStepProps): JSX.Element { const classes = useStyles() const [shift, setShift] = useState(null as Shift | null) const [submitted, setSubmitted] = useState(false) + const { zone } = useScheduleTZ(scheduleID) // set start equal to the temporary schedule's start // can't this do on mount since the step renderer puts everyone on the DOM at once @@ -180,6 +183,10 @@ export default function TempSchedAddShiftsStep({ }) setSubmitted(false) } + const schedInterval = parseInterval({ start: start, end: end }) + + const hasCoverageGaps = + getCoverageGapItems(schedInterval, value, zone).length > 0 return ( @@ -248,13 +255,13 @@ export default function TempSchedAddShiftsStep({ /> - {showCoverageGapsWarning && ( + {isShowingCoverageGapsWarning && hasCoverageGaps && ( Gaps in coverage - There are gaps in coverage. During these gaps nobody will - receive alerts. If you still want to proceed, check the box and - then click Retry. + There are gaps in coverage. During these gaps, nobody on the + schedule will receive alerts. If you still want to proceed, + check the box and retry. 0 const handleSubmit = (): void => { - if (hasCoverageGaps && !isAllowingNoCoverage) { - setIsShowingNoCoverageWarning(true) + if (hasCoverageGaps && !shouldAllowNoCoverage) { + setIsShowingCoverageGapsWarning(true) return } - if (isShowingNoCoverageWarning && isAllowingNoCoverage) { - setIsShowingNoCoverageWarning(false) + if (isShowingCoverageGapsWarning && shouldAllowNoCoverage) { + setIsShowingCoverageGapsWarning(false) } submit() @@ -128,11 +128,9 @@ export default function TempSchedDialog({ start={value.start} end={value.end} edit={edit} - coverageGapsAllowed={isAllowingNoCoverage} - setCoverageGapsAllowed={setIsAllowingNoCoverage} - showCoverageGapsWarning={ - isShowingNoCoverageWarning && hasCoverageGaps - } + coverageGapsAllowed={shouldAllowNoCoverage} + setCoverageGapsAllowed={setShouldAllowNoCoverage} + isShowingCoverageGapsWarning={isShowingCoverageGapsWarning} /> ) } @@ -142,7 +140,7 @@ export default function TempSchedDialog({ } const noCoverageErrs = - hasCoverageGaps && isShowingNoCoverageWarning + hasCoverageGaps && isShowingCoverageGapsWarning ? [new Error('This temporary schedule has gaps in coverage.')] : [] const nonFieldErrs = nonFieldErrors(error).map((e) => ({ From 22ee52c8d51396ad7669d55ee860b8edebdeeba1 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Mon, 20 Sep 2021 16:26:05 -0500 Subject: [PATCH 08/13] Handle timezone loading state in temp schedule dialog Co-authored-by: David Talbot --- web/src/app/schedules/temp-sched/TempSchedDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index 2980755a4d..0606d9b6cb 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -88,7 +88,7 @@ export default function TempSchedDialog({ useState(false) const hasCoverageGaps = - getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 + !q.loading && getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 const handleSubmit = (): void => { if (hasCoverageGaps && !shouldAllowNoCoverage) { From ce7bec5aa1d5fe9f6cf0d7c0352fecbea5206ee0 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Mon, 20 Sep 2021 16:27:20 -0500 Subject: [PATCH 09/13] Apply timezone suggestions from code review Co-authored-by: David Talbot --- .../app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 5785b60e4c..cfcc0b4f71 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -129,7 +129,7 @@ export default function TempSchedAddShiftsStep({ const classes = useStyles() const [shift, setShift] = useState(null as Shift | null) const [submitted, setSubmitted] = useState(false) - const { zone } = useScheduleTZ(scheduleID) + const { zone, q } = useScheduleTZ(scheduleID) // set start equal to the temporary schedule's start // can't this do on mount since the step renderer puts everyone on the DOM at once @@ -185,8 +185,11 @@ export default function TempSchedAddShiftsStep({ } const schedInterval = parseInterval({ start: start, end: end }) - const hasCoverageGaps = - getCoverageGapItems(schedInterval, value, zone).length > 0 + const hasCoverageGaps = (() => { + if (q.loading) return false + const schedInterval = parseInterval({ start: start, end: end }, zone) + return getCoverageGapItems(schedInterval, value, zone).length > 0 + })() return ( From 282905fa58706e4ce372bfc86467eadc494f35ca Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Mon, 20 Sep 2021 16:33:35 -0500 Subject: [PATCH 10/13] Fix formatting after commits --- .../app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 8 +++----- web/src/app/schedules/temp-sched/TempSchedDialog.tsx | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index cfcc0b4f71..9a360890f7 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -183,12 +183,10 @@ export default function TempSchedAddShiftsStep({ }) setSubmitted(false) } - const schedInterval = parseInterval({ start: start, end: end }) - const hasCoverageGaps = (() => { - if (q.loading) return false - const schedInterval = parseInterval({ start: start, end: end }, zone) - return getCoverageGapItems(schedInterval, value, zone).length > 0 + if (q.loading) return false + const schedInterval = parseInterval({ start: start, end: end }, zone) + return getCoverageGapItems(schedInterval, value, zone).length > 0 })() return ( diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index 0606d9b6cb..65513afa40 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -88,7 +88,8 @@ export default function TempSchedDialog({ useState(false) const hasCoverageGaps = - !q.loading && getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 + !q.loading && + getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 const handleSubmit = (): void => { if (hasCoverageGaps && !shouldAllowNoCoverage) { From 3dfe6a1fb9cf0028e164dedbccb4fc645525a601 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Tue, 21 Sep 2021 09:33:01 -0500 Subject: [PATCH 11/13] Update TempSchedAddShiftsStep.tsx --- web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 9a360890f7..7736a2ed9e 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -183,6 +183,8 @@ export default function TempSchedAddShiftsStep({ }) setSubmitted(false) } + + // const hasCoverageGaps = (() => { if (q.loading) return false const schedInterval = parseInterval({ start: start, end: end }, zone) From 43880eb610baf4dde250f00a38838f1884ba4b5a Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Tue, 21 Sep 2021 09:53:31 -0500 Subject: [PATCH 12/13] Update TempSchedAddShiftsStep.tsx --- web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx index 7736a2ed9e..c4e1f6f230 100644 --- a/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedAddShiftsStep.tsx @@ -184,7 +184,6 @@ export default function TempSchedAddShiftsStep({ setSubmitted(false) } - // const hasCoverageGaps = (() => { if (q.loading) return false const schedInterval = parseInterval({ start: start, end: end }, zone) From 13dcbd373aeb92320f7fd41a1c1b1c71651bd7f4 Mon Sep 17 00:00:00 2001 From: Spencer Pauly Date: Tue, 21 Sep 2021 10:18:37 -0500 Subject: [PATCH 13/13] Fix schedInterval lint error and merge with master --- web/src/app/schedules/temp-sched/TempSchedDialog.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx index fde2aa514c..430170d0c5 100644 --- a/web/src/app/schedules/temp-sched/TempSchedDialog.tsx +++ b/web/src/app/schedules/temp-sched/TempSchedDialog.tsx @@ -90,9 +90,11 @@ export default function TempSchedDialog({ const [isShowingCoverageGapsWarning, setIsShowingCoverageGapsWarning] = useState(false) - const hasCoverageGaps = - !q.loading && - getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 + const hasCoverageGaps = (() => { + if (q.loading) return false + const schedInterval = parseInterval(value, zone) + return getCoverageGapItems(schedInterval, value.shifts, zone).length > 0 + })() const handleSubmit = (): void => { if (hasCoverageGaps && !shouldAllowNoCoverage) {