Skip to content

Commit

Permalink
use schema CreateRotaitonInput for value
Browse files Browse the repository at this point in the history
  • Loading branch information
KatieMSB committed Jul 19, 2022
1 parent fb2549b commit d2cd120
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
5 changes: 3 additions & 2 deletions web/src/app/rotations/RotationCreateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useState } from 'react'
import { gql, useMutation } from '@apollo/client'
import { nonFieldErrors, fieldErrors } from '../util/errutil'
import FormDialog from '../dialogs/FormDialog'
import RotationForm, { Value } from './RotationForm'
import RotationForm from './RotationForm'
import { DateTime } from 'luxon'
import { Redirect } from 'wouter'
import { CreateRotationInput } from '../../schema'

const mutation = gql`
mutation ($input: CreateRotationInput!) {
Expand All @@ -21,7 +22,7 @@ const mutation = gql`
`

const RotationCreateDialog = (props: { onClose?: () => void }): JSX.Element => {
const [value, setValue] = useState<Value>({
const [value, setValue] = useState<CreateRotationInput>({
name: '',
description: '',
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
Expand Down
17 changes: 4 additions & 13 deletions web/src/app/rotations/RotationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,15 @@ import { ISODateTimePicker } from '../util/ISOPickers'
import NumberField from '../util/NumberField'
import Spinner from '../loading/components/Spinner'
import { FieldError } from '../util/errutil'
import { RotationType } from '../../schema'
import { RotationType, CreateRotationInput } from '../../schema'

interface RotationFormProps {
value: Value
value: CreateRotationInput
errors: FieldError[]
onChange: (value: Value) => void
onChange: (value: CreateRotationInput) => void
disabled?: boolean
}

export interface Value {
name: string
description: string
timeZone: string
type: RotationType
shiftLength: number
start: string
}

const query = gql`
query calcRotationHandoffTimes($input: CalcRotationHandoffTimesInput) {
calcRotationHandoffTimes(input: $input)
Expand Down Expand Up @@ -87,7 +78,7 @@ export default function RotationForm(props: RotationFormProps): JSX.Element {
handoff: value.start,
from: value.start,
timeZone: value.timeZone,
shiftLengthHours: getHours(value.shiftLength, value.type),
shiftLengthHours: getHours(value.shiftLength as number, value.type),
count: 3,
},
},
Expand Down

0 comments on commit d2cd120

Please sign in to comment.