From a371b1b0bed903cfd82e25329b6885a2d084603c Mon Sep 17 00:00:00 2001 From: Jack Gluskin Date: Mon, 7 Oct 2024 08:24:56 +0100 Subject: [PATCH] Update types --- etc/plugin-config-ui-lib.api.md | 4 ++-- src/components/form/configUIForm.tsx | 9 +++++---- src/types.ts | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/etc/plugin-config-ui-lib.api.md b/etc/plugin-config-ui-lib.api.md index c514ddb..e650545 100644 --- a/etc/plugin-config-ui-lib.api.md +++ b/etc/plugin-config-ui-lib.api.md @@ -595,8 +595,8 @@ export interface PluginConfig { export type PluginConfigFormStep = { children: (IterableStepComponent | React_2.FC)[]; title: string; - submitGuard?: (formValues: any, callApi: ReturnType['callApi']) => Promise['callApi']) => Promise; }; diff --git a/src/components/form/configUIForm.tsx b/src/components/form/configUIForm.tsx index a3dab45..6c9a1a1 100644 --- a/src/components/form/configUIForm.tsx +++ b/src/components/form/configUIForm.tsx @@ -145,11 +145,12 @@ export function ConfigUIForm({ prepareSubmitValues }: ConfigUIFormProps) { const thisStep = getValues('_step'); if (config.steps[thisStep]?.submitGuard) { - const result = await config.steps[thisStep]?.submitGuard(getValues(), callApi); - const resultError = typeof result === 'object' && 'error' in result && result.error; - if (result === false || resultError) { + const result = await config.steps[thisStep]?.submitGuard(getValues(), teamName, callApi); + const resultErrorMessage = + typeof result === 'object' && 'errorMessage' in result && result.errorMessage; + if (result === false || resultErrorMessage) { setError('root', { - message: resultError || 'Validation failed. Please check the form for errors.', + message: resultErrorMessage || 'Validation failed. Please check the form for errors.', }); return; diff --git a/src/types.ts b/src/types.ts index bdbd698..7a05443 100644 --- a/src/types.ts +++ b/src/types.ts @@ -49,8 +49,9 @@ export type PluginConfigFormStep = { title: string; submitGuard?: ( formValues: any, + teamName: string, callApi: ReturnType['callApi'], - ) => Promise; + ) => Promise; }; /**