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

feat(page): Complete Your User Profile - No Associated Financial Institutions with Email Domain - Phase 1 #249

Merged
merged 96 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
d42c5bb
wip: Update Your Financial Profile - Skeleton
shindigira Feb 2, 2024
7258690
feat: created wrapper components to abstract away some tailwind form …
shindigira Feb 2, 2024
41c7af4
dep(checkbox): includes the checkbox fix for spreading properties
shindigira Feb 2, 2024
74c359a
fix(Checkbox): uses DSR's Checkbox
shindigira Feb 2, 2024
0dac6dc
fix(style): Added List and ListItem to Checkbox instances
shindigira Feb 2, 2024
be82a14
fix: resolved merge conflicts
shindigira Feb 2, 2024
58b90db
content: removed Login.gov link
shindigira Feb 5, 2024
720bc2c
Merge branch 'main' of github.com:cfpb/sbl-frontend into 223-update-f…
shindigira Feb 5, 2024
5d7d152
chore: added comments
shindigira Feb 6, 2024
80b11a3
chore: aded Checkbox interface
shindigira Feb 6, 2024
cd4ea0f
chore: added eslint exceptions to console.log
shindigira Feb 6, 2024
bf36d60
updatefinancialProfile TypeScript fixes
shindigira Feb 6, 2024
70690c9
fix: ignored certain TS errors for now
shindigira Feb 6, 2024
ac66fbb
fix: resolved merge conflicts from protected api PR
shindigira Feb 6, 2024
0e03e7f
chore: added InputEntry error shown example
shindigira Feb 6, 2024
321006d
Merge branch '223-update-financial-institution-profile-skeleton' of g…
shindigira Feb 6, 2024
0de1c5a
fix: resolve merge conflicts
shindigira Feb 7, 2024
fb64bfb
fix(typescript): relieves many of the TS errors related to UFPSchema
shindigira Feb 7, 2024
af70439
feat: implements the mocked request
shindigira Feb 7, 2024
c90c8d1
comment: added additional TS comment
shindigira Feb 7, 2024
4c019dd
refactor: Rename "InstitutionsDetails" to "ViewInstitutionProfile" to…
meissadia Feb 7, 2024
d4289ca
fix: Update Zod types
meissadia Feb 8, 2024
4b2a005
feat: added base_url and endpoint for the mail api
shindigira Feb 8, 2024
6a9cf23
reformat: changed names of components and moved locations
shindigira Feb 8, 2024
a43f12b
Merge branch 'main' into 222-update-financial-institution-profile
meissadia Feb 8, 2024
aa6dd26
fix: Add Institution update route and link to it
meissadia Feb 8, 2024
ba25b05
Merge branch 'main' of github.com:cfpb/sbl-frontend into 242-update-f…
shindigira Feb 8, 2024
ad7ccc9
Merge branch 'main' of github.com:cfpb/sbl-frontend into 217-complete…
shindigira Feb 8, 2024
fc28146
Merge branch '222-update-financial-institution-profile' of github.com…
shindigira Feb 8, 2024
63f65a1
feat(error-header): Implemented the error header on the update-financ…
shindigira Feb 8, 2024
ce80b4d
fix: resolve merge conflict
shindigira Feb 9, 2024
98c8078
Merge branch '242-update-financial-profile-error-header' of github.co…
shindigira Feb 9, 2024
2cd25de
feat(create-profile-form): start
shindigira Feb 9, 2024
9a64381
chore: abstracted more form components
shindigira Feb 9, 2024
a7b7c2d
feat: Step1FormInfoFieldGroup
shindigira Feb 9, 2024
4ef8e1c
refactor: removed isSalesforce, isMultiselect and FormHeaders type
shindigira Feb 9, 2024
5f669cb
feat: abstracted Step1FormInfoFieldGroup.tsx more
shindigira Feb 9, 2024
62edcf9
chore: added types to info group
shindigira Feb 9, 2024
83c70b0
info group implemented
shindigira Feb 9, 2024
899a25c
chore: typescript change on info group
shindigira Feb 9, 2024
079cb72
feat: useFieldArray implementation
shindigira Feb 9, 2024
95ab275
feat: lei group in-place
shindigira Feb 10, 2024
450b66c
fix: resolved merge conflicts
shindigira Feb 10, 2024
73321ff
refactor: TextInput takes in the error directly
shindigira Feb 10, 2024
703b34e
chore: added PropsWithoutRef
shindigira Feb 10, 2024
35709bc
Merge branch 'main' of github.com:cfpb/sbl-frontend into 220-complete…
shindigira Feb 10, 2024
7a7078d
feat: added AddFinancialInstitution functionality
shindigira Feb 10, 2024
eb299ef
feat: addFinancialInstitution link functioning
shindigira Feb 10, 2024
e367df9
feat: added function to remove institution
shindigira Feb 10, 2024
9c3fbfb
feat: unable to remove financial institution if index is 0
shindigira Feb 10, 2024
da4f7ba
style: bottom removed on last InputEntry
shindigira Feb 10, 2024
738e817
refactor: InputEntry receives errormessage as a string
shindigira Feb 12, 2024
4f1680f
fix: FormHeader margin
shindigira Feb 12, 2024
f2e5c78
feat:added LinkButton component
shindigira Feb 12, 2024
d606370
enhancement: FormErrorHeader typescript
shindigira Feb 12, 2024
4cc6eae
feat: implemented getAllProperties
shindigira Feb 12, 2024
188afdf
feat: implemented error header for CreateProfileFormSF
shindigira Feb 12, 2024
369eb82
feat: implemented submit api request
shindigira Feb 12, 2024
0444b22
feat: implemented clear form
shindigira Feb 12, 2024
6fffc80
Merge branch 'main' of github.com:cfpb/sbl-frontend into 220-complete…
shindigira Feb 13, 2024
7dde96c
refactor: removed SF reference
shindigira Feb 14, 2024
95272e9
fix: error and errorMessage optional, eslint/ts ignore not at file level
shindigira Feb 14, 2024
f926f5a
fix: resolved from comments
shindigira Feb 14, 2024
7d2e39e
refactor: routing via /profile/x
shindigira Feb 16, 2024
868031b
refactor: routing to user profile view
shindigira Feb 16, 2024
043f0c5
refactor: LinkButton uses a button instead of anchor
shindigira Feb 16, 2024
87d396f
feat(routing): if a user's email domain has no associated institution…
shindigira Feb 16, 2024
f27fe19
fix: disabled eslint properly
shindigira Feb 16, 2024
360be73
fix: proper routing o /profile/complete
shindigira Feb 16, 2024
6ff2d47
refactor: moved FormWrapper to respective components
shindigira Feb 16, 2024
d2ef4ca
refactor(Step2): Step2 is now Summary, and uses linkstate, removed us…
shindigira Feb 16, 2024
f4c621a
fix: syntax error
shindigira Feb 16, 2024
cbadc5c
fix(summary): edge case when summary with no scenario object
shindigira Feb 16, 2024
6480cf1
refactor(summary): removed summary route, added as sync component
shindigira Feb 16, 2024
57da101
chore: updated conditional
shindigira Feb 17, 2024
23d1adf
refactor(summary): reinstated summary route
shindigira Feb 17, 2024
a2bcd42
comment: added comment regarding user profile
shindigira Feb 20, 2024
18c04c1
documentation(regtech-mail-api): updated README.md with repo used in …
shindigira Feb 20, 2024
e56eb71
feat(mail-api): updated requests to use the mail api
shindigira Feb 20, 2024
9153c7d
revert: README.md
shindigira Feb 20, 2024
a22908a
Merge branch 'regtech-mail-api-documentation' of github.com:cfpb/sbl-…
shindigira Feb 20, 2024
8d2ef24
dep(querystring): added querystring
shindigira Feb 20, 2024
d5b630f
Merge branch 'regtech-mail-api-documentation' of github.com:cfpb/sbl-…
shindigira Feb 20, 2024
963957b
dep(qs): readded
shindigira Feb 20, 2024
a4b38cf
Merge branch 'regtech-mail-api-documentation' of github.com:cfpb/sbl-…
shindigira Feb 20, 2024
559c6be
feat(mail-api): removed querystring, utilized nomenclature (e.g. lei_1)
shindigira Feb 20, 2024
a57062a
revert: removed query-string
shindigira Feb 20, 2024
467372d
Merge branch 'main' of github.com:cfpb/sbl-frontend into regtech-mail…
shindigira Feb 20, 2024
2e21058
Merge branch 'main' of github.com:cfpb/sbl-frontend into 220-complete…
shindigira Feb 20, 2024
6d9ff0e
Merge branch 'regtech-mail-api-documentation' of github.com:cfpb/sbl-…
shindigira Feb 20, 2024
53fe444
feat(mail-api): updated to handle mail-api
shindigira Feb 20, 2024
159084c
Merge branch 'regtech-mail-api-update' of github.com:cfpb/sbl-fronten…
shindigira Feb 20, 2024
026e65f
Merge branch 'main' of github.com:cfpb/sbl-frontend into 220-complete…
shindigira Feb 20, 2024
f004098
fix: added /complete endpoint to check
shindigira Feb 21, 2024
86d370c
Merge branch 'main' of github.com:cfpb/sbl-frontend into 220-complete…
shindigira Feb 21, 2024
aa5a261
chore: removed Two as it is dead code
shindigira Feb 22, 2024
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
18 changes: 11 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const PrivacyActNotice = lazy(async () => import('pages/Filing/PrivacyNotice'));
const PaperworkNotice = lazy(
async () => import('pages/Filing/PaperworkNotice'),
);
const Summary = lazy(async () => import('pages/Summary/Summary'));

// allow developers to toggle routing in development
const isRoutingEnabled = getIsRoutingEnabled();
Expand Down Expand Up @@ -120,7 +121,7 @@ function ProtectedRoute({
children,
}: ProtectedRouteProperties): JSX.Element | null {
const { pathname } = useLocation();
const isProfileFormPath = pathname === '/profile-form';
const isProfileFormPath = pathname.includes('/profile/complete');

if (!isRoutingEnabled) {
return children;
Expand All @@ -136,17 +137,19 @@ function ProtectedRoute({
const isUserAssociatedWithAnyInstitution =
UserProfile.institutions.length > 0;
if (!isUserAssociatedWithAnyInstitution && !isProfileFormPath)
return <Navigate replace to='/profile-form' />;
return <Navigate replace to='/profile/complete' />;
if (isProfileFormPath && isUserAssociatedWithAnyInstitution)
return <Navigate replace to='/landing' />;
return children;
}

export default function App(): ReactElement {
const auth = useSblAuth();
const { isAuthenticated: userIsAuthenticated, isLoading: isAuthLoading } =
auth;
const { emailAddress } = auth;
const {
isAuthenticated: userIsAuthenticated,
isLoading: isAuthLoading,
emailAddress,
} = auth;

const { isLoading: isFetchUserProfileLoading, data: UserProfile } = useQuery({
queryKey: [`fetch-user-profile-${emailAddress}`, emailAddress],
Expand Down Expand Up @@ -202,15 +205,15 @@ export default function App(): ReactElement {
}
/>
<Route
path='/user-profile/'
path='/profile/view'
element={
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<ViewUserProfile />
</ProtectedRoute>
}
/>
<Route
path='/profile-form'
path='/profile/complete'
element={
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<ProfileForm />
Expand All @@ -230,6 +233,7 @@ export default function App(): ReactElement {
path='/paperwork-reduction-act-notice'
element={<PaperworkNotice />}
/>
<Route path='/summary' element={<Summary />} />
<Route path='/500/*' element={<Error500 />} />
{/* TODO: Remove /loading route once testing is complete */}
<Route path='/loading' element={<LoadingContent />} />
Expand Down
7 changes: 7 additions & 0 deletions src/api/axiosService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ export const request = async <T>({
// @ts-expect-error: Unnecessary check
return response.data;
};

/** Querystring for mail api - form urlencoded * */
/* example: queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'}); */
/* result: //=> 'foo[0]=1&foo[1]=2&foo[2]=3' */
export const queryStringFormat = (object): string =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
queryString.stringify(object, { arrayFormat: 'index' });
15 changes: 8 additions & 7 deletions src/api/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fetchInstitutionDetails from './fetchInstitutionDetails';
import fetchAssociatedInstitutions from './fetchAssociatedInstitutions';
import fetchInstitutions from './fetchInstitutions';
import fetchIsDomainAllowed from './fetchIsDomainAllowed';
import fetchUserProfile from './fetchUserProfile';
import submitUserProfile from './submitUserProfile';
export { default as fetchAssociatedInstitutions } from './fetchAssociatedInstitutions';
export { default as fetchInstitutionDetails } from './fetchInstitutionDetails';
export { default as fetchInstitutions } from './fetchInstitutions';
export { default as fetchIsDomainAllowed } from './fetchIsDomainAllowed';
export { default as fetchUserProfile } from './fetchUserProfile';
export { default as submitUpdateFinancialProfile } from './submitUpdateFinancialProfile';
export { default as submitUserProfile } from './submitUserProfile';
export { default as submitUserProfileFi } from './submitUserProfileFi';

export { fetchInstitutionDetails, fetchAssociatedInstitutions, fetchInstitutions, fetchIsDomainAllowed, fetchUserProfile, submitUserProfile }
20 changes: 13 additions & 7 deletions src/components/FormErrorHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import { Alert, List, ListItem } from 'design-system-react';
import type { FieldErrors } from 'react-hook-form';
import { Element, Link } from 'react-scroll';

import { FormFieldsHeaderError as formFieldsHeaderError } from 'pages/ProfileForm/types';
import getAllProperties from 'utils/getAllProperties';

interface FormErrorHeaderProperties {
id: string;
errors: object;
errors?: FieldErrors;
}

/**
Expand All @@ -16,10 +17,8 @@ interface FormErrorHeaderProperties {
function FormErrorHeader({
errors,
id,
}: FormErrorHeaderProperties): JSX.Element {
// formErrors && Object.keys(formErrors).length > 0
}: FormErrorHeaderProperties): JSX.Element | null {
if (!errors || Object.keys(errors).length === 0) return null;

return (
<div className='mb-[2.8125rem] mt-[2.8125rem] w-full'>
<Element name={id} id={id}>
Expand All @@ -28,7 +27,8 @@ function FormErrorHeader({
status='error'
>
<List isLinks>
{Object.keys(errors).map((key: string): JSX.Element => {
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-call */}
{getAllProperties(errors).map((key: string): JSX.Element => {
const focusKeyItem = (): void => {
const element = document.querySelector(`#${key}`) as
| HTMLElement
Expand All @@ -52,6 +52,7 @@ function FormErrorHeader({

return (
<ListItem key={key}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<Link
href='#'
className='m-list_link'
Expand All @@ -64,9 +65,10 @@ function FormErrorHeader({
tabIndex={0}
>
{
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
formFieldsHeaderError[
key as keyof typeof formFieldsHeaderError
]
] || key
}
</Link>
</ListItem>
Expand All @@ -79,4 +81,8 @@ function FormErrorHeader({
);
}

FormErrorHeader.defaultProps = {
errors: null,
};

export default FormErrorHeader;
15 changes: 12 additions & 3 deletions src/components/FormHeaderWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import type { ReactNode } from 'react';

interface Properties {
interface FormHeaderWrapperProperties {
crumbTrailMarginTop?: boolean;
shindigira marked this conversation as resolved.
Show resolved Hide resolved
children: ReactNode;
}

function FormHeaderWrapper({ children }: Properties): JSX.Element {
function FormHeaderWrapper({
crumbTrailMarginTop,
children,
}: FormHeaderWrapperProperties): JSX.Element {
const marginTop = crumbTrailMarginTop ? 'mt-[1.875rem]' : 'mt-[2.84375rem]';
return (
<div className='mb-[3.75rem] mt-[2.84375rem] max-w-[41.875rem]'>
<div className={`mb-[3.75rem] max-w-[41.875rem] ${marginTop} `}>
{children}
</div>
);
}

FormHeaderWrapper.defaultProps = {
crumbTrailMarginTop: false,
};

export default FormHeaderWrapper;
7 changes: 4 additions & 3 deletions src/components/FormParagraph.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';

interface FormParagraphProperties {
children: string;
className: string;
children: ReactNode;
}

/**
Expand All @@ -10,7 +11,7 @@ interface FormParagraphProperties {
function FormParagraph({
children,
className = '',
}: FormParagraphProperties): JSX.Element {
}: FormParagraphProperties & React.ComponentPropsWithoutRef<'p'>): JSX.Element {
return <p className={`max-w-[41.875rem] ${className}`}>{children}</p>;
}

Expand Down
35 changes: 22 additions & 13 deletions src/components/InputEntry.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* eslint-disable react/require-default-props */
import type { ReactNode } from 'react';
import type { PropsWithoutRef, ReactNode } from 'react';
import { forwardRef } from 'react';
import { Element } from 'react-scroll';

import InputErrorMessage from 'components/InputErrorMessage';
import { Heading, TextInput } from 'design-system-react';
import isString from 'utils/isString';

interface InputEntryProperties
extends React.PropsWithoutRef<JSX.IntrinsicElements['input']> {
extends PropsWithoutRef<JSX.IntrinsicElements['input']> {
id: string;
label: string;
errors: object;
label: JSX.Element | string;
errorMessage?: string | undefined;
isDisabled?: boolean;
isLast?: boolean;
hideInput?: boolean;
Expand All @@ -22,7 +23,7 @@ const InputEntry = forwardRef<HTMLInputElement, InputEntryProperties>(
(
{
id,
errors,
errorMessage,
label,
isDisabled = false,
hideInput = false,
Expand All @@ -33,26 +34,34 @@ const InputEntry = forwardRef<HTMLInputElement, InputEntryProperties>(
},
reference,
) => {
const handleError = Boolean(showError && errors[id]);
const handleError = Boolean(showError && errorMessage);
return (
<div className={`${isLast ? '' : 'mb-[0.9375rem]'}`}>
<Element name={id}>
<label htmlFor={id}>
<Heading
type='4'
className={`${hideInput ? 'mb-[0.5rem]' : 'mb-[0.625rem]'}`}
>
{label}
</Heading>
{isString(label) ? (
<Heading
type='4'
className={`${hideInput ? 'mb-[0.5rem]' : 'mb-[0.625rem]'}`}
>
{label}
</Heading>
) : (
<div>{label}</div>
)}
</label>
{children}
{/* TODO: Will put in a prop to style the email input as a regular text */}
{/* https://github.com/cfpb/sbl-frontend/issues/156 */}
<div className={`${hideInput ? 'hidden' : ''}`}>
<TextInput
isFullWidth
// TODO: fix TS errors due by making props optional
// https://github.com/cfpb/design-system-react/issues/308
// @ts-expect-error will need to be fixed in DSR TextInput
shindigira marked this conversation as resolved.
Show resolved Hide resolved
type={id === 'email' ? 'email' : 'text'}
id={id}
// @ts-expect-error will need to be fixed in DSR TextInput
status={handleError ? 'error' : ''}
aria-invalid={handleError ? 'true' : 'false'}
disabled={isDisabled}
Expand All @@ -62,7 +71,7 @@ const InputEntry = forwardRef<HTMLInputElement, InputEntryProperties>(
</div>
{handleError ? (
<div>
<InputErrorMessage>{errors[id].message}</InputErrorMessage>
<InputErrorMessage>{errorMessage}</InputErrorMessage>
</div>
) : null}
</Element>
Expand Down
33 changes: 33 additions & 0 deletions src/components/LinkButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import { Button, Icon, LinkText } from 'design-system-react';
import type { ComponentPropsWithoutRef, ReactNode } from 'react';

interface LinkButtonProperties {
icon: string;
children: ReactNode;
}

function LinkButton({
className,
icon = 'plus',
children,
...other
}: ComponentPropsWithoutRef<'button'> & LinkButtonProperties): JSX.Element {
return (
<Button
className={`cursor-pointer ${className}`}
// TODO: https://github.com/cfpb/design-system-react/issues/311
// @ts-expect-error label should be ReactNode, fix should be in DSR Repo
label={
<>
<Icon name={icon} />
<LinkText className='ml-2'>{children}</LinkText>
</>
}
asLink
{...other}
/>
);
}

export default LinkButton;
3 changes: 2 additions & 1 deletion src/components/SectionIntro.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Heading } from 'design-system-react';
import FormParagraph from 'components/FormParagraph';
import { Heading } from 'design-system-react';
import type { ReactNode } from 'react';

interface SectionIntroProperties {
heading: ReactNode;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Filing/UpdateFinancialProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod';
import submitUpdateFinancialProfile from 'api/requests/submitUpdateFinancialProfile';
import { submitUpdateFinancialProfile } from 'api/requests';
import useSblAuth from 'api/useSblAuth';
import FieldGroup from 'components/FieldGroup';
import FormButtonGroup from 'components/FormButtonGroup';
Expand All @@ -24,7 +24,7 @@ import {
ufpSchema,
} from 'pages/Filing/UpdateFinancialProfile/types';

import { scrollToErrorForm } from 'pages/ProfileForm/ProfileFormUtils';
import { scrollToElement } from 'pages/ProfileForm/ProfileFormUtils';

import { Controller as FormController, useForm } from 'react-hook-form';

Expand Down Expand Up @@ -78,7 +78,7 @@ function UpdateFinancialProfile(properties: Properties): JSX.Element {
preFormattedData,
);
} else {
scrollToErrorForm(formErrorHeaderId);
scrollToElement(formErrorHeaderId);
}
};

Expand Down Expand Up @@ -153,7 +153,7 @@ function UpdateFinancialProfile(properties: Properties): JSX.Element {
label='Federal Taxpayer Identification Number (TIN)'
id='tin'
{...register('tin')}
errors={formErrors}
errorMessage={formErrors.tin?.message}
showError
/>
</FieldGroup>
Expand Down
Loading
Loading