From af03f2869db12e12c41f7311cb332aa56257ad4c Mon Sep 17 00:00:00 2001 From: alissav <63168432+alissav30@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:33:12 -0700 Subject: [PATCH 1/9] quick styling fix --- apps/react/src/pages/WaiveCardinalCare.tsx | 6 +++--- apps/server/var/sessions.db | Bin 12288 -> 12288 bytes apps/server/var/sqlite.db | Bin 69632 -> 73728 bytes 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/react/src/pages/WaiveCardinalCare.tsx b/apps/react/src/pages/WaiveCardinalCare.tsx index bdf1626..bd45237 100644 --- a/apps/react/src/pages/WaiveCardinalCare.tsx +++ b/apps/react/src/pages/WaiveCardinalCare.tsx @@ -220,10 +220,10 @@ const WaiveCardinalCare = () => { }; const titleStyle = { - fontSize: '32px', // Adjusted for a larger banner + fontSize: '36px', // Adjusted for a larger banner fontWeight: 'bold', flex: '1', - marginLeft: '20px', + marginLeft: '530px', }; const infoButtonStyle = { @@ -235,7 +235,7 @@ const WaiveCardinalCare = () => { border: 'none', borderRadius: '4px', cursor: 'pointer', - marginRight: '20px', + marginRight: '530px', }; const labelStyle = { diff --git a/apps/server/var/sessions.db b/apps/server/var/sessions.db index f5136cb10c75400512dea3c9d5998efda655f852..66916525bce5ccaf9343c8eacd3dc75065150433 100644 GIT binary patch delta 222 zcmZojXh@hK%~&;2#+k8dW5N=C9%fz6~0S$)}?6Fg9}RX-Sg9Y+{%KIvO;r;DsoKIBb+MUTDl1sOtzIv+q_aXkx{#vy-_vU zr8FtE($vY@G~3-U)Hl#1IY&3IC^)~=$hn|c*VG%N$>om#P?HaLt!tQ3B`eUbM%Bsp p^%W+sk&obE=AX#Gf17_B|3v6~0Sbf=>6)jyY z!d%0Q@&mj)Q;mG0k|Iiz0=zt;QgVvI3!MTgQ=BT^9EsX@V6v@T+UAwAiHtgRKwa|Q z6^>?}#Re6*&H;YGCO+9tX0AS=;Rc?rNkv8`CEkfZU5O#9LAo5o8rj)_HZ?jzZK`Ai z@l+?@*H@UlMm~aviGLdd|84$lKsa%;ph7hN6s6_7!GxyB+ Wlnxs9Xt6#wF`(!>{$i0 z%7!&MRtLyqG>!t9%{BSPer-XJ24*1U2Vzbj7MwiMMSk*}Jw}^T56t6d6qr0QH+XaD z!fw9FAM#iy&sw80S$D$MO%Ip_7`Z2JERx-9Kk*>n#m(9eZt#Po8JK~X z3y1}Pm~Zk#7x~F^_84tWJusV}hZiWs#N^As`NF0 E00K-io&W#< From 4c8217a8e5198810d999abc3db98af5756ff0f1d Mon Sep 17 00:00:00 2001 From: alissav <63168432+alissav30@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:37:27 -0700 Subject: [PATCH 2/9] Squashed commit of the following: commit c1237432c91d15f468e87349ad4da85c80568e3f Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Thu Apr 11 08:02:25 2024 -0700 Fixed wording on waiver commit 0c2d0de55d824c0f3220a4a70e08ca5be320472f Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Thu Apr 11 00:40:53 2024 -0700 Resolved #53 commit 180bd451f3a2b004581c6e7c57517b550953ca5e Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Thu Apr 11 00:25:39 2024 -0700 Resolved #21 This commit is a doozy - definitely look at all changed files here. commit 1ef1f7b82f38724aa27a95cea4ffa6b54148435a Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 23:41:33 2024 -0700 Fixed Cardinal Care encoding according to Abhinav's update - Undid a rule removal from my last commit commit d45dc16533051d2b5836de14068a6a12edacca20 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 22:04:41 2024 -0700 Many changes related to #42 and #51 - Removed rules from the ruleset that resulted in the covid-specific rules being ignored. - Updated the facility label to be "Outpatient Center", since Hospital already appeared. - Updated the tour dataset to correctly pass for covid vaccines - Resolved #42 commit 142bbd8aeb768e117a74628b13b7659a5f8654f5 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 21:03:44 2024 -0700 Resolved #51 commit bd5a250f202767ddc2e88e228dd075a3e992ea17 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 20:34:46 2024 -0700 Resolved #55 commit 5419eba48c798b2b6bee76cdb568783fec7a581b Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 20:13:31 2024 -0700 Resolved #57 commit cbfb491dc412e9440eb1168372b73f1de38b18f5 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 20:06:06 2024 -0700 Resolved #52 commit 7c9a3431876eedba5f7cd27ed81d855a296134b0 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 17:24:20 2024 -0700 Resolved #56 commit 9de5471f58ba651cf281a553d2ff26cd3b35c510 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 16:56:00 2024 -0700 Resolved #54 commit 2155cc8a0af8c0aecf213b284f43416243d0daab Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 16:27:30 2024 -0700 Fixed #49 commit 076d6d3d676f795a4d3b15c615d4cb589d5316cf Merge: af4204d dd7b7d5 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 12:09:13 2024 -0700 Merge branch 'alissa-branch' commit af4204d79389c6ce7ca7ed4de956bee165264832 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 09:54:47 2024 -0700 Resolved #16 commit 2a88ab80d8689304f87affdc7223ffbe4af7aaf9 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 09:27:15 2024 -0700 Resolved #34 commit 768afe2155a5327a6ec4202f42bee9cf7ecc820e Merge: 97e0046 4327cb6 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 09:13:04 2024 -0700 Merge branch 'alissa-branch' commit 97e00467236138c1b8209dd25003732befe116b1 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 09:08:25 2024 -0700 Updated waiver styling commit f778613fecf516b7a03c0867772b1b8a7cf0812e Merge: f6bb071 96991e4 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 08:38:02 2024 -0700 Merge pull request #45 from pfw13/alissa-branch finished the "waive cardinal care"page commit f6bb071ee864a392ac64fa9c4922cd83526d40b8 Author: pjames27 <44187608+pjames27@users.noreply.github.com> Date: Wed Apr 10 01:53:19 2024 -0700 Resolved #44 --- .../DoAfterLoginActionBeforeRender.tsx | 29 ++- .../src/components/EpilogFormContainer.tsx | 7 +- apps/react/src/components/InputDate.tsx | 5 +- apps/react/src/components/ResourceList.tsx | 25 ++- .../components/forms/ContraceptivesForm.tsx | 132 +++--------- .../components/forms/Covid19VaccineForm.tsx | 10 +- apps/react/src/consts/dataset.const.ts | 36 ++-- apps/react/src/consts/options.const.ts | 8 + apps/react/src/consts/ruleset.const.ts | 4 + .../src/epilog/form-adapters/_formAdapter.ts | 1 + .../form-adapters/contraceptivesAdapter.ts | 188 +++++++++++++++++ .../form-adapters/covid19VaccineAdapter.ts | 36 +++- apps/react/src/pages/ClaimSingle.tsx | 53 ++++- apps/react/src/pages/Dashboard.tsx | 11 +- apps/react/src/pages/Explore.tsx | 38 +++- apps/react/src/pages/Index.tsx | 7 +- apps/react/src/pages/Root.tsx | 7 +- apps/react/src/pages/WaiveCardinalCare.tsx | 189 +++++++----------- apps/react/src/types/Claim.ts | 1 + apps/react/src/utils/epilogUtils.ts | 3 + apps/server/src/utils/getOrCreateSSOUser.ts | 5 +- 21 files changed, 512 insertions(+), 283 deletions(-) create mode 100644 apps/react/src/epilog/form-adapters/contraceptivesAdapter.ts diff --git a/apps/react/src/components/DoAfterLoginActionBeforeRender.tsx b/apps/react/src/components/DoAfterLoginActionBeforeRender.tsx index b16f278..05da981 100644 --- a/apps/react/src/components/DoAfterLoginActionBeforeRender.tsx +++ b/apps/react/src/components/DoAfterLoginActionBeforeRender.tsx @@ -4,6 +4,7 @@ import { useUserDataset } from "../api/userDataset"; import useSessionUser from "../hooks/useSessionUser"; import { getAfterLoginAction, setAfterLoginAction } from "../utils/storage"; import Spinner from "./Spinner"; +import { ROUTES } from "common"; export default function DoAfterLoginActionBeforeRender({ children, @@ -28,9 +29,35 @@ export default function DoAfterLoginActionBeforeRender({ if (!userDataset) return; // TODO Handle situations in which the logged in user already has a claim with id claim0 - // Also, the person and policy in the userDataset will currently be overwritten all the time + // TODO The person and policy in the userDataset will currently be overwritten all the time // with the data that was inputted into the form when the user was not logged in. + // Get all claim ids already in dataset + + let claimIds = compfinds("C", read("claim.service_type(C, T)"), userDataset, []) as string[]; + + // If claim0 is present, change claim0 in saveToUserDataset to the first claim id not taken. + if (claimIds.includes("claim0")) { + let newClaimNum = 1; + let newClaimId = "claim" + newClaimNum; + while (claimIds.includes("claim" + newClaimNum)) { + newClaimNum++; + newClaimId = "claim" + newClaimNum; + } + + + // Update saveToUserDataset and redirectPath + actionInfo.saveToUserDataset = actionInfo.saveToUserDataset.map((fact, _) => { + return fact.map((epilogSymbol, _) => { + return epilogSymbol === "claim0" ? "claim" + newClaimNum : epilogSymbol ; + }); + }); + + actionInfo.redirectPath = ROUTES.getClaimUrl(newClaimId + "") + } + + + const mergedDataset = definemorefacts( actionInfo.saveToUserDataset, userDataset, diff --git a/apps/react/src/components/EpilogFormContainer.tsx b/apps/react/src/components/EpilogFormContainer.tsx index c43034e..4922d44 100644 --- a/apps/react/src/components/EpilogFormContainer.tsx +++ b/apps/react/src/components/EpilogFormContainer.tsx @@ -44,12 +44,15 @@ const EpilogFormContainer: React.FC = ({ > {claimId && {claimName + ":"}}

{title}

-

{isCovered === undefined ? "needs more info" : - isCovered ? "covered" : "not covered"}

+

{isCovered === undefined ? "Needs More Info" : + isCovered ? "Covered" : "Not Covered"}

+
+ Important Coverage Note: Cardinal Care only covers services received at
(a) Stanford Health Care, (b) Menlo Medical Clinic, or (c) Sutter Health +
{children} {/*{__debugFormData && }*/} diff --git a/apps/react/src/components/InputDate.tsx b/apps/react/src/components/InputDate.tsx index 60ba96d..dad4043 100644 --- a/apps/react/src/components/InputDate.tsx +++ b/apps/react/src/components/InputDate.tsx @@ -31,6 +31,7 @@ const buttonClassNames = classNames( const InputDate: React.FC = ({ options, + value, onChange, ...props }) => { @@ -53,7 +54,9 @@ const InputDate: React.FC = ({ }, }), [options]); - const [inputValue, setInputValue] = useState(""); + + + const [inputValue, setInputValue] = useState(DateTime.fromJSDate(value).toISODate()); return ( <> diff --git a/apps/react/src/components/ResourceList.tsx b/apps/react/src/components/ResourceList.tsx index 2f7dcc1..776fe8a 100644 --- a/apps/react/src/components/ResourceList.tsx +++ b/apps/react/src/components/ResourceList.tsx @@ -1,6 +1,6 @@ import { PlusCircleIcon, TrashIcon } from "@heroicons/react/24/outline"; import { format } from "date-fns"; -import { Link } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; import { ResourceListItem } from "../types/resourceListItem"; import { classNames } from "../utils/classNames"; import Container from "./Container"; @@ -76,6 +76,8 @@ function ResourceCard({ const isPersonItem = item && "dob" in item; const isClaimItem = item && "policyId" in item; // Assuming 'policyId' indicates a claim item + const navigate = useNavigate(); + // Existing functions for formatting DOB and occupation const formatDOB = (dob: any) => { // Split the dob string by "_" and rearrange it to "YYYY-MM-DD" format @@ -105,6 +107,7 @@ function ResourceCard({ color: "#555", fontSize: "0.9rem", marginTop: "0.3rem", + textAlign: "left" }; const capitalizeOccupation = (occupation: any) => @@ -122,8 +125,11 @@ function ResourceCard({ } return ( - + )} @@ -177,6 +187,7 @@ function ResourceCard({ // Fallback for items that are neither person nor claim
{label}
)} - + + ); } diff --git a/apps/react/src/components/forms/ContraceptivesForm.tsx b/apps/react/src/components/forms/ContraceptivesForm.tsx index 5793f00..61bfe11 100644 --- a/apps/react/src/components/forms/ContraceptivesForm.tsx +++ b/apps/react/src/components/forms/ContraceptivesForm.tsx @@ -6,13 +6,13 @@ import EpilogFormContainer from "../../components/EpilogFormContainer"; import InputDate from "../../components/InputDate"; import InputSelect from "../../components/InputSelect"; import InputSelectButtons from "../../components/InputSelectButtons"; -import { LOCATIONS } from "../../consts/options.const"; +import { CONTRACEPTIVE_OPTIONS, LOCATIONS } from "../../consts/options.const"; import { ConstraintContext, IsConstraintLockedRecord, createConstraintContextData, } from "../../contexts/constraintContext"; -import { Covid19Vaccine } from "../../epilog/form-adapters/_formAdapter"; +import { Contraceptives } from "../../epilog/form-adapters/_formAdapter"; import useIsCovered from "../../hooks/useIsCovered"; /* -------------------------------------------------------------------------- */ @@ -20,8 +20,6 @@ import useIsCovered from "../../hooks/useIsCovered"; /* -------------------------------------------------------------------------- */ interface IsLockedRecord extends IsConstraintLockedRecord { - dob: boolean; - vaccinationHistory: boolean; insurance: boolean; services: boolean; when: boolean; @@ -29,8 +27,8 @@ interface IsLockedRecord extends IsConstraintLockedRecord { } type Input = { - defaultValues: Covid19Vaccine.FormValues; - onClickSave: (formValues: Covid19Vaccine.FormValues) => void; + defaultValues: Contraceptives.FormValues; + onClickSave: (formValues: Contraceptives.FormValues) => void; }; /* -------------------------------------------------------------------------- */ @@ -44,7 +42,7 @@ export default function ContraceptivesForm({ /* ------------------------------- Form logic ------------------------------- */ const { control, watch, getValues, formState } = - useForm({ + useForm({ defaultValues, }); @@ -56,39 +54,12 @@ export default function ContraceptivesForm({ /* --------------------------- Constraint locking --------------------------- */ const [isLockedRecord, setIsLockedRecord] = useState({ - dob: false, - vaccinationHistory: false, insurance: false, services: false, when: false, where: false, }); - useEffect( - () => - void ( - formState.dirtyFields.dob && - setIsLockedRecord((prev) => ({ ...prev, dob: true })) - ), - [watch("dob"), formState.dirtyFields.dob], - ); - - useEffect( - () => - void ( - formState.touchedFields.vaccinationHistory_vaccineTypes && - formState.touchedFields.vaccinationHistory_date && - getValues("vaccinationHistory_vaccineType") && - setIsLockedRecord((prev) => ({ ...prev, vaccinationHistory: true })) - ), - [ - watch("vaccinationHistory_vaccineType"), - watch("vaccinationHistory_date"), - formState.touchedFields.vaccinationHistory_vaccineTypes, - formState.touchedFields.vaccinationHistory_date, - ], - ); - useEffect( () => void ( @@ -109,25 +80,6 @@ export default function ContraceptivesForm({ [isLockedRecord, setIsLockedRecord], ); - useEffect( - () => - void ( - formState.dirtyFields.dob && - setIsLockedRecord((prev) => ({ ...prev, dob: true })) - ), - [watch("dob")], - ); - - useEffect( - () => - void ( - formState.touchedFields.vaccinationHistory_vaccineTypes && - formState.touchedFields.vaccinationHistory_date && - getValues("vaccinationHistory_vaccineType") && - setIsLockedRecord((prev) => ({ ...prev, vaccinationHistory: true })) - ), - [watch("vaccinationHistory_vaccineType"), watch("vaccinationHistory_date")], - ); useEffect( () => @@ -144,20 +96,6 @@ export default function ContraceptivesForm({ [watch("policyType")], ); - useEffect( - () => - void ( - formState.touchedFields.vaccineBrand && - setIsLockedRecord((prev) => ({ - ...prev, - services: - !!getValues( - "vaccineBrand.id", - ) /* if changed to multiple again: remove !! and append .length > 0 */, - })) - ), - [watch("vaccineBrand")], - ); useEffect( () => @@ -186,10 +124,21 @@ export default function ContraceptivesForm({ /* -------------------------------- IsCovered ------------------------------- */ const formDataset = useMemo( - () => Covid19Vaccine.formAdapter.formValuesToEpilog(getValues()), + () => Contraceptives.formAdapter.formValuesToEpilog(getValues()), [JSON.stringify(watch())], ); + let allInputsEntered = useMemo( + () => { + const formValues = getValues(); + + return formValues.contraceptiveService !== null && + formValues.when !== null && + formValues.where !== null; + }, + [watch("contraceptiveService"), watch("when"), watch("where")] + ); + const isCovered = useIsCovered(defaultValues.claim.id + "", formDataset); /* -------------------------------- Rendering ------------------------------- */ @@ -198,65 +147,36 @@ export default function ContraceptivesForm({ - - ( - - )} - /> - - - ( - - )} - /> - ( - - )} - /> - - + {/* ( )} /> - - + */} + ( )} /> - + - + append( - VACCINE_OPTIONS.find((option) => option.id === "other") as BasicOption, + VACCINE_HISTORY_OPTIONS.find((option) => option.id === "other") as BasicOption, ), [onClickSave, getValues], ); @@ -265,7 +265,9 @@ export default function Covid19VaccineForm({ label="Vaccination History" onClickAddField={onClickAddVaccinationHistoryType} > -

Add the types for all your Covid-19 vaccinations here. Click the plus button on the right to add an entry.

+

Add an entry for each Covid vaccine you've received. + If you received it before September 11, 2023, indicate its type. + If it was the most recent formulation (i.e. received since September 11, 2023), indicate that instead.

{fields.map((field, index) => (
{ style={{ ...inputStyle, backgroundColor: !formData.international ? '#cccccc' : '#ffffff' }} />
-
Additional Questions For International Students @@ -310,7 +318,7 @@ const WaiveCardinalCare = () => {
$ { }} />
- - + +
$ { }} />
- - + +
{ style={{ ...inputStyle, backgroundColor: !formData.jVisaHolder ? '#cccccc' : '#ffffff' }} />
- +
$ { }} />
- - +
{ style={{ ...inputStyle, backgroundColor: !formData.visaCopy ? '#cccccc' : '#ffffff' }} />
- +
{ style={{ ...inputStyle, backgroundColor: !formData.internationalTranslated ? '#cccccc' : '#ffffff' }} />
- +
+
{ style={inputStyle} />
- +
{ style={inputStyle} />
- {/*
{ */}
{ style={{ ...inputStyle, backgroundColor: !formData.coversInpatientOutpatientMedicalSF ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.coversInpatientOutpatientMentalHealthSF ? '#cccccc' : '#ffffff' }} />
- {/*
{ */}
$ { }} />
- +
{ style={{ ...inputStyle, backgroundColor: !formData.specialEmployerPlanAnnualDeductible ? '#cccccc' : '#ffffff' }} />
- {/*
{
$ { }} />
- +
{ style={{ ...inputStyle, backgroundColor: !formData.specialEmployerPlanAnnualOutOfPocketMaximum ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.providesEMBPPACA ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.covers100PercentPreventiveCarePPACA ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.exclusionsForPreExistingConditions ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.offersPrescriptionDrugCoverage ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.coverageForNonEmergencyAndEmergencyCare ? '#cccccc' : '#ffffff' }} />
-
{ style={{ ...inputStyle, backgroundColor: !formData.lifetimeAggregateMaxBenefit ? '#cccccc' : '#ffffff' }} />
-
); diff --git a/apps/react/src/types/Claim.ts b/apps/react/src/types/Claim.ts index d9f4d00..dabe385 100644 --- a/apps/react/src/types/Claim.ts +++ b/apps/react/src/types/Claim.ts @@ -1,6 +1,7 @@ export interface Claim { id: string; policyId: string; + serviceType: string; claimantId: string; time: string; hospitalStart: string; diff --git a/apps/react/src/utils/epilogUtils.ts b/apps/react/src/utils/epilogUtils.ts index 44e99e9..c4fe9f5 100644 --- a/apps/react/src/utils/epilogUtils.ts +++ b/apps/react/src/utils/epilogUtils.ts @@ -122,6 +122,9 @@ export const getClaimDetailsById = (claimId: string, dataset: ReturnType Date: Thu, 25 Apr 2024 02:10:08 -0700 Subject: [PATCH 3/9] fixed date picker so that the styling doesn't look awkward on the dropdwon --- apps/react/src/.DS_Store | Bin 0 -> 6148 bytes apps/react/src/components/InputDate.tsx | 114 +++++++----------------- apps/server/var/sessions.db | Bin 12288 -> 12288 bytes 3 files changed, 33 insertions(+), 81 deletions(-) create mode 100644 apps/react/src/.DS_Store diff --git a/apps/react/src/.DS_Store b/apps/react/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..01568566c0035d62b34ce753624afe4a0c183306 GIT binary patch literal 6148 zcmeHK%}T>S5Z<+|O({YS3Oz1(Em+%X5icRu7cim+m735}gE3p0)Er77XMG``#OHBl zcLOa3k0N#kcE8#A+0A^A{b7u8cQHO@%w~*P&=5H)C4%Ns*NzEBdKD)`RyXGcWbiMdJGNI~-k083l#z z2RGp)8`=98GEV(4p3GH3IG#Yr{cRYJW#-C7JWf=uryW+qYK-jGa@if6v_)^wU$w>Z ztlMdee(!X(YFGz{N9R|g=jbJtZ<@PKfg z3aC@Ld17##4t8PU9D}(=ozA#g8Rju77mpXNRtLLK;fy;PsV4@AflUS~dT8VMe+j=# z=_7wLg+{~xG4RhA;MJiwbfGA7wtg!Q&sqWP5gH1{<*0ywzHteF0q!F$<b2! WbB#C)+EqFrT?7;%)DZ)}z`z$^@k-wS literal 0 HcmV?d00001 diff --git a/apps/react/src/components/InputDate.tsx b/apps/react/src/components/InputDate.tsx index dad4043..62cc907 100644 --- a/apps/react/src/components/InputDate.tsx +++ b/apps/react/src/components/InputDate.tsx @@ -14,102 +14,54 @@ import { stringToDate } from "../utils/epilogUtils"; /* Types */ /* -------------------------------------------------------------------------- */ -type InputDate_Input = Omit< - React.ComponentProps, - "show" | "setShow" -> & { onBlur?: () => void }; +type InputDateProps = { + value: string; // ISO date string "YYYY-MM-DD" + onChange: (newDate: Date) => void; + onBlur?: () => void; + }; /* -------------------------------------------------------------------------- */ /* Functions */ /* -------------------------------------------------------------------------- */ -// We have to override the stuff that comes from Datepicker -const buttonClassNames = classNames( - getButtonClassNames("gray"), - "rounded-none", -); - const InputDate: React.FC = ({ - options, value, onChange, + onBlur, ...props }) => { const inputContext = useContext(InputContext); + const [inputValue, setInputValue] = useState(value); const [show, setShow] = useState(false); const datePickerWrapperRef = useRef(null); - const onChangeCallback = useCallback((date) => { - const dateString = DateTime.fromJSDate(date).toISODate(); - setInputValue(dateString); - onChange?.(date); - // Keep the calendar open even after selecting a date - }, [onChange]); - - const opts = useMemo(() => ({ - ...options, - theme: { - selected: "bg-blue-500 hover:bg-blue-700 text-white", - }, - }), [options]); - - - - const [inputValue, setInputValue] = useState(DateTime.fromJSDate(value).toISODate()); + const handleChange = useCallback((e) => { + const newDateValue = e.target.value; // "YYYY-MM-DD" format + setInputValue(newDateValue); + if (newDateValue.match(/^\d{4}-\d{2}-\d{2}$/)) { + onChange(stringToDate(newDateValue.replace(/-/g, "_"))); // Convert to "DD_MM_YYYY" format if needed + } + }, [onChange]); - return ( - <> -
- - { - setInputValue(e.target.value); - }} - onBlur={(e) => { - // Check whether in correct format - const pattern: RegExp = /^\d{4}-\d{2}-\d{2}$/; - if (!pattern.test(inputValue)) { - return; - } - // Check whether it's a valid date - if (Number.isNaN(Date.parse(inputValue))) { - return; - } - const [year, month, day] = inputValue.split("-"); - onChangeCallback(stringToDate(`${day}_${month}_${year}`)); - }} - className={COMMON_INPUT_CLASSES + " w-full"} - placeholder="YYYY-MM-DD" - /> - {show && ( -
- - -
- )} -
- - ); - }; - - export default InputDate; \ No newline at end of file + return ( + + ); + }; + + export default InputDate; \ No newline at end of file diff --git a/apps/server/var/sessions.db b/apps/server/var/sessions.db index 66916525bce5ccaf9343c8eacd3dc75065150433..aa9c9916c435b855e3efaa4f5c4a12fc0978c258 100644 GIT binary patch delta 184 zcmZojXh@hK%~&^4#+k8hW5Pmyeg*~xMt(L1el}haUJ)LVjfE^cn?+=PF>(OKKl!pZ z%TL~=uQ1t6?t*?}ITI^TKrz7FuTfPYC^t91BD~1B!ouCDFeTR~yUeNL xn*TXCC#|2F?b5Zo-N5Y0b1Ti=@nDB%S(UX`GcOaRj?HlF|h delta 235 zcmZojXh@hK%~&;2#+k8dW5PmyetvcaW?m6yK0f|dUJ)LVjfE^cn?+=PF>*APv9S8G zH_K1nrLQpAOzwhyEdv8XHG89KvP)@FYNe@@w`sP!VW@AQNpg;EUQuvU!oH=aj`e6}Wm>`o^1>8@Q!AWmP667gt%h zd6hX;yg8D_KG{ajSFn}~XcaU6Ls1VIRIa}YGMTOay5$GaSMMB20 F0su^KMUemi From 38e21441a05a89eb1b869b7ce9bd62833d83ba3e Mon Sep 17 00:00:00 2001 From: alissav <63168432+alissav30@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:10:43 -0700 Subject: [PATCH 4/9] another styling fix on the date picker --- apps/react/src/components/InputDate.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/react/src/components/InputDate.tsx b/apps/react/src/components/InputDate.tsx index 62cc907..985caea 100644 --- a/apps/react/src/components/InputDate.tsx +++ b/apps/react/src/components/InputDate.tsx @@ -56,7 +56,7 @@ const InputDate: React.FC = ({ value={inputValue} onChange={handleChange} onBlur={onBlur} - className={COMMON_INPUT_CLASSES + " pl-4 pr-2 py-2 border rounded"} + className={COMMON_INPUT_CLASSES + " pl-3 pr-2 py-2 border rounded"} style={{ display: 'block', width: '100%', fontSize: '16px', lineHeight: '20px' }} />
From 2c75b28a8f4b78f4cae82beb35b3f2a24541c65e Mon Sep 17 00:00:00 2001 From: alissav <63168432+alissav30@users.noreply.github.com> Date: Mon, 6 May 2024 14:33:13 -0700 Subject: [PATCH 5/9] generalizing take 1 --- apps/react/src/components/InputDate.tsx | 2 - .../src/components/InputSelectButtons.tsx | 69 +- .../components/forms/GeneralPolicyForm.tsx | 137 + apps/react/src/consts/options.const.ts | 16 + .../form-adapters/contraceptivesAdapter.ts | 17 + .../src/epilog/form-adapters/formConfigs.ts | 103 + .../form-adapters/generalFormAdapter.ts | 156 + apps/react/src/epilog/plain-js/epilog.js | 2994 ++++++++++++++--- apps/react/src/pages/Explore.tsx | 213 +- apps/react/src/pages/Explore_old.tsx | 159 + apps/server/var/sessions.db | Bin 12288 -> 12288 bytes apps/server/var/sqlite.db | Bin 73728 -> 102400 bytes 12 files changed, 3243 insertions(+), 623 deletions(-) create mode 100644 apps/react/src/components/forms/GeneralPolicyForm.tsx create mode 100644 apps/react/src/epilog/form-adapters/formConfigs.ts create mode 100644 apps/react/src/epilog/form-adapters/generalFormAdapter.ts create mode 100644 apps/react/src/pages/Explore_old.tsx diff --git a/apps/react/src/components/InputDate.tsx b/apps/react/src/components/InputDate.tsx index 985caea..6881660 100644 --- a/apps/react/src/components/InputDate.tsx +++ b/apps/react/src/components/InputDate.tsx @@ -5,7 +5,6 @@ import { classNames } from "../utils/classNames"; import { COMMON_INPUT_CLASSES } from "../consts/classes.const"; import { InputContext } from "../contexts/inputContext.ts"; import { DateTime } from "luxon"; -import { FaRegCalendarAlt } from 'react-icons/fa'; import { stringToDate } from "../utils/epilogUtils"; // https://github.com/OMikkel/tailwind-datepicker-react @@ -48,7 +47,6 @@ const InputDate: React.FC = ({ return (