generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tfi, poc): Provide Your Types of Financial Institutions - Skelet…
…on; Point of Contact - Skeleton, Input Validation, Error Handling, Submission (#300) closes #284 closes #287 closes #297 closes #288 ## Changes - style(Fieldgroup): Adhere's to the 770px max-width with box-border (includes borders, margins and padding into the max-width) - style(SectionIntro): Adhere's to the 670px max-width with box-border (includes borders, margins and padding into the max-width) - feat(poc): Point of Contacts - Skeleton - feat(poc): Point of Contacts - Zod Schema - feat(tfi): Types of Financial Institutions - Skeleton Implemented - awaiting functionality - feat(vite proxy): add `v1/filing` as a vite proxy point. - feat(poc): Create a `submitPointOfContact` request for use on the Point of Contact form. - chore(FormMain): Created a `FormMain` component which is a wrapper component for `<form />`. ## Screenshots |Point of Contact|PoC Error Header|Types of Financial Institutions| |---|---|---| |<img width="412" alt="Screenshot 2024-03-15 at 11 35 42 AM" src="https://github.com/cfpb/sbl-frontend/assets/13324863/6109744d-6780-429a-b92f-d4088dc4eae5">|<img width="416" alt="Screenshot 2024-03-15 at 11 35 59 AM" src="https://github.com/cfpb/sbl-frontend/assets/13324863/a0e8137a-9738-44e9-98cd-341b17ff8545">|<img width="410" alt="Screenshot 2024-03-15 at 11 39 12 AM" src="https://github.com/cfpb/sbl-frontend/assets/13324863/44f1ce18-e37c-4e5b-b1cc-60c60b0fa326">| ## How to Test **Pre-requisites** - Make sure to `yarn update`, wipe all Docker containers and Docker volumes, run `yarn seed`. - **Add `SBL_FILING_BASE_URL="http://localhost:8882"` to your `.env`.** **Test Set 0** - Code inspect the proxy changes - Ensure all previously create requests are functioning properly - Inspect the styling of `Fieldgroup` and ensure the 770px (48.125rem) limit is met (including borders, margins, etc). **Test Set 1** - If needed, `toggleRouting()` to disable enforced routing - Navigate to `http://localhost:8899/point-of-contact` to verify Point of Contact - Do not fill anything and hit **submit**. Double-check regex verification (ZIP code, phone number, email, etc) - Fill out everything properly and hit submit. Check in Network tab along (compare with the swagger docs) that the request is properly implemented. NOTE: Currently, the request is **not** working (backend problem). **Test Set 2** - If needed, `toggleRouting()` to disable enforced routing - Navigate to `http://localhost:8899/types-financial-institutions` to verify Types of Financial Institutions. No functionality at this moment. ## TODO - `submitPointOfContact` requires a corresponding `lei` and `filing_period`, so temporarily using **HARDCODED** values. - Types of Financial Institutions: Waiting on `Update Your Financial Institution` to be completed before further updates to the zod schema, input validation and error handling. ## Notes - Includes commits from 222: Update Your Financial Institution; wait till that PR is merged in before this one. - Currently, the `submitPointOfContact` request will return an `500 Internal Server Error`. This can be ignored, [see here](#300 (comment)). --------- Co-authored-by: Meis <[email protected]>
- Loading branch information
1 parent
377b28c
commit e083993
Showing
20 changed files
with
637 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { request } from 'api/axiosService'; | ||
import type { SblAuthProperties } from 'api/useSblAuth'; | ||
import type { FormattedPointOfContactSchema } from 'types/formTypes'; | ||
|
||
const submitPointOfContact = async ( | ||
auth: SblAuthProperties, | ||
userProfileObject: FormattedPointOfContactSchema, | ||
): Promise<null> => { | ||
return request<null>({ | ||
// This will eventually be `/v1/filing/institutions/{lei}/filings/{period_name}/contact-info` | ||
// CURRENTLY HARDCODED | ||
url: `/v1/filing/institutions/123456789TESTBANK123/filings/2024/contact-info`, | ||
method: 'put', | ||
body: userProfileObject, | ||
headers: { Authorization: `Bearer ${auth.user?.access_token}` }, | ||
}); | ||
}; | ||
|
||
export default submitPointOfContact; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ReactNode } from 'react'; | ||
|
||
interface FormProperties { | ||
children: ReactNode; | ||
} | ||
|
||
/** | ||
* | ||
* @returns FormParagraph | ||
*/ | ||
function FormMain({ | ||
children, | ||
className = '', | ||
}: FormProperties & React.ComponentPropsWithoutRef<'form'>): JSX.Element { | ||
return <form className={`mb-[3.75rem] w-full ${className}`}>{children}</form>; | ||
} | ||
|
||
export default FormMain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/pages/Filing/UpdateFinancialProfile/TypesFinancialInstitutionSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import FieldGroup from 'components/FieldGroup'; | ||
import InputEntry from 'components/InputEntry'; | ||
import { Checkbox, Heading, List, ListItem } from 'design-system-react'; | ||
import type { | ||
Control, | ||
FieldErrors, | ||
UseFormRegister, | ||
UseFormSetValue, | ||
} from 'react-hook-form'; | ||
import { Controller as FormController } from 'react-hook-form'; | ||
import { Zero } from 'utils/constants'; | ||
import type { CheckboxOption, UFPSchema } from './types'; | ||
import { checkboxOptions } from './types'; | ||
|
||
interface TypesFinancialInstitutionSectionProperties { | ||
register: UseFormRegister<UFPSchema>; | ||
setValue: UseFormSetValue<UFPSchema>; | ||
formErrors: FieldErrors<UFPSchema>; | ||
control: Control<UFPSchema>; | ||
} | ||
|
||
function TypesFinancialInstitutionSection({ | ||
register, | ||
setValue, | ||
formErrors, | ||
control, | ||
}: TypesFinancialInstitutionSectionProperties): JSX.Element { | ||
// const typeOtherData = data.sbl_institution_types.find(item => { | ||
// return item.sbl_type.id === sblInstitutionTypeMap.other; | ||
// }); | ||
return ( | ||
<FieldGroup> | ||
<Heading type='4'>Type(s) of financial institution</Heading> | ||
<List isUnstyled> | ||
{checkboxOptions.map((option: CheckboxOption): JSX.Element => { | ||
const optionId = `sbl_institution_types.${option.id}`; | ||
|
||
const onCheckboxChange = ( | ||
event: React.ChangeEvent<HTMLInputElement>, | ||
): void => { | ||
setValue(optionId, event.target.checked); | ||
}; | ||
|
||
return ( | ||
<ListItem key={option.id}> | ||
<FormController | ||
render={({ field }) => { | ||
return ( | ||
<Checkbox | ||
id={option.id} | ||
label={option.label} | ||
{...register(optionId)} | ||
checked={field.value} | ||
onChange={onCheckboxChange} | ||
/> | ||
); | ||
}} | ||
control={control} | ||
name={optionId} | ||
/> | ||
</ListItem> | ||
); | ||
})} | ||
</List> | ||
<InputEntry | ||
label='' | ||
id='institutionTypeOther' | ||
{...register('sbl_institution_types_other', { | ||
// value: typeOtherData?.details, | ||
})} | ||
errorMessage={formErrors[Zero]} | ||
showError | ||
/> | ||
</FieldGroup> | ||
); | ||
} | ||
|
||
export default TypesFinancialInstitutionSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.