diff --git a/app/src/client/App.tsx b/app/src/client/App.tsx index 7f4496e..ee57ddd 100644 --- a/app/src/client/App.tsx +++ b/app/src/client/App.tsx @@ -57,7 +57,7 @@ export default function App({ children }: { children: ReactNode }) { useEffect(() => { if (user) { if (!user.isSignUpComplete) { - if (user.hasAcceptedTos && user.hasSubscribedToMarketingEmails) { + if (user.hasAcceptedTos) { updateCurrentUser({ isSignUpComplete: true, }); @@ -67,13 +67,13 @@ export default function App({ children }: { children: ReactNode }) { localStorage.getItem('hasAcceptedTos') === 'true'; const hasSubscribedToMarketingEmails = localStorage.getItem('hasSubscribedToMarketingEmails') === 'true'; - if (!hasAcceptedTos || !hasSubscribedToMarketingEmails) { + if (!hasAcceptedTos) { setShowTosAndMarketingEmailsModal(true); } else { updateCurrentUser({ isSignUpComplete: true, - hasAcceptedTos: true, - hasSubscribedToMarketingEmails: true, + hasAcceptedTos: hasAcceptedTos, + hasSubscribedToMarketingEmails: hasSubscribedToMarketingEmails, }); setShowTosAndMarketingEmailsModal(false); } diff --git a/app/src/client/auth/LoginSignupForm.tsx b/app/src/client/auth/LoginSignupForm.tsx index d7c4558..f83be99 100644 --- a/app/src/client/auth/LoginSignupForm.tsx +++ b/app/src/client/auth/LoginSignupForm.tsx @@ -45,7 +45,7 @@ const googleSignInUrl = `${config.apiUrl}/auth/google/login`; export const checkBoxErrMsg = { title: - 'To proceed, please ensure you have accepted the Terms & Conditions, Privacy Policy, and opted to receive marketing emails.', + "To proceed, please ensure you've accepted our Terms & Conditions and Privacy Policy.", description: '', }; @@ -88,10 +88,10 @@ export const LoginSignupForm = ({ } = hookForm; useEffect(() => { - if (tocChecked && marketingEmailsChecked) { + if (tocChecked) { setErrorMessage(null); } - }, [tocChecked, marketingEmailsChecked]); + }, [tocChecked]); const handleTocChange = (event: React.ChangeEvent) => { setTocChecked(event.target.checked); @@ -122,7 +122,7 @@ export const LoginSignupForm = ({ updateLocalStorage(); window.location.href = googleSignInUrl; } else { - if (tocChecked && marketingEmailsChecked) { + if (tocChecked) { updateLocalStorage(); window.location.href = googleSignInUrl; } else { diff --git a/app/src/client/components/TosAndMarketingEmailsModal.tsx b/app/src/client/components/TosAndMarketingEmailsModal.tsx index 96d0da8..76f07d6 100644 --- a/app/src/client/components/TosAndMarketingEmailsModal.tsx +++ b/app/src/client/components/TosAndMarketingEmailsModal.tsx @@ -12,6 +12,9 @@ export type ErrorMessage = { description?: string; }; +export const notificationMsg = + 'Before accessing the application, please confirm your agreement to the Terms & Conditions and Privacy Policy.'; + const TosAndMarketingEmailsModal = () => { const history = useHistory(); const { isLoading, setSuccessMessage, setIsLoading } = @@ -22,10 +25,10 @@ const TosAndMarketingEmailsModal = () => { const [marketingEmailsChecked, setMarketingEmailsChecked] = useState(false); useEffect(() => { - if (tocChecked && marketingEmailsChecked) { + if (tocChecked) { setErrorMessage(null); } - }, [tocChecked, marketingEmailsChecked]); + }, [tocChecked]); const handleTocChange = (event: React.ChangeEvent) => { setTocChecked(event.target.checked); @@ -39,12 +42,14 @@ const TosAndMarketingEmailsModal = () => { const onClick = (event: React.MouseEvent) => { event.preventDefault(); - if (tocChecked && marketingEmailsChecked) { + if (tocChecked) { setErrorMessage(null); updateCurrentUser({ isSignUpComplete: true, hasAcceptedTos: tocChecked, - hasSubscribedToMarketingEmails: marketingEmailsChecked, + ...(marketingEmailsChecked && { + hasSubscribedToMarketingEmails: marketingEmailsChecked, + }), }); history.push('/chat'); } else { @@ -66,18 +71,14 @@ const TosAndMarketingEmailsModal = () => {

Almost there...

-

- Before accessing the application, please confirm your agreement to - the Terms & Conditions, Privacy Policy, and consent to receiving - marketing emails by checking the boxes below -

+

{notificationMsg}

{ test('renders TosAndMarketingEmailsModal component', async () => { @@ -55,9 +57,7 @@ describe('TosAndMarketingEmailsModal', () => { test('renders error message when save button is clicked and checkboxes are not checked', async () => { renderInContext(); fireEvent.click(screen.getByText('Save')); - const errorItems = await screen.findAllByText( - 'Before accessing the application, please confirm your agreement to the Terms & Conditions, Privacy Policy, and consent to receiving marketing emails by checking the boxes below' - ); + const errorItems = await screen.findAllByText(notificationMsg); expect(errorItems).toHaveLength(1); }); });