From f89f9adcb19bc3273fa8ff6af1b9327d2043b7bf Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 15:43:15 -0500 Subject: [PATCH 1/7] console log behind in development env only --- pwa/src/components/PatientInfoForm.tsx | 72 +++++++++++++------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/pwa/src/components/PatientInfoForm.tsx b/pwa/src/components/PatientInfoForm.tsx index fa39c95..27f4064 100644 --- a/pwa/src/components/PatientInfoForm.tsx +++ b/pwa/src/components/PatientInfoForm.tsx @@ -33,42 +33,44 @@ export default function Form(): ReactElement { /* istanbul ignore next */ const onSubmit = () => { - // This shows how to access the values of the form - const firstNameField: HTMLInputElement = document.getElementById( - "firstname" - ) as HTMLInputElement; - const lastNameField: HTMLInputElement = document.getElementById( - "lastname" - ) as HTMLInputElement; - const nicknameField: HTMLInputElement = document.getElementById( - "nickname" - ) as HTMLInputElement; - const birthdateField: HTMLInputElement = document.getElementById( - "birthdate" - ) as HTMLInputElement; - const complaintField1: HTMLInputElement = document.getElementById( - "complaint1" - ) as HTMLInputElement; - const complaintField2: HTMLInputElement = document.getElementById( - "complaint2" - ) as HTMLInputElement; - const complaintField3: HTMLInputElement = document.getElementById( - "complaint3" - ) as HTMLInputElement; + if (process.env.NODE_ENV === "development") { + // This shows how to access the values of the form + const firstNameField: HTMLInputElement = document.getElementById( + "firstname" + ) as HTMLInputElement; + const lastNameField: HTMLInputElement = document.getElementById( + "lastname" + ) as HTMLInputElement; + const nicknameField: HTMLInputElement = document.getElementById( + "nickname" + ) as HTMLInputElement; + const birthdateField: HTMLInputElement = document.getElementById( + "birthdate" + ) as HTMLInputElement; + const complaintField1: HTMLInputElement = document.getElementById( + "complaint1" + ) as HTMLInputElement; + const complaintField2: HTMLInputElement = document.getElementById( + "complaint2" + ) as HTMLInputElement; + const complaintField3: HTMLInputElement = document.getElementById( + "complaint3" + ) as HTMLInputElement; - console.log("First name:", firstNameField.value); - console.log("Last name:", lastNameField.value); - console.log("Nickname:", nicknameField.value); - console.log("Birth Date:", birthdateField.value); - console.log( - "Complaints: ", - complaintField1.value + - " " + - complaintField2.value + - " " + - complaintField3.value - ); - console.log("Wants Planning?: " + planning); + console.log("First name:", firstNameField.value); + console.log("Last name:", lastNameField.value); + console.log("Nickname:", nicknameField.value); + console.log("Birth Date:", birthdateField.value); + console.log( + "Complaints: ", + complaintField1.value + + " " + + complaintField2.value + + " " + + complaintField3.value + ); + console.log("Wants Planning?: " + planning); + } }; return ( From b1ad2d8fbf337a27e1819237b2c4e28f894daef1 Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 15:58:08 -0500 Subject: [PATCH 2/7] Birthdate allows digits + '-' only --- pwa/src/components/PatientInfoForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwa/src/components/PatientInfoForm.tsx b/pwa/src/components/PatientInfoForm.tsx index 27f4064..6899e7a 100644 --- a/pwa/src/components/PatientInfoForm.tsx +++ b/pwa/src/components/PatientInfoForm.tsx @@ -113,7 +113,7 @@ export default function Form(): ReactElement { - + Birth Date From c7baf1f1c2d3ea4474336e737ba432a0f3e78341 Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 16:10:41 -0500 Subject: [PATCH 3/7] limit age to 3 characters --- pwa/src/components/PatientInfoForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwa/src/components/PatientInfoForm.tsx b/pwa/src/components/PatientInfoForm.tsx index 6899e7a..30da2e1 100644 --- a/pwa/src/components/PatientInfoForm.tsx +++ b/pwa/src/components/PatientInfoForm.tsx @@ -117,7 +117,7 @@ export default function Form(): ReactElement { Birth Date - + Age{" "} From e1614724978874dff26f2dbecc2b42d0434c8621 Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 16:22:07 -0500 Subject: [PATCH 4/7] forced padding on input labels --- pwa/src/scss/App.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pwa/src/scss/App.scss b/pwa/src/scss/App.scss index 9b04ce6..522510d 100644 --- a/pwa/src/scss/App.scss +++ b/pwa/src/scss/App.scss @@ -5,3 +5,7 @@ #root { height: 100vh; } + +.am-input-label { + padding-right: 0.5em !important; +} From cb91178e63e0cff5be3f6a0494033ce5b3fddfa2 Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 16:29:51 -0500 Subject: [PATCH 5/7] undo global rule --- pwa/src/scss/App.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pwa/src/scss/App.scss b/pwa/src/scss/App.scss index 522510d..9b04ce6 100644 --- a/pwa/src/scss/App.scss +++ b/pwa/src/scss/App.scss @@ -5,7 +5,3 @@ #root { height: 100vh; } - -.am-input-label { - padding-right: 0.5em !important; -} From 7b967cfd08d48f92d3ba96b9ee1dd04a5e9a82f9 Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 16:34:21 -0500 Subject: [PATCH 6/7] global rule fixed --- pwa/src/scss/App.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pwa/src/scss/App.scss b/pwa/src/scss/App.scss index 9b04ce6..0a5c96f 100644 --- a/pwa/src/scss/App.scss +++ b/pwa/src/scss/App.scss @@ -5,3 +5,11 @@ #root { height: 100vh; } + +.am-input-label { + padding-right: 0.5em !important; +} + +.am-textarea-label { + padding-right: 0.5em !important; +} From 465c99790062ffef7f669e472a06efcdf65969ca Mon Sep 17 00:00:00 2001 From: Ben Mitchinson Date: Sat, 18 Apr 2020 17:25:37 -0500 Subject: [PATCH 7/7] blood pressure input validation --- pwa/src/components/PatientInfoForm.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pwa/src/components/PatientInfoForm.tsx b/pwa/src/components/PatientInfoForm.tsx index 30da2e1..72088c5 100644 --- a/pwa/src/components/PatientInfoForm.tsx +++ b/pwa/src/components/PatientInfoForm.tsx @@ -19,6 +19,7 @@ export default function Form(): ReactElement { const [visit, setVisit] = useState(0); // Default: No const [pregnant, setPregnant] = useState(0); // Default: No const [planning, setPlanning] = useState(0); // Default: No + const [bloodPressureValue, setbloodPressureValue] = useState(""); // Data for Radio Buttons const sexValues = [ @@ -73,6 +74,13 @@ export default function Form(): ReactElement { } }; + const validateBp = (value: string) => { + const newChar = value.slice(-1); + if (newChar.match(/[0-9]|\/|^$/) && value.length < 8) { + setbloodPressureValue(value); + } + }; + return (
- + BP