From 22755f371b3512fa2cdefcb040a4c86a26754b57 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Fri, 2 Jun 2023 18:46:52 +0300 Subject: [PATCH] Add nullable state for Result form (#193) --- .../modal/form-container/result-form/result-form.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/components/app/modal-container/modal/form-container/result-form/result-form.tsx b/src/app/components/app/modal-container/modal/form-container/result-form/result-form.tsx index 146979ca..869fd3c1 100644 --- a/src/app/components/app/modal-container/modal/form-container/result-form/result-form.tsx +++ b/src/app/components/app/modal-container/modal/form-container/result-form/result-form.tsx @@ -4,12 +4,13 @@ import { useAppDispatch, useAppSelector } from 'checkout/configure-store'; import { FormName, ModalForms, ModalName, ResultFormInfo, ResultState, ResultType } from 'checkout/state'; import { setResult } from 'checkout/actions'; import { findNamed } from 'checkout/utils'; -import { makeContentInvoiceHook } from './make-content'; +import { ResultFormType, makeContentInvoiceHook } from './make-content'; import { failedHook, pending } from './make-content/make-from-payment-change'; import { ActionBlock } from './action-block'; import { ResultIcon } from './result-icons'; import styled, { css } from 'checkout/styled-components'; import { device } from 'checkout/utils/device'; +import isNil from 'checkout/utils/is-nil'; import { InitialContext } from '../../../../initial-context'; @@ -73,6 +74,15 @@ export const ResultForm = () => { const dispatch = useAppDispatch(); const { hasActions, type, header, description, hasDone } = useMemo(() => { + if (isNil(resultFormInfo)) { + return { + type: ResultFormType.WARNING, + hasActions: false, + hasDone: false, + header: '', + description: '' + }; + } switch (resultFormInfo.resultType) { case ResultType.hookError: return failedHook(locale, resultFormInfo.hookPayload.error);