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.
(Review third) Update FI profile - mail api integration (#283)
Part 3 of #222 <img width="1226" alt="Screenshot 2024-02-29 at 4 05 55 PM" src="https://github.com/cfpb/sbl-frontend/assets/2592907/9dd7c191-a102-44ff-9709-3758d9e72f5b"> ## Changes - Formats form data for email submission - Triggers Mail API call upon submission - Replace "Simulated" submission with actual Mail API call ## Planned improvements - [ ] Data submission (formatFinancialProfileObject): Do further comparison against `defaultValues` to determine which data was changed, so that we only send SBL Help the info they actually need to update. This may also be resolved if we can address the [`forwardRef` errors](cfpb/design-system-react#316) we've been seeing, which may fix the issue of changes to these fields not being registered in `react-hook-form` ## How to test this PR 1. In `console` ensure routing is enabled: `setIsRoutingEnabled(true)` 1. Login as a user with an associated institution 2. Click on the Institution to `View institution profile` 3. Click on `Update institution profile` 4. Change some Institution data 5. Hit submit 6. Hopefully an email gets generated 🤞🏾 7. In `console`, you should also see the data that will be sent. <img width="549" alt="Screenshot 2024-02-28 at 5 41 29 PM" src="https://github.com/cfpb/sbl-frontend/assets/2592907/f0515aae-b02b-473c-88b3-4a7a9a881536"> ## Notes - Submission data format (decoded) ``` decoded { "tax_id": "tax_id", "rssd_id": "rss_id", "parent_legal_name": "parent-name", "parent_lei": "parent_lei", "parent_rssd_id": "parent-rssd", "top_holder_legal_name": "top-name", "top_holder_lei": "top-lei", "top_holder_rssd_id": "top-rssd", "sbl_institution_types": "bankSavings,minorityDepository,other", "sbl_institution_types_other": "Test SBL Type", "additional_details": "details" } ``` - Submission data format (encoded) ``` tax_id=tax_id&rssd_id=rss_id&parent_legal_name=parent-name&parent_lei=parent_lei&parent_rssd_id=parent-rssd&top_holder_legal_name=top-name&top_holder_lei=top-lei&top_holder_rssd_id=top-rssd&sbl_institution_types=bankSavings%2CminorityDepository%2Cother&sbl_institution_types_other=Test+SBL+Type&additional_details=details ``` --------- Co-authored-by: shindigira <[email protected]>
- Loading branch information
1 parent
e083993
commit d5f3f60
Showing
10 changed files
with
167 additions
and
170 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
32 changes: 32 additions & 0 deletions
32
src/pages/Filing/UpdateFinancialProfile/buildProfileFormDefaults.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,32 @@ | ||
import type { InstitutionDetailsApiType } from 'types/formTypes'; | ||
import { buildEmailDomainString } from 'utils/formatting'; | ||
|
||
// Map the Institutions API data to an easily trackable format for react-hook-form | ||
const buildProfileFormDefaults = ( | ||
data: InstitutionDetailsApiType, | ||
): InstitutionDetailsApiType => { | ||
const formDefaults: InstitutionDetailsApiType = structuredClone(data); | ||
formDefaults.domains = buildEmailDomainString(data.domains); | ||
formDefaults.additional_details = ''; // Only part of outgoing data | ||
|
||
// Building an easier format to track checkboxes via react-hook-form | ||
formDefaults.sbl_institution_types = []; | ||
if (data.sbl_institution_types) { | ||
for (const currentType of data.sbl_institution_types) { | ||
if (typeof currentType === 'object') { | ||
const { details, sbl_type: sblType } = currentType; | ||
const { id: currentId } = sblType; | ||
|
||
formDefaults.sbl_institution_types[Number(currentId)] = true; | ||
|
||
// Other's details | ||
if (currentId === '13') | ||
formDefaults.sbl_institution_types_other = details; | ||
} | ||
} | ||
} | ||
|
||
return formDefaults; | ||
}; | ||
|
||
export default buildProfileFormDefaults; |
Oops, something went wrong.