diff --git a/src/components/PrivacyStatement/PrivacyStatement.tsx b/src/components/PrivacyStatement/PrivacyStatement.tsx index 61e2cf06..58368f9b 100644 --- a/src/components/PrivacyStatement/PrivacyStatement.tsx +++ b/src/components/PrivacyStatement/PrivacyStatement.tsx @@ -19,6 +19,17 @@ function formatDateTimestamp(timestamp: string) { }); } +type PrivacyStatementContent = { + effectiveDate: string; + version: string; + formContent: { + sections: { + title: string; + content: string; + }[]; + }; +}; + type Props = { baseServicesUrl: string; closeModal: () => void; @@ -37,28 +48,27 @@ function PrivacyStatement({ const [resetKey, setResetKey] = React.useState(0); const [isConfirmModalOpen, setIsConfirmModalOpen] = React.useState(false); const statementUrl = serviceUrl.getStatement({ baseServicesUrl }); - const statementQuery = useQuery({ + const statementQuery = useQuery({ queryKey: statementUrl, queryFn: resolver.query(statementUrl), }); const { mutateAsync, error: mutateUserConsentError } = useMutation(resolver.putUserConsent); + function closeConfirmModal() { + setIsConfirmModalOpen(false); + } + function handleClose() { closeModal(); + closeConfirmModal(); setResetKey(resetKey + 1); } - async function handleSubmit({ - closeAlertModal, - closeModal, - }: { - closeAlertModal: () => void; - closeModal: () => void; - }) { + async function handleSubmit() { const body = { hasConsented: false, - version: statementQuery.data.version, + version: statementQuery.data?.version, }; try { @@ -67,13 +77,13 @@ function PrivacyStatement({ , { containerId: `${prefix}--bmrg-header-notifications` } ); - closeAlertModal(); + closeConfirmModal(); closeModal(); if (window.location) { window.location.reload(); } } catch (e) { - closeAlertModal(); + closeConfirmModal(); } } @@ -83,6 +93,7 @@ function PrivacyStatement({ className={`${prefix}--bmrg-privacy-statement-container ${prefix}--bmrg-header-modal`} onClose={handleClose} open={isOpen} + preventCloseOnClickOutside={isConfirmModalOpen} > ) : ( - statementQuery.data?.formContent?.sections?.length > 0 && ( + statementQuery.data && + statementQuery.data.formContent?.sections?.length > 0 && ( <> - {statementQuery.data.formContent.sections.map((section: any) => { + {statementQuery.data.formContent.sections.map((section) => { return (

- - setIsConfirmModalOpen(false)} - label="Delete Account" - title="Request account deletion" - /> + +

By selecting to delete your account, your account will be deleted along with all of your user data from @@ -149,17 +157,11 @@ function PrivacyStatement({ sure you want to delete your account?

- - - diff --git a/src/components/PrivacyStatement/__snapshots__/PrivacyStatement.spec.tsx.snap b/src/components/PrivacyStatement/__snapshots__/PrivacyStatement.spec.tsx.snap index 791ac4c2..da09be40 100644 --- a/src/components/PrivacyStatement/__snapshots__/PrivacyStatement.spec.tsx.snap +++ b/src/components/PrivacyStatement/__snapshots__/PrivacyStatement.spec.tsx.snap @@ -165,7 +165,6 @@ exports[`Privacy Statement - snapshot 1`] = `