Skip to content

Commit

Permalink
Add Validation Email page
Browse files Browse the repository at this point in the history
  • Loading branch information
roshni73 committed Nov 12, 2024
1 parent 3d1ebe0 commit bc04716
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/App/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ const recoverAccount = customWrapRoute({
visibility: 'is-not-authenticated',
},
});
const resendValidationEmail = customWrapRoute({
parent: rootLayout,
path: 'resend-validation-email',
component: {
render: () => import('#views/ResendValidationEmail'),
props: {},
},
context: {
title: 'Resend Validation Email',
visibility: 'is-not-authenticated',
},
});

const wrappedRoutes = {
rootLayout,
Expand All @@ -232,6 +244,7 @@ const wrappedRoutes = {
pageNotFound,
login,
recoverAccount,
resendValidationEmail,
mySubscription,
};

Expand Down
2 changes: 1 addition & 1 deletion src/views/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function Component() {
{strings.loginForgotUserPass}
</Link>
<Link
to="login" // FIXME :LoginResendValidation
to="resendValidationEmail"
title={strings.loginResendValidationTitle}
withUnderline
>
Expand Down
10 changes: 10 additions & 0 deletions src/views/ResendValidationEmail/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"namespace": "resendValidationEmail",
"strings": {
"pageTitle": "IFRC Alert-Hub - Resend Validation Email",
"pageHeading": "Resend Validation Email",
"pageDescription": "Enter the email you used during registration",
"emailInputLabel": "Email",
"submitButtonLabel": "Resend"
}
}
111 changes: 111 additions & 0 deletions src/views/ResendValidationEmail/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { useMemo } from 'react';
import {
Button,
TextInput,
} from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';
import {
createSubmitHandler,
getErrorObject,
type ObjectSchema,
requiredStringCondition,
useForm,
} from '@togglecorp/toggle-form';

import HCaptcha from '#components/Captcha';
import Page from '#components/Page';

import i18n from './i18n.json';
import styles from './styles.module.css';

interface FormFields {
email?: string;
captcha?:string;
}

const defaultFormValue: FormFields = {
};

type FormSchema = ObjectSchema<FormFields>;
type FormSchemaFields = ReturnType<FormSchema['fields']>

const formSchema: FormSchema = {
fields: (): FormSchemaFields => ({
email: {
required: true,
requiredValidation: requiredStringCondition,
},
captcha: {
required: true,
requiredValidation: requiredStringCondition,
},
}),
};

// eslint-disable-next-line import/prefer-default-export
export function Component() {
const strings = useTranslation(i18n);

const {
value: formValue,
error: formError,
setFieldValue,
setError,
validate,
} = useForm(formSchema, { value: defaultFormValue });

const handleFormSubmit = useMemo(
() => createSubmitHandler(
validate,
setError,
// FIXME: Add Submit logic here
() => {},
),
[validate, setError],
);

const fieldError = getErrorObject(formError);

return (
<Page
className={styles.resendValidationEmail}
title={strings.pageTitle}
heading={strings.pageHeading}
description={strings.pageDescription}
>
<form
className={styles.form}
onSubmit={handleFormSubmit}
>

<TextInput
name="email"
label={strings.emailInputLabel}
value={formValue.email}
onChange={setFieldValue}
error={fieldError?.email}
disabled={false}
withAsterisk
autoFocus
/>
<div className={styles.actions}>
<HCaptcha
name="captcha"
onChange={setFieldValue}
/>
<Button
name={undefined}
type="submit"
className={styles.submitButton}
disabled={false}
>
{strings.submitButtonLabel}
</Button>
</div>

</form>
</Page>
);
}

Component.displayName = 'ResendValidationEmail';
21 changes: 21 additions & 0 deletions src/views/ResendValidationEmail/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.resend-validation-email {
.form {
display: flex;
flex-direction: column;
flex-grow: 1;
gap: var(--go-ui-spacing-lg);
margin: 0 auto;
max-width: var(--go-ui-width-content-max);

.submit-button {
align-self: center;
}

.actions {
display: flex;
flex-direction: column;
gap: var(--go-ui-spacing-lg);
align-items: center;
}
}
}

0 comments on commit bc04716

Please sign in to comment.