Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Plans prompt after social register #498

Merged
merged 13 commits into from
Apr 15, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AccountController from '@jwp/ott-common/src/controllers/AccountController
import { checkConsentsFromValues, extractConsentValues, formatConsentsFromValues } from '@jwp/ott-common/src/utils/collection';
import useSocialLoginUrls from '@jwp/ott-hooks-react/src/useSocialLoginUrls';
import useForm from '@jwp/ott-hooks-react/src/useForm';
import { modalURLFromLocation } from '@jwp/ott-ui-react/src/utils/location';
import { modalURLFromLocation, modalURLFromWindowLocation } from '@jwp/ott-ui-react/src/utils/location';
import { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore';

import RegistrationForm from '../../../components/RegistrationForm/RegistrationForm';
Expand Down Expand Up @@ -55,7 +55,7 @@ const Registration = () => {
setConsentValues(extractConsentValues(publisherConsents));
}, [accountController, publisherConsents]);

const socialLoginURLs = useSocialLoginUrls(window.location.href.split('?')[0]);
const socialLoginURLs = useSocialLoginUrls(modalURLFromWindowLocation('personal-details'));

const { handleSubmit, handleChange, handleBlur, values, errors, validationSchemaError, submitting } = useForm<RegistrationFormData>({
initialValues: { email: '', password: '' },
Expand Down
3 changes: 2 additions & 1 deletion platforms/web/src/containers/AppRoutes/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
PATH_USER_PROFILES_EDIT_PROFILE,
PATH_SEARCH,
PATH_USER,
PATH_HOME,
} from '@jwp/ott-common/src/paths';

import useNotifications from '#src/hooks/useNotifications';
Expand All @@ -53,7 +54,7 @@ export default function AppRoutes() {
useNotifications();

if (userData.user && !userData.loading && window.location.href.includes('#token')) {
return <Navigate to="/" />; // component instead of hook to prevent extra re-renders
return <Navigate to={`${PATH_HOME}${location.search}`} />; // component instead of hook to prevent extra re-renders
}

if (userData.user && selectingProfileAvatar !== null) {
Expand Down
Loading