Skip to content

Commit

Permalink
fix: fix onboarding component issues
Browse files Browse the repository at this point in the history
Description:
Fix onboarding component issues
VAN-1996
  • Loading branch information
Ahtesham Quraish authored and Ahtesham Quraish committed Jul 5, 2024
1 parent 75e0195 commit 3960703
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/authn-component/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState } from 'react';

import { Spinner } from '@openedx/paragon';
import { breakpoints, Spinner, useMediaQuery } from '@openedx/paragon';
import PropTypes from 'prop-types';

import { getThirdPartyAuthContext, setCurrentOpenedForm, setOnboardingComponentContext } from './data/reducers';
Expand Down Expand Up @@ -46,6 +46,8 @@ export const AuthnComponent = ({
const dispatch = useDispatch();
const queryParams = useMemo(() => getAllPossibleQueryParams(), []);

const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth - 1 });

const [screenSize, setScreenSize] = useState('lg');
const [hasCloseButton, setHasCloseButton] = useState(true);

Expand All @@ -60,6 +62,15 @@ export const AuthnComponent = ({
const { provider: tpaProvider } = getTpaProvider(tpaHint, providers, secondaryProviders);
const pendingState = queryParams?.tpa_hint && thirdPartyAuthApiStatus === PENDING_STATE;

useEffect(() => {
if (isExtraSmall) {
setScreenSize('fullscreen');
}
if (!isExtraSmall && currentForm !== PROGRESSIVE_PROFILING_FORM) {
setScreenSize('lg');
}
}, [isExtraSmall, currentForm]);

useEffect(() => {
if (currentForm === PROGRESSIVE_PROFILING_FORM) {
setHasCloseButton(false);
Expand Down
1 change: 1 addition & 0 deletions src/forms/fields/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import "password-field";
@import "text-field";
@import "auto-suggested-field";
@import "marketing-email-opt-out-field";
14 changes: 12 additions & 2 deletions src/forms/fields/marketing-email-opt-out-field/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React from 'react';

import { useIntl } from '@edx/frontend-platform/i18n';
import { Form } from '@openedx/paragon';
import classNames from 'classnames';
import PropTypes from 'prop-types';

import messages from './messages';
import './index.scss';

/**
* Marketing email opt in field component. It accepts following handler(s)
Expand All @@ -15,13 +17,20 @@ import messages from './messages';
*/
const MarketingEmailOptInCheckbox = (props) => {
const { formatMessage } = useIntl();
const { name, value, handleChange } = props;
const {
name, value, handleChange, isExtraSmall,
} = props;

return (
<Form.Group controlId="marketingEmailOptIn" className="mb-4">
<Form.Checkbox
name={name}
className="text-gray-800"
className={classNames(
'text-gray-800',
{
marketing_email_opt: isExtraSmall,
},
)}
checked={!!value}
onChange={handleChange}
>
Expand All @@ -35,6 +44,7 @@ MarketingEmailOptInCheckbox.propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.bool.isRequired,
handleChange: PropTypes.func.isRequired,
isExtraSmall: PropTypes.bool.isRequired,
};

export default MarketingEmailOptInCheckbox;
3 changes: 3 additions & 0 deletions src/forms/fields/marketing-email-opt-out-field/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.marketing_email_opt > div > label {
line-height: 1.75rem !important;
}
26 changes: 23 additions & 3 deletions src/forms/registration-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import React, {
import { getConfig, snakeCaseObject } from '@edx/frontend-platform';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Container, Form, Spinner, StatefulButton,
breakpoints, Container, Form, Spinner, StatefulButton, useMediaQuery,
} from '@openedx/paragon';
import classNames from 'classnames';

import HonorCodeAndPrivacyPolicyMessage from './components/honorCodeAndTOS';
import RegistrationFailureAlert from './components/RegistrationFailureAlert';
Expand Down Expand Up @@ -60,6 +61,8 @@ const RegistrationForm = () => {
const dispatch = useDispatch();
const [formStartTime, setFormStartTime] = useState(null);

const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth - 1 });

const [formFields, setFormFields] = useState({
name: '', email: '', password: '', marketingEmailsOptIn: true,
});
Expand Down Expand Up @@ -295,7 +298,15 @@ const RegistrationForm = () => {
{(!autoSubmitRegForm || errorCode.type) && (!currentProvider) && (
<>
<SocialAuthProviders isLoginForm={false} ref={socialAuthnButtonRef} />
<div className="text-center mb-4 mt-3">
<div
className={classNames(
'text-center',
{
'mb-4 mt-3': !isExtraSmall,
'mt-3 mb-3': isExtraSmall,
},
)}
>
{formatMessage(messages.registrationFormHeading2)}
</div>
</>
Expand Down Expand Up @@ -346,8 +357,17 @@ const RegistrationForm = () => {
name="marketingEmailsOptIn"
value={formFields.marketingEmailsOptIn}
handleChange={handleOnChange}
isExtraSmall={isExtraSmall}
/>
<div className="d-flex flex-column my-4">
<div
className={classNames(
'd-flex flex-column',
{
'my-4': !isExtraSmall,
'mt-4 mb-3': isExtraSmall,
},
)}
>
<StatefulButton
id="register-user"
name="register-user"
Expand Down
2 changes: 1 addition & 1 deletion src/forms/reset-password-popup/reset-password/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const ResetPasswordPage = () => {
className="loader-container d-flex flex-column justify-content-center align-items-center my-6 w-100 h-100 text-center"
>
<h1 className="loader-heading text-center mb-4">{formatMessage(messages.resetPasswordTokenValidatingHeadingText)}</h1>
<Spinner animation="border" variant="primary" className="spinner--position-centered" />;
<Spinner animation="border" variant="primary" className="spinner--position-centered" />
</Container>
);
} if (status === PASSWORD_RESET_ERROR || status === PASSWORD_RESET.INVALID_TOKEN) {
Expand Down

0 comments on commit 3960703

Please sign in to comment.