Skip to content

Commit

Permalink
handle deleted step
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus committed Apr 4, 2024
1 parent 9bac64f commit 2288f07
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/src/app/escalation-policies/PolicyStepsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ const mutation = gql`
}
`

type StepInfo = {
id: string
delayMinutes: number
stepNumber: number
actions?: Destination[]
targets: Target[]
}

export type PolicyStepsCardProps = {
escalationPolicyID: string
repeat: number
steps: Array<{
id: string
delayMinutes: number
stepNumber: number
actions?: Destination[]
targets: Target[]
}>
steps: Array<StepInfo>
}

export default function PolicyStepsCard(
Expand All @@ -59,11 +61,9 @@ export default function PolicyStepsCard(
setStepIDs(props.steps.map((s) => s.id))
}, [props.steps.map((s) => s.id).join(',')]) // update steps when order changes

const orderedSteps = stepIDs.map((id) => {
const step = props.steps.find((s) => s.id === id)
if (!step) throw new Error('Step not found') // should be impossible
return step
})
const orderedSteps = stepIDs
.map((id) => props.steps.find((s) => s.id === id))
.filter((s) => s) as StepInfo[]

const [editStepID, setEditStepID] = useURLParam<string>('editStep', '')
const editStep = props.steps.find((step) => step.id === editStepID)
Expand Down

0 comments on commit 2288f07

Please sign in to comment.