2
0

feat(inputs): Add Condition step

This commit is contained in:
Baptiste Arnaud
2022-01-15 17:30:20 +01:00
parent 4ccb7bca49
commit 2814a352b2
30 changed files with 1178 additions and 243 deletions

View File

@ -2,6 +2,7 @@ import {
BubbleStep,
BubbleStepType,
ChoiceInputStep,
ConditionStep,
InputStep,
InputStepType,
LogicStep,
@ -36,9 +37,9 @@ export const sendRequest = async <ResponseData>({
}
}
export const isDefined = <T>(value: T | undefined | null): value is T => {
return <T>value !== undefined && <T>value !== null
}
export const isDefined = <T>(
value: T | undefined | null
): value is NonNullable<T> => value !== undefined && value !== null
export const filterTable = <T>(ids: string[], table: Table<T>): Table<T> => ({
byId: ids.reduce((acc, id) => ({ ...acc, [id]: table.byId[id] }), {}),
@ -65,3 +66,6 @@ export const isChoiceInput = (step: Step): step is ChoiceInputStep =>
export const isSingleChoiceInput = (step: Step): step is ChoiceInputStep =>
step.type === InputStepType.CHOICE && !step.options.isMultipleChoice
export const isConditionStep = (step: Step): step is ConditionStep =>
step.type === LogicStepType.CONDITION