From e32748a8fbfba0fd354c43b1cd76fd25b96d899c Mon Sep 17 00:00:00 2001 From: Manh Hung Nguyen Date: Tue, 12 Dec 2023 09:55:54 +0700 Subject: [PATCH] get message from api --- src/@episerver/forms-react/src/components/FormBody.tsx | 4 ++-- src/@episerver/forms-sdk/src/form-submit/formSubmit.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/@episerver/forms-react/src/components/FormBody.tsx b/src/@episerver/forms-react/src/components/FormBody.tsx index edc15a4..03c4744 100644 --- a/src/@episerver/forms-react/src/components/FormBody.tsx +++ b/src/@episerver/forms-react/src/components/FormBody.tsx @@ -102,12 +102,12 @@ export const FormBody = (props: FormBodyProps) => { formSubmitter.doSubmit(model).then((response: FormSubmitResult)=>{ if(response.success){ - message.current = "The form has been submitted successfully."; + message.current = response.messages.map(m => m.message).join("
"); } else { submissionWarning.current = true; //ignore validation message - message.current = response.errors.filter(e => isNullOrEmpty(e.identifier)).map(e => e.message).join("
"); + message.current = response.messages.filter(m => isNullOrEmpty(m.identifier)).map(m => m.message).join("
"); } validateFail.current = response.validationFail; isFormFinalized.current = isSuccess.current = response.success; diff --git a/src/@episerver/forms-sdk/src/form-submit/formSubmit.ts b/src/@episerver/forms-sdk/src/form-submit/formSubmit.ts index efdde91..0185dff 100644 --- a/src/@episerver/forms-sdk/src/form-submit/formSubmit.ts +++ b/src/@episerver/forms-sdk/src/form-submit/formSubmit.ts @@ -49,12 +49,12 @@ export interface FormSubmitResult { */ validationFail: boolean; /** - * List of error messages from the form submission. + * List of messages from the form submission. */ - errors: FormSubmitError[]; + messages: FormSubmitMessage[]; } -export interface FormSubmitError { +export interface FormSubmitMessage { /** * The section where the message originated from. */