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

content(Complete User Profile): Updated the language, commented out button #598

Merged
merged 15 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/FormErrorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Alert, List, ListItem } from 'design-system-react';
import type { PropsWithChildren } from 'react';
import type { FieldErrors, FieldValues } from 'react-hook-form';
import { Element, Link } from 'react-scroll';
import { One } from 'utils/constants';

import getAllProperties from 'utils/getAllProperties';
import type { FormErrorKeyType } from 'utils/getFormErrorKeyLogic';
Expand All @@ -15,6 +16,7 @@ interface FormErrorHeaderProperties<
errors?: FieldErrors<M>;
alertHeading?: string;
formErrorHeaderObject: T;
showKeyIndexNumber?: boolean;
}

/**
Expand All @@ -30,6 +32,7 @@ function FormErrorHeader<
id,
keyLogicFunc,
formErrorHeaderObject,
showKeyIndexNumber,
}: PropsWithChildren<FormErrorHeaderProperties<M, T>>): JSX.Element | null {
if (!errors || Object.keys(errors).length === 0) return null;

Expand Down Expand Up @@ -100,7 +103,9 @@ function FormErrorHeader<
: 'Missing entry'
}${
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I don't think you need this eslint exception now that you changed it to One?

typeof keyIndex === 'number' ? ` (${keyIndex + 1})` : ''
showKeyIndexNumber && typeof keyIndex === 'number'
? ` (${keyIndex + One})`
: ''
}`}
</Link>
</ListItem>
Expand All @@ -116,6 +121,7 @@ function FormErrorHeader<
FormErrorHeader.defaultProps = {
alertHeading: 'There was a problem completing your user profile',
errors: null,
showKeyIndexNumber: false,
};

export default FormErrorHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ interface AddFinancialInstitutionProperties {
index: number;
register: UseFormRegister<ValidationSchemaCPF>;
formErrors: FieldErrors<ValidationSchemaCPF>;
isLast?: boolean;
}

function AddFinancialInstitution({
index,
register,
formErrors,
isLast,
}: AddFinancialInstitutionProperties): JSX.Element {
return (
<div className='mb-[1.875rem]' key={index}>
<div className={isLast ? '' : 'mb-[1.875rem]'} key={index}>
<FieldGroup>
<InputEntry
label='Financial institution name'
Expand Down Expand Up @@ -46,4 +48,8 @@ function AddFinancialInstitution({
);
}

AddFinancialInstitution.defaultProps = {
isLast: false,
};

export default AddFinancialInstitution;
20 changes: 14 additions & 6 deletions src/pages/ProfileForm/CreateProfileForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import FormWrapper from 'components/FormWrapper';

import FormButtonGroup from 'components/FormButtonGroup';
import FormMain from 'components/FormMain';
import { Link } from 'components/Link';
import LinkButton from 'components/LinkButton';
import SectionIntro from 'components/SectionIntro';
import { Button, Link } from 'design-system-react';
import { Button } from 'design-system-react';
import {
emptyAddFinancialInstitution,
formatUserProfileObject,
Expand All @@ -34,6 +35,8 @@ import { scenarios } from 'pages/Summary/Summary.data';

import { useNavigate } from 'react-router-dom';

import { sblHelpMail } from 'utils/common';
import { One } from 'utils/constants';
import { normalKeyLogic } from 'utils/getFormErrorKeyLogic';

function CreateProfileForm(): JSX.Element {
Expand Down Expand Up @@ -113,6 +116,7 @@ function CreateProfileForm(): JSX.Element {
id={formErrorHeaderId}
formErrorHeaderObject={CupNFFormHeaderErrors}
keyLogicFunc={normalKeyLogic}
// showKeyIndexNumber -- re-enable post-mvp
/>
<Step1FormInfoHeader />
<FormMain>
Expand All @@ -123,11 +127,12 @@ function CreateProfileForm(): JSX.Element {
<SectionIntro heading='Provide your financial institution details'>
Provide the name and LEI of the financial institution for which you
are authorized to file. If you are authorized to file for an
additional financial institution, click &ldquo;Add a financial
institution.&rdquo;
additional financial institution,{' '}
<Link href={sblHelpMail}>email our support staff</Link>.
</SectionIntro>
{fields.map((field, index) => {
const onRemoveThisInstitution = (): void => remove(index);
const isLast = fields.length - One === index;
return (
<div className='flex flex-col' key={`${field.id}`}>
{index !== 0 && (
Expand All @@ -141,15 +146,18 @@ function CreateProfileForm(): JSX.Element {
index={index}
register={register}
formErrors={formErrors}
isLast={isLast}
/>
</div>
);
})}
<div className='mb-[3.75rem]'>
{/* TODO: Re-enable button post-mvp */}
{/* https://github.com/cfpb/sbl-frontend/issues/596 */}
{/* <div className='mb-[3.75rem]'>
<LinkButton onClick={onAppendFinancialInstitutions} icon='plus'>
Add a financial institution
Add an additional financial institution
</LinkButton>
</div>
</div> */}
<FormButtonGroup>
<Button
appearance='primary'
Expand Down
21 changes: 16 additions & 5 deletions src/pages/ProfileForm/Step1Form/Step1FormHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ function Step1FormHeader({ isStep1 }: Step1FormHeaderProperties): JSX.Element {
}
description={
<Paragraph>
In order to begin using the platform you must have a Legal Entity
Identifier (LEI) for your financial institution. If your
organization does not have an LEI, visit the{' '}
<Link href={gleifGetAnLEI}>Global LEI Foundation (GLEIF)</Link>{' '}
website.
<>
In order to begin using the platform you must have a Legal Entity
Identifier (LEI) for your financial institution. If your
organization does not have an LEI, visit the{' '}
<Link href={gleifGetAnLEI} target='_blank'>
Global LEI Foundation (GLEIF)
</Link>{' '}
website. If you need assistance with this form,{' '}
<Link
href='mailto:[email protected]?subject=[BETA] Complete your user profile: Questions after submitting form'
target='_blank'
>
email our support staff
</Link>
.
</>
</Paragraph>
}
/>
Expand Down
12 changes: 10 additions & 2 deletions src/pages/Summary/Summary.data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ function ChildrenError1(): JSX.Element {
<Link className={linkStyles} href='/'>
return to the platform homepage
</Link>
, and sign in with your financial institution email address.
, and sign in with your financial institution email address. If this issue
persists,{' '}
<Link
className={linkStyles}
href='mailto:[email protected]?subject=[BETA] Complete your user profile: Questions after submitting form'
>
email our support staff
</Link>
.
</>
);
}
Expand All @@ -126,7 +134,7 @@ function ChildrenSuccessInstitutionProfileUpdate(): JSX.Element {
return (
<>
Please allow 24-48 hours for a response during normal business hours. If
you need further assistance please{' '}
you need further assistance{' '}
<Link
className={linkStyles}
href='mailto:[email protected]?subject=[BETA] Update your financial institution profile: Questions after submitting form'
Expand Down
25 changes: 13 additions & 12 deletions src/pages/Summary/Summary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect } from 'react';

import useSblAuth from 'api/useSblAuth';
import CrumbTrail from 'components/CrumbTrail';
import FormWrapper from 'components/FormWrapper';
import { LoadingContent } from 'components/Loading';
import { Link } from 'design-system-react';
import type { Scenario } from 'pages/Summary/Summary.data';
import { scenarios } from 'pages/Summary/Summary.data';
import { useLocation, useNavigate } from 'react-router-dom';
import SummaryContent from './SummaryContent';

Expand All @@ -18,6 +18,10 @@ function Summary(): JSX.Element | null {
window.scrollTo({ top: 0 });
}, []);

const auth = useSblAuth();
const { isAuthenticated: userIsAuthenticated, isLoading: isAuthLoading } =
auth;

const { state } = useLocation() as { state: ScenarioStateType };
const navigate = useNavigate();

Expand All @@ -29,23 +33,20 @@ function Summary(): JSX.Element | null {
}, [state, navigate]);

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!state?.scenario) {
if (!state?.scenario || isAuthLoading) {
return <LoadingContent />;
}

const isSuccessInstitutionProfileUpdate: boolean =
state.scenario === scenarios.SuccessInstitutionProfileUpdate;
const platformHomeLink = userIsAuthenticated ? '/landing' : '/';

return (
<main id='main'>
{isSuccessInstitutionProfileUpdate ? (
<CrumbTrail>
<Link isRouterLink href='/landing' key='home'>
Platform home
</Link>
</CrumbTrail>
) : null}
<FormWrapper isMarginTop={!isSuccessInstitutionProfileUpdate}>
<CrumbTrail>
<Link isRouterLink href={platformHomeLink} key='home'>
Platform home
</Link>
</CrumbTrail>
<FormWrapper isMarginTop={false}>
<SummaryContent scenario={state.scenario} />
</FormWrapper>
</main>
Expand Down