🐛 Avoid error when we delete a date

pull/2116/head
Jérémy Rialland 2022-04-25 12:29:59 +02:00 committed by Jérémy Rialland
parent 1b29cd76b7
commit 569eca1174
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,9 @@
import { goToQuestion, stepAction, updateSituation } from '@/actions/actions'
import {
deleteFromSituation,
goToQuestion,
stepAction,
updateSituation,
} from '@/actions/actions'
import RuleInput from '@/components/conversation/RuleInput'
import Notifications from '@/components/Notifications'
import QuickLinks from '@/components/QuickLinks'
@ -51,7 +56,12 @@ export default function Conversation({
dispatch(goToQuestion(previousAnswers.slice(-1)[0]))
const onChange = (value: PublicodesExpression | undefined) => {
dispatch(updateSituation(currentQuestion, value))
dispatch(
(value == null ? deleteFromSituation : updateSituation)(
currentQuestion,
value
)
)
}
return (