Skip to content

Commit

Permalink
small optimization and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner-ricks committed Oct 24, 2024
1 parent 500b822 commit d21bdb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/pages/PointOfContact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function FilingDetails(): JSX.Element {

/** Populate form with pre-existing data, when it exists */
useEffect(() => {
let shouldCheck = false;
// Checks if the fetched contact info passes validation
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
const checkPreviousContactInfo = async (): void => {
Expand All @@ -136,7 +137,7 @@ function FilingDetails(): JSX.Element {

if (typeof isVoluntary === 'boolean') {
setValue('isVoluntary', isVoluntary);
checkPreviousContactInfo();
shouldCheck = true;
}

const contactInfo = (filing as FilingType).contact_info;
Expand All @@ -149,6 +150,10 @@ function FilingDetails(): JSX.Element {
}
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
shouldCheck = true;
}

if (shouldCheck) {
checkPreviousContactInfo();
}
}, [filing, setValue, trigger]);
Expand Down
12 changes: 5 additions & 7 deletions src/types/formTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,11 @@ export interface FormattedUserProfileObjectType {

// Voluntary Reporter Status
export const voluntaryReporterStatusSchema = z.object({
isVoluntary: z
.boolean({
invalid_type_error: 'You must indicate your voluntary reporter status.',
required_error: 'You must indicate your voluntary reporter status.',
description: 'You must indicate your voluntary reporter status.',
})
.nullable(),
isVoluntary: z.boolean({
invalid_type_error: 'You must indicate your voluntary reporter status.',
required_error: 'You must indicate your voluntary reporter status.',
description: 'You must indicate your voluntary reporter status.',
}),
});

export type VoluntaryReporterStatusSchema = z.infer<
Expand Down

0 comments on commit d21bdb5

Please sign in to comment.