From 0090ea3681db7432b0ab3b662df72e234b4ac1d4 Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Fri, 1 Mar 2024 16:49:41 -0500 Subject: [PATCH 1/6] Allow dashes for rider phone number info --- frontend/src/components/Modal/RiderModalInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Modal/RiderModalInfo.tsx b/frontend/src/components/Modal/RiderModalInfo.tsx index 6d149fcab..ca19378a6 100644 --- a/frontend/src/components/Modal/RiderModalInfo.tsx +++ b/frontend/src/components/Modal/RiderModalInfo.tsx @@ -122,7 +122,7 @@ const RiderModalInfo = ({ id="phoneNumber" name="phoneNumber" type="tel" - ref={register({ required: true, pattern: /^[0-9]{10}$/ })} + ref={register({ required: true, pattern: /^[0-9-]{10,}$/ })} className={styles.firstRow} aria-required="true" /> From dc9eacb14d2514923a7b55948240beda3b9964ea Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Fri, 1 Mar 2024 16:58:51 -0500 Subject: [PATCH 2/6] Allow dashes for employee phone number --- frontend/src/components/EmployeeModal/EmployeeInfo.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx index 03031cf38..4ee485e74 100644 --- a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx +++ b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx @@ -75,13 +75,13 @@ const EmployeeInfo = ({ type="tel" defaultValue={phone} min={10} - max={10} + max={12} aria-required="true" className={cn(styles.input)} ref={register({ required: true, - pattern: /[0-9]{10}/, - maxLength: 10, + pattern: /[0-9-]{10,}/, + maxLength: 12, minLength: 10, })} /> From 34f2e277a64dc8b10dafd061e6990b8286b6ced0 Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Sat, 2 Mar 2024 11:52:50 -0500 Subject: [PATCH 3/6] Add min and max phone number length for rider --- frontend/src/components/Modal/RiderModalInfo.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Modal/RiderModalInfo.tsx b/frontend/src/components/Modal/RiderModalInfo.tsx index ca19378a6..ea0f55631 100644 --- a/frontend/src/components/Modal/RiderModalInfo.tsx +++ b/frontend/src/components/Modal/RiderModalInfo.tsx @@ -122,7 +122,14 @@ const RiderModalInfo = ({ id="phoneNumber" name="phoneNumber" type="tel" - ref={register({ required: true, pattern: /^[0-9-]{10,}$/ })} + min={10} + max={12} + ref={register({ + required: true, + pattern: /^[0-9-]{10,}$/, + maxLength: 12, + minLength: 10, + })} className={styles.firstRow} aria-required="true" /> From 0dde7358ff19ad7289dd88d2b8912e1c0cda0143 Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Sun, 3 Mar 2024 22:19:59 -0500 Subject: [PATCH 4/6] Implement suggested changes and add documentation --- frontend/src/components/EmployeeModal/EmployeeInfo.tsx | 6 +----- frontend/src/components/Modal/RiderModalInfo.tsx | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx index 4ee485e74..ce9ea20ed 100644 --- a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx +++ b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx @@ -74,15 +74,11 @@ const EmployeeInfo = ({ id="phoneNumber" type="tel" defaultValue={phone} - min={10} - max={12} aria-required="true" className={cn(styles.input)} ref={register({ required: true, - pattern: /[0-9-]{10,}/, - maxLength: 12, - minLength: 10, + pattern: /^\d{3}-?\d{3}-?\d{4}$/ //phone numbers can optionally take dashes })} /> {formState.errors.phoneNumber && ( diff --git a/frontend/src/components/Modal/RiderModalInfo.tsx b/frontend/src/components/Modal/RiderModalInfo.tsx index ea0f55631..9c6d5de12 100644 --- a/frontend/src/components/Modal/RiderModalInfo.tsx +++ b/frontend/src/components/Modal/RiderModalInfo.tsx @@ -122,13 +122,9 @@ const RiderModalInfo = ({ id="phoneNumber" name="phoneNumber" type="tel" - min={10} - max={12} ref={register({ required: true, - pattern: /^[0-9-]{10,}$/, - maxLength: 12, - minLength: 10, + pattern: /^\d{3}-?\d{3}-?\d{4}$/, })} className={styles.firstRow} aria-required="true" From 3d1892d59a0427608fb73ee10ec3aaac5407ca8d Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Tue, 5 Mar 2024 12:19:29 -0500 Subject: [PATCH 5/6] Use prettier --- frontend/src/components/EmployeeModal/EmployeeInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx index ce9ea20ed..eea89629e 100644 --- a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx +++ b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx @@ -78,7 +78,7 @@ const EmployeeInfo = ({ className={cn(styles.input)} ref={register({ required: true, - pattern: /^\d{3}-?\d{3}-?\d{4}$/ //phone numbers can optionally take dashes + pattern: /^\d{3}-?\d{3}-?\d{4}$/, //phone numbers can optionally take dashes })} /> {formState.errors.phoneNumber && ( From d205b4f0f893261982f132069dcf99b1e6dde13a Mon Sep 17 00:00:00 2001 From: Selena Liu Date: Sat, 21 Sep 2024 15:04:16 -0400 Subject: [PATCH 6/6] update regex for validity check --- frontend/src/components/EmployeeModal/EmployeeInfo.tsx | 2 +- frontend/src/components/Modal/RiderModalInfo.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx index eea89629e..ea842f53b 100644 --- a/frontend/src/components/EmployeeModal/EmployeeInfo.tsx +++ b/frontend/src/components/EmployeeModal/EmployeeInfo.tsx @@ -78,7 +78,7 @@ const EmployeeInfo = ({ className={cn(styles.input)} ref={register({ required: true, - pattern: /^\d{3}-?\d{3}-?\d{4}$/, //phone numbers can optionally take dashes + pattern: /^(?:\d{3}-\d{3}-\d{4}|\d{10})$/, //123-456-7890 or 1234567890 })} /> {formState.errors.phoneNumber && ( diff --git a/frontend/src/components/Modal/RiderModalInfo.tsx b/frontend/src/components/Modal/RiderModalInfo.tsx index 9c6d5de12..6854e1149 100644 --- a/frontend/src/components/Modal/RiderModalInfo.tsx +++ b/frontend/src/components/Modal/RiderModalInfo.tsx @@ -124,7 +124,7 @@ const RiderModalInfo = ({ type="tel" ref={register({ required: true, - pattern: /^\d{3}-?\d{3}-?\d{4}$/, + pattern: /^(?:\d{3}-\d{3}-\d{4}|\d{10})$/, })} className={styles.firstRow} aria-required="true"