From a1486a563bfba9c4fda962e4c36ba33fe88d4289 Mon Sep 17 00:00:00 2001 From: Mohamed amaan Date: Fri, 10 Jan 2025 07:10:51 +0530 Subject: [PATCH 1/6] DOB input auto switch added --- .../Patient/PatientRegistration.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 94289124403..54e745c5047 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -498,12 +498,15 @@ export default function PatientRegistration( maxLength={2} max={31} min={1} - onChange={(e) => + onChange={(e) => { setForm((f) => ({ ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, - })) - } + })); + if (e.target.value.length === 2) { + document.getElementById("month-input")?.focus(); + } + }} />
@@ -512,18 +515,22 @@ export default function PatientRegistration( * + onChange={(e) => { setForm((f) => ({ ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${e.target.value}-${form.date_of_birth?.split("-")[2] || ""}`, - })) - } + })); + if (e.target.value.length === 2) { + document.getElementById("year-input")?.focus(); + } + }} />
@@ -532,6 +539,7 @@ export default function PatientRegistration( * Date: Fri, 10 Jan 2025 20:11:55 +0530 Subject: [PATCH 2/6] coderabbitai suggestion added --- src/components/Patient/PatientRegistration.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 54e745c5047..5d3d594faa0 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -503,7 +503,12 @@ export default function PatientRegistration( ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, })); - if (e.target.value.length === 2) { + const day = parseInt(e.target.value); + if ( + e.target.value.length === 2 && + day >= 1 && + day <= 31 + ) { document.getElementById("month-input")?.focus(); } }} @@ -527,7 +532,12 @@ export default function PatientRegistration( ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${e.target.value}-${form.date_of_birth?.split("-")[2] || ""}`, })); - if (e.target.value.length === 2) { + const month = parseInt(e.target.value); + if ( + e.target.value.length === 2 && + month >= 1 && + month <= 12 + ) { document.getElementById("year-input")?.focus(); } }} From eed2171c644eabe10e6c0b74e9550cdd08d2c289 Mon Sep 17 00:00:00 2001 From: Mohamed amaan Date: Fri, 10 Jan 2025 21:19:16 +0530 Subject: [PATCH 3/6] checking cypress test issue --- src/components/Patient/PatientRegistration.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 0453cb181de..2dcccfb5dda 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -493,6 +493,7 @@ export default function PatientRegistration( ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, })); + // checking cypress issue const day = parseInt(e.target.value); if ( e.target.value.length === 2 && From d4bb3979dccdeb485df96019dbfd86afbda00ebe Mon Sep 17 00:00:00 2001 From: Mohamed amaan Date: Fri, 10 Jan 2025 21:44:29 +0530 Subject: [PATCH 4/6] command removed --- src/components/Patient/PatientRegistration.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 2dcccfb5dda..0453cb181de 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -493,7 +493,6 @@ export default function PatientRegistration( ...f, date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`, })); - // checking cypress issue const day = parseInt(e.target.value); if ( e.target.value.length === 2 && From 525fafe2f267d23790c775fb21ed9858eef486be Mon Sep 17 00:00:00 2001 From: Mohamed amaan Date: Fri, 10 Jan 2025 22:57:37 +0530 Subject: [PATCH 5/6] try to resolving cypress issue --- cypress/support/commands.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index c8c0dbbd3d8..c557d1d8b47 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -177,11 +177,20 @@ Cypress.Commands.add("clickAndTypeDate", (selector, date) => { cy.get("body").click(0, 0); }); +// Cypress.Commands.add( +// "verifyAndClickElement", +// (element: string, reference: string) => { +// cy.get(element).scrollIntoView(); +// cy.get(element).contains(reference).should("be.visible").click(); +// }, +// ); + Cypress.Commands.add( "verifyAndClickElement", (element: string, reference: string) => { - cy.get(element).scrollIntoView(); - cy.get(element).contains(reference).should("be.visible").click(); + cy.get(element).scrollIntoView().as("container"); + cy.get("@container").contains(reference).as("target"); + cy.get("@target").should("be.visible").click(); }, ); From f742561f9c5dd8230e957d523ac3c2ef7d4d9fb1 Mon Sep 17 00:00:00 2001 From: Mohamed amaan Date: Fri, 10 Jan 2025 23:04:08 +0530 Subject: [PATCH 6/6] cypress code change revoked --- cypress/support/commands.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index c557d1d8b47..c8c0dbbd3d8 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -177,20 +177,11 @@ Cypress.Commands.add("clickAndTypeDate", (selector, date) => { cy.get("body").click(0, 0); }); -// Cypress.Commands.add( -// "verifyAndClickElement", -// (element: string, reference: string) => { -// cy.get(element).scrollIntoView(); -// cy.get(element).contains(reference).should("be.visible").click(); -// }, -// ); - Cypress.Commands.add( "verifyAndClickElement", (element: string, reference: string) => { - cy.get(element).scrollIntoView().as("container"); - cy.get("@container").contains(reference).as("target"); - cy.get("@target").should("be.visible").click(); + cy.get(element).scrollIntoView(); + cy.get(element).contains(reference).should("be.visible").click(); }, );