From 5de18f9dc22a67cdc4a745c56430014b09de2c74 Mon Sep 17 00:00:00 2001 From: hamzawaleed01 Date: Mon, 11 Mar 2024 19:17:43 +0500 Subject: [PATCH] fix: hit updateEnterpriseSsoOrchestrationRecord if errore --- .../SettingsSSOTab/NewExistingSSOConfigs.jsx | 4 ++-- .../SettingsSSOTab/SSOFormWorkflowConfig.tsx | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx b/src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx index 792e6913f7..895788f9e2 100644 --- a/src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx +++ b/src/components/settings/SettingsSSOTab/NewExistingSSOConfigs.jsx @@ -161,8 +161,8 @@ const NewExistingSSOConfigs = ({ ); const untested = res.data.filter(config => !config.validated_at || config.validated_at < config.configured_at); const timedOut = res.data.filter(checkTimedOut); - const errored = res.data.filter(checkErrored); - if (timedOut.length >= 1) { + const errored = res.data.filter(checkErrored); + if (timedOut.length >= 1) { setTimedOutConfigs(timedOut); } diff --git a/src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx b/src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx index d5bbe5b8c7..ca6ec565b0 100644 --- a/src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx +++ b/src/components/settings/SettingsSSOTab/SSOFormWorkflowConfig.tsx @@ -105,11 +105,25 @@ export const SSOFormWorkflowConfig = ({ enterpriseId, setConfigureError }) => { }: FormWorkflowHandlerArgs) => { let err = null; - // Accurately detect if form fields have changed - if (!formFieldsChanged) { - // Don't submit if nothing has changed + // Accurately detect if form fields have changed or there's and error in existing record + let isErrored; + if (formFields?.uuid) { + const ssoRecord = + await LmsApiService.fetchEnterpriseSsoOrchestrationRecord( + formFields?.uuid + ).catch(() => { + return { data: {} }; + }); + const { data } = ssoRecord; + isErrored = + data.errored_at && + data.uuid == formFields?.uuid && + data.submitted_at < data.errored_at; + } + if (!isErrored && !formFieldsChanged) { return formFields; } + // else, update enterprise SSO record let updatedFormFields: SSOConfigCamelCase = omit(formFields, ['idpConnectOption', 'spMetadataUrl', 'isPendingConfiguration']); updatedFormFields.enterpriseCustomer = enterpriseId; const submittedFormFields: SSOConfigSnakeCase = snakeCaseDict(updatedFormFields) as SSOConfigSnakeCase;