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

[Point of Contact] Phone extension field #961

Merged
merged 22 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e55b086
WIP point of contact phone extension
shindigira Sep 23, 2024
afacb6c
WIP phone extension flex collapse
shindigira Sep 23, 2024
718a74f
tailwind: update -- responsive breakpoints
shindigira Sep 24, 2024
27feec5
updated phone and phone extension stacked breakpoint
shindigira Sep 24, 2024
8e80392
label updated
shindigira Sep 24, 2024
0738402
gap-15px
shindigira Sep 24, 2024
b4d63be
feat: dynamic wording based on width of device
shindigira Sep 24, 2024
aa00fe6
updated text, constants
shindigira Sep 25, 2024
df2ce2b
Merge branch 'main' of github.com:cfpb/sbl-frontend into 945-phone-ex…
shindigira Sep 25, 2024
8f50bca
added phone extension to Verification field on sign and submit, updat…
shindigira Sep 25, 2024
e781831
added maxLength of 254
shindigira Sep 26, 2024
c2c7c5d
style: break-all
shindigira Sep 26, 2024
4f3869e
sign-and-submit: Extension label
shindigira Sep 26, 2024
cbe3acd
Merge branch 'main' of github.com:cfpb/sbl-frontend into 945-phone-ex…
shindigira Sep 27, 2024
59c43d7
revert: original mobile handling of phone extension
shindigira Sep 27, 2024
e1af4d4
removed unused function
shindigira Sep 28, 2024
f5683cf
chore: disable rendering Extension when no extension
shindigira Sep 30, 2024
224c2bf
extension breakpoint: 600px
shindigira Sep 30, 2024
aea23d0
Merge branch 'main' into 945-phone-extension-field
shindigira Sep 30, 2024
6a4dd3a
sign submit: phone number and extension comes before email
shindigira Sep 30, 2024
c73f413
Merge branch '945-phone-extension-field' of github.com:cfpb/sbl-front…
shindigira Sep 30, 2024
84f33b4
content changes
shindigira Sep 30, 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
5 changes: 4 additions & 1 deletion e2e/example.spec.demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ test('proof of concept', async ({ page }) => {
await page.getByLabel('First name').fill(pointOfContactJson.first_name);
await page.getByLabel('Last name').fill(pointOfContactJson.last_name);
await page
.getByLabel('Work phone numberPhone number')
.getByLabel('Phone numberPhone number')
.fill(pointOfContactJson.phone_number);
await page
.getByLabel('Extension (optional)Extension')
.fill(pointOfContactJson.phone_ext);
await page
.getByLabel('Email addressEmail address')
.fill(pointOfContactJson.email);
Expand Down
6 changes: 5 additions & 1 deletion e2e/fixtures/testFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export const test = baseTest.extend<{
await page.getByRole('button', { name: 'Continue to next step' }).click();
await expect(page.locator('h1')).toContainText(
'Provide point of contact',
{ timeout: 30_000 },
);
});
await use(page);
Expand All @@ -273,8 +274,11 @@ export const test = baseTest.extend<{
await page.getByLabel('First name').fill(pointOfContactJson.first_name);
await page.getByLabel('Last name').fill(pointOfContactJson.last_name);
await page
.getByLabel('Work phone numberPhone number')
.getByLabel('Phone numberPhone number')
.fill(pointOfContactJson.phone_number);
await page
.getByLabel('Extension (optional)Extension')
.fill(pointOfContactJson.phone_ext);
await page
.getByLabel('Email addressEmail address')
.fill(pointOfContactJson.email);
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/filing-app/formAlerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ test('Form Alerts', async ({
await test.step('Complete form', async () => {
await page.getByLabel('First name').fill('Playwright');
await page.getByLabel('Last name').fill('Test');
await page.getByLabel('Work phone').fill('555-555-5555');
await page.getByLabel('Phone number').fill('555-555-5555');
await page.getByLabel('Email address').fill('playwright@test.com');
await page.getByLabel('Street address line 1').fill('555 Main St.');
await page.getByLabel('City').fill('Utah (U');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"hq_address_state": "CA",
"hq_address_zip": "55555",
"phone_number": "555-555-5555",
"phone_ext": "8942",
"email": "point_of_contact_email@email.test"
}
2 changes: 1 addition & 1 deletion src/components/LabelOptional.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function LabelOptional(): JSX.Element {
return (
<span className='text-base font-normal text-grayDark'> (optional)</span>
<span className='text-[1rem] font-normal text-grayDark'> (optional)</span>
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/pages/Filing/FilingApp/FilingSubmit.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getDescriptionForSignAndSubmitSection(

export function PointOfContactConfirm({
data,
heading = 'Confirm your filing point of contact',
heading = 'Confirm the point of contact for your filing',
description = getDescriptionForSignAndSubmitSection('poc'),
}: {
data: FilingType;
Expand All @@ -51,10 +51,13 @@ export function PointOfContactConfirm({
<WellContainer className='u-mt30'>
<DisplayField label='First name' value={poc?.first_name} />
<DisplayField label='Last name' value={poc?.last_name} />
<DisplayField label='Phone number' value={poc?.phone_number} />
{poc?.phone_ext ? (
<DisplayField label='Extension' value={poc?.phone_ext} />
) : null}
<DisplayField label='Email address' value={poc?.email} />
<DisplayField label='Work phone number' value={poc?.phone_number} />
<DisplayField
label='Business address'
label='Address'
value={
poc ? (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function DisplayField({
return (
<div className={classNames('display-field', className)}>
{label ? (
<Heading className='h4' type='3'>
<Heading className='h4 break-all' type='3'>
{label}
</Heading>
) : undefined}
<p className='u-mt10'>{value ?? fallbackValue}</p>
<p className='u-mt10 break-all'>{value ?? fallbackValue}</p>
</div>
);
}
Expand Down
36 changes: 25 additions & 11 deletions src/pages/PointOfContact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import type {
PointOfContactSchema,
} from 'types/formTypes';
import { ContactInfoMap, pointOfContactSchema } from 'types/formTypes';
import { inputCharLimit } from 'utils/constants';
import useAddressStates from 'utils/useAddressStates';
import useFilingStatus from 'utils/useFilingStatus';
import useInstitutionDetails from 'utils/useInstitutionDetails';
Expand Down Expand Up @@ -243,7 +244,7 @@ function PointOfContact(): JSX.Element {
keyLogicFunc={normalKeyLogic}
/>
<div className='mb-[1.875rem]'>
<SectionIntro heading='Provide contact information for your filing'>
<SectionIntro heading='Provide the point of contact for your filing'>
You are required to complete all fields with the exception of the
street address lines labeled optional. Your point of contact
information will not be saved until you provide all required
Expand All @@ -263,26 +264,39 @@ function PointOfContact(): JSX.Element {
label='First name'
id='firstName'
{...register('firstName')}
maxLength={255}
maxLength={inputCharLimit}
errorMessage={formErrors.firstName?.message}
showError
/>
<InputEntry
label='Last name'
id='lastName'
{...register('lastName')}
maxLength={255}
maxLength={inputCharLimit}
errorMessage={formErrors.lastName?.message}
showError
/>
<InputEntry
label='Work phone number'
id='phone'
{...register('phone')}
helperText='Phone number must be in 555-555-5555 format.'
errorMessage={formErrors.phone?.message}
showError
/>
<div className='flex flex-col items-stretch bpSM:flex-row bpSM:gap-[0.9375rem]'>
<InputEntry
className='w-full bpSM:flex-[5]'
label='Phone number'
id='phone'
{...register('phone')}
helperText='Phone number must be in 555-555-5555 format.'
errorMessage={formErrors.phone?.message}
showError
/>
<InputEntry
className='w-full bpSM:flex-[3]'
label='Extension'
id='phoneExtension'
helperText='Extension should be a number.'
{...register('phoneExtension')}
maxLength={inputCharLimit}
isOptional
/>
</div>

<InputEntry
label='Email address'
id='email'
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProfileForm/ProfileFormUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const formatPointOfContactObject = (
first_name: userProfileObject.firstName,
last_name: userProfileObject.lastName,
phone_number: userProfileObject.phone,
phone_ext: userProfileObject.phoneExtension,
email: userProfileObject.email,
hq_address_street_1: userProfileObject.hq_address_street_1,
hq_address_street_2: userProfileObject.hq_address_street_2,
Expand Down
5 changes: 3 additions & 2 deletions src/pages/ProfileForm/Step1Form/Step1FormInfoFieldGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import InputEntry from 'components/InputEntry';
import { Link } from 'components/Link';
import type { FieldErrors, UseFormRegister } from 'react-hook-form';
import type { BasicInfoSchema, ValidationSchema } from 'types/formTypes';
import { inputCharLimit } from 'utils/constants';

// TODO: Refactor to take a generic and pass these TS schemas in
type FormSchema = BasicInfoSchema | ValidationSchema;
Expand Down Expand Up @@ -31,15 +32,15 @@ function Step1FormInfoFieldGroup({
label='First name'
id='firstName'
{...register('firstName')}
maxLength={255}
maxLength={inputCharLimit}
errorMessage={formErrors.firstName?.message}
showError
/>
<InputEntry
label='Last name'
id='lastName'
{...register('lastName')}
maxLength={255}
maxLength={inputCharLimit}
errorMessage={formErrors.lastName?.message}
showError
/>
Expand Down
1 change: 1 addition & 0 deletions src/types/filingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const FilingSchema = z.object({
hq_address_zip: z.string(),
email: z.string(),
phone_number: z.string(),
phone_ext: z.string(),
}),
z.null(),
]),
Expand Down
10 changes: 9 additions & 1 deletion src/types/formTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ export const pointOfContactSchema = z.object({
.regex(usPhoneNumberRegex, {
message: PocZodSchemaErrors.phoneRegex,
}),
phoneExtension: z
.string()
.max(inputCharLimit, {
message: "The phone number extension's maximum character limit is 255",
})
.optional(),
email: z
.string()
.trim()
Expand Down Expand Up @@ -374,6 +380,7 @@ export const ContactInfoMap = {
first_name: 'firstName',
last_name: 'lastName',
phone_number: 'phone',
phone_ext: 'phoneExtension',
email: 'email',
hq_address_street_1: 'hq_address_street_1',
hq_address_street_2: 'hq_address_street_2',
Expand All @@ -390,9 +397,10 @@ export type ContactInfoValues = (typeof ContactInfoMap)[ContactInfoKeys];

export type FormattedPointOfContactSchema = Omit<
PointOfContactSchema,
'firstName' | 'lastName' | 'phone'
'firstName' | 'lastName' | 'phone' | 'phoneExtension'
> & {
first_name: string;
last_name: string;
phone_number: string;
phone_ext: string | undefined;
};
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Ten = 10;
export const ITEMS_PER_PAGE = 20;
export const Thirty = 30;
export const Hundred = 100;
export const inputCharLimit = 255;
export const inputCharLimit = 254;
export const EightHundred = 800;
export const Thousand = 1000;
export const CACHE_TIME = 600_000;
Expand Down
24 changes: 24 additions & 0 deletions src/utils/useWidthMatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useEffect, useState } from 'react';
shindigira marked this conversation as resolved.
Show resolved Hide resolved

function useWidthMatch(query: string): boolean {
const [matches, setMatches] = useState<boolean>(false);

useEffect(() => {
const mediaQuery = window.matchMedia(query);
setMatches(mediaQuery.matches); // Initial check

const handleChange = (event: MediaQueryListEvent) => {
setMatches(event.matches);
};

mediaQuery.addEventListener('change', handleChange);

return () => {
mediaQuery.removeEventListener('change', handleChange);
};
}, [query]);

return matches;
}

export default useWidthMatch;
9 changes: 9 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ const config = {
fontFamily: {
inter: ['Inter', ...defaultConfig.theme.fontFamily.sans],
},
// See `vars-breakpoints.js` of the `design-system` repo
screens: {
bpXS: '0px',
bpSM: '601px',
bpMED: '901px',
bpLG: '1021px',
bpXL: '1201px'

}
},
},
experimental: { optimizeUniversalDefaults: true },
Expand Down