-
Notifications
You must be signed in to change notification settings - Fork 57
Enhancement: Support email editing on My Account page #3777
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
1566ce6
51ff649
147674a
f14ecc0
73a6dbb
5f957ea
f1fd0a7
5e18545
fce416c
8d925ee
cc2b89f
a82c61a
d74f7bc
53ff048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| import { checkOrgStatus } from 'services/AuthService'; | ||
| import { TERMS_OF_USE_LINK } from 'common/constants'; | ||
|
|
||
| import { Promotion } from './Promotion/Promotion'; | ||
| // import { Promotion } from './Promotion/Promotion'; | ||
|
|
||
| export interface AuthProps { | ||
| pageTitle: string; | ||
|
|
@@ -36,8 +36,6 @@ | |
| linkURL?: string; | ||
| errorMessage?: string; | ||
| successMessage?: string; | ||
| loading?: boolean; | ||
| inlineSuccessMessage?: string; | ||
| } | ||
|
|
||
| export const Auth = ({ | ||
|
|
@@ -55,32 +53,26 @@ | |
| linkURL, | ||
| errorMessage, | ||
| successMessage, | ||
| loading: externalLoading, | ||
| inlineSuccessMessage, | ||
| }: AuthProps) => { | ||
| // handle visibility for the password field | ||
| const [showPassword, setShowPassword] = useState(false); | ||
| const [loading, setLoading] = useState(false); | ||
| const { t } = useTranslation(); | ||
| const [orgName, setOrgName] = useState('Glific'); | ||
| const [status, setStatus] = useState(''); | ||
|
|
||
| const isLoading = externalLoading !== undefined ? externalLoading : loading; | ||
|
|
||
| useEffect(() => { | ||
| if (mode === 'trialregistration') { | ||
| return; | ||
| } | ||
|
|
||
| axios | ||
| .post(ORGANIZATION_NAME) | ||
|
Check failure on line 66 in src/containers/Auth/Auth.tsx
|
||
| .then(({ data }) => { | ||
| setOrgName(data?.data?.name); | ||
| setStatus(data?.data?.status); | ||
| }) | ||
| .catch((error) => setLogs(`orgName error ${JSON.stringify(error)}`, error)); | ||
| }, [mode]); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| // Stop loading if any error | ||
| if (loading && errorMessage) { | ||
| setLoading(false); | ||
| } | ||
|
|
@@ -94,7 +86,6 @@ | |
| const boxTitleClass = [styles.BoxTitle]; | ||
| let buttonClass = styles.AuthButton; | ||
| let buttonContainedVariant = true; | ||
|
|
||
| switch (mode) { | ||
| case 'login': | ||
| boxClass.push(styles.LoginBox); | ||
|
|
@@ -106,13 +97,6 @@ | |
| boxTitleClass.push(styles.RegistrationBoxTitle); | ||
| buttonClass = styles.AuthRegistrationButton; | ||
| break; | ||
| case 'trialregistration': | ||
| boxClass.push(styles.RegistrationBox); | ||
| boxClass.push(styles.TrialRegistrationBox); | ||
| boxTitleClass.push(styles.RegistrationBoxTitle); | ||
| buttonClass = styles.AuthButton; | ||
| buttonContainedVariant = true; | ||
| break; | ||
| case 'confirmotp': | ||
| boxClass.push(styles.OTPBox); | ||
| boxTitleClass.push(styles.RegistrationBoxTitle); | ||
|
|
@@ -132,10 +116,8 @@ | |
| } | ||
|
|
||
| const isRegistration = mode === 'registration'; | ||
| const isTrialRegistration = mode === 'trialregistration'; | ||
| const whatsAppIcon = <WhatsAppIcon className={styles.WhatsAppIcon} />; | ||
| const otpMessage = 'You will receive an OTP on your WhatsApp number'; | ||
|
|
||
| let displayErrorMessage: any = null; | ||
| if (errorMessage) { | ||
| displayErrorMessage = <div className={styles.ErrorMessage}>{errorMessage}</div>; | ||
|
|
@@ -145,18 +127,22 @@ | |
| setShowPassword(!showPassword); | ||
| }; | ||
|
|
||
| // let's add the additonal password field info to the password field to handle | ||
| // visibility of the field | ||
| const passwordFieldAdditionalInfo = { | ||
| endAdornmentCallback: handlePasswordVisibility, | ||
| togglePassword: showPassword, | ||
| }; | ||
|
|
||
| const handlePhone = | ||
| () => | ||
| (value: string): void => { | ||
| initialFormValues.phone = value; | ||
| }; | ||
| (value: string): void => { | ||
| // eslint-disable-next-line | ||
| initialFormValues.phone = value; | ||
| }; | ||
|
|
||
| let formElements; | ||
| // we should not render form elements when displaying success message | ||
| if (!successMessage) { | ||
| formElements = ( | ||
| <> | ||
|
|
@@ -169,6 +155,7 @@ | |
|
|
||
| <Formik | ||
| initialValues={initialFormValues} | ||
| enableReinitialize={true} | ||
| validationSchema={validationSchema} | ||
| onSubmit={(item) => { | ||
| setLoading(true); | ||
|
|
@@ -187,7 +174,6 @@ | |
| fieldInfo = { ...field, handlePhone }; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const key = index; | ||
|
|
||
| return ( | ||
| <div className={field.styles} key={key}> | ||
| {field.label ? ( | ||
|
|
@@ -201,17 +187,11 @@ | |
| </div> | ||
| ); | ||
| })} | ||
|
|
||
| {isTrialRegistration && inlineSuccessMessage && ( | ||
| <div className={styles.SuccessMessageInline}>{inlineSuccessMessage}</div> | ||
| )} | ||
|
|
||
| {linkURL && ( | ||
| <div className={styles.Link}> | ||
| <Link to={`/${linkURL}`}>{linkText}</Link> | ||
| </div> | ||
| )} | ||
|
|
||
| <div className={styles.CenterButton}> | ||
| {isRegistration ? ( | ||
| <Captcha | ||
|
|
@@ -226,7 +206,7 @@ | |
| }} | ||
| className={buttonClass} | ||
| data-testid="SubmitButton" | ||
| loading={isLoading} | ||
| loading={loading} | ||
| action="register" | ||
| > | ||
| {buttonText} | ||
|
|
@@ -239,14 +219,16 @@ | |
| onClick={submitForm} | ||
| className={buttonClass} | ||
| data-testid="SubmitButton" | ||
| loading={isLoading} | ||
| type="button" | ||
| loading={loading} | ||
| > | ||
| {buttonText} | ||
| {!loading && buttonText} | ||
| </Button> | ||
| )} | ||
| </div> | ||
| {isRegistration && <div className={styles.InformationText}>{otpMessage}</div>} | ||
| {/* We neeed to add this submit button to enable form sumbitting when user hits enter | ||
| key. This is an workaround solution till the bug in formik or react is fixed. For | ||
| more info: https://github.com/formium/formik/issues/1418 */} | ||
|
||
| <input className={styles.SubmitAction} type="submit" /> | ||
| </Form> | ||
| {displayErrorMessage} | ||
|
|
@@ -260,17 +242,14 @@ | |
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className={`${styles.Container} ${isTrialRegistration ? styles.TrialContainer : ''}`} | ||
| data-testid="AuthContainer" | ||
| > | ||
| <div className={styles.Container} data-testid="AuthContainer"> | ||
| <div className={styles.Auth}> | ||
| <div> | ||
| <img src={GlificLogo} className={styles.GlificLogo} alt="Glific" /> | ||
| </div> | ||
| <hr className={styles.Break} /> | ||
|
|
||
| {!isTrialRegistration && <div className={styles.OrganizationName}>{orgName}</div>} | ||
| <div className={styles.OrganizationName}>{orgName}</div> | ||
|
|
||
| <div className={boxClass.join(' ')}> | ||
| {formElements} | ||
|
|
@@ -297,7 +276,7 @@ | |
| ) : null} | ||
| </div> | ||
|
|
||
| {mode === 'login' && <Promotion />} | ||
| {/* {mode === 'login' && <Promotion />} */} | ||
| </div> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.