Skip to content

Commit

Permalink
fix: reintroduced accidentally removed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Apr 15, 2024
1 parent 6e84b37 commit 7103bed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DOMPurify from 'dompurify';
import type { FormErrors } from '@jwp/ott-common/types/form';
import type { CustomFormField, RegistrationFormData } from '@jwp/ott-common/types/account';
import { testId } from '@jwp/ott-common/src/utils/common';
import type { SocialLoginURLs } from '@jwp/ott-hooks-react/src/useSocialLoginUrls';
import useToggle from '@jwp/ott-hooks-react/src/useToggle';
import Visibility from '@jwp/ott-theme/assets/icons/visibility.svg?react';
import VisibilityOff from '@jwp/ott-theme/assets/icons/visibility_off.svg?react';
Expand All @@ -20,6 +21,7 @@ import LoadingOverlay from '../LoadingOverlay/LoadingOverlay';
import Link from '../Link/Link';
import Icon from '../Icon/Icon';
import { modalURLFromLocation } from '../../utils/location';
import SocialButtonsList from '../SocialButtonsList/SocialButtonsList';

import styles from './RegistrationForm.module.scss';

Expand All @@ -36,6 +38,7 @@ type Props = {
submitting: boolean;
validationError?: boolean;
publisherConsents: CustomFormField[] | null;
socialLoginURLs: SocialLoginURLs | null;
};

const RegistrationForm: React.FC<Props> = ({
Expand All @@ -51,6 +54,7 @@ const RegistrationForm: React.FC<Props> = ({
consentValues,
onConsentChange,
consentErrors,
socialLoginURLs,
}: Props) => {
const [viewPassword, toggleViewPassword] = useToggle();

Expand Down Expand Up @@ -80,14 +84,15 @@ const RegistrationForm: React.FC<Props> = ({

return (
<form onSubmit={onSubmit} data-testid={testId('registration-form')} noValidate>
<h2 className={styles.title}>{t('registration.sign_up')}</h2>
<div ref={ref}>
{errors.form ? (
<FormFeedback variant="error" visible={!validationError}>
{errors.form}
</FormFeedback>
) : null}
</div>
<SocialButtonsList socialLoginURLs={socialLoginURLs} />
<h2 className={styles.title}>{t('registration.sign_up')}</h2>
<TextField
value={values.email}
onChange={onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { RegistrationFormData } from '@jwp/ott-common/types/account';
import { getModule } from '@jwp/ott-common/src/modules/container';
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 { useAccountStore } from '@jwp/ott-common/src/stores/AccountStore';
Expand Down Expand Up @@ -54,6 +55,8 @@ const Registration = () => {
setConsentValues(extractConsentValues(publisherConsents));
}, [accountController, publisherConsents]);

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

const { handleSubmit, handleChange, handleBlur, values, errors, validationSchemaError, submitting } = useForm<RegistrationFormData>({
initialValues: { email: '', password: '' },
validationSchema: object().shape({
Expand Down Expand Up @@ -95,6 +98,7 @@ const Registration = () => {
consentValues={consentValues}
publisherConsents={publisherConsents}
loading={loading || publisherConsentsLoading}
socialLoginURLs={socialLoginURLs}
/>
);
};
Expand Down

0 comments on commit 7103bed

Please sign in to comment.