diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 3a67eee5614..7c160ce029b 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -11,6 +11,7 @@ on: jobs: cypress-run: + permissions: write-all if: github.repository == 'coronasafe/care_fe' runs-on: ubuntu-latest steps: @@ -58,6 +59,20 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_OPTIONS: --max_old_space_size=4096 + - name: Remove cypress passed label on failure ๐Ÿท๏ธ + uses: actions-ecosystem/action-remove-labels@v1 + if: failure() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: cypress passed + + - name: Add cypress passed label on success ๐Ÿท๏ธ + uses: actions-ecosystem/action-add-labels@v1 + if: success() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: cypress passed + - name: Remove cypress failed label on success ๐Ÿท๏ธ uses: actions-ecosystem/action-remove-labels@v1 if: success() diff --git a/cypress/e2e/assets_spec/assets.cy.ts b/cypress/e2e/assets_spec/assets.cy.ts index 3dbedeb2098..e49104b34dc 100644 --- a/cypress/e2e/assets_spec/assets.cy.ts +++ b/cypress/e2e/assets_spec/assets.cy.ts @@ -1,8 +1,12 @@ /// import { cy, describe, before, beforeEach, it } from "local-cypress"; +import { v4 as uuidv4 } from "uuid"; -describe("Assets List", () => { +const phone_number = "9999999999"; +const serial_no = parseInt((Math.random() * 10 ** 10).toString()); + +describe("Asset", () => { before(() => { cy.loginByApi("devdistrictadmin", "Coronasafe@123"); cy.saveLocalStorage(); @@ -13,6 +17,64 @@ describe("Assets List", () => { cy.awaitUrl("/assets"); }); + it("Create an Asset", () => { + cy.get("button").should("contain", "Create Asset"); + cy.get("[data-testid=create-asset-buttom] button").click(); + cy.get("input[name='facilities']") + .type("Dummy Facility 1") + .then(() => { + cy.get("[role='option']").contains("Dummy Facility 1").click(); + }); + cy.get("button").should("contain", "Select"); + cy.get("button").get("#submit").click(); + cy.get("[data-testid=asset-name-input] input").type("New Test Asset"); + cy.get("[data-testid=asset-location-input] input") + .type("Camera Locat") + .then(() => { + cy.get("[role='option']").contains("Camera Locations").click(); + }); + cy.get("[data-testid=asset-type-input] button") + .click() + .then(() => { + cy.get("[role='option']").contains("Internal").click(); + }); + cy.get("[data-testid=asset-class-input] button") + .click() + .then(() => { + cy.get("[role='option']").contains("ONVIF Camera").click(); + }); + cy.get("[data-testid=asset-description-input] textarea").type( + "Test Description" + ); + cy.get("[data-testid=asset-working-status-input] li") + .contains("Working") + .click(); + const qr_id = uuidv4(); + cy.get("[data-testid=asset-qr-id-input] input").type(qr_id); + cy.get("[data-testid=asset-manufacturer-input] input").type( + "Manufacturer's Name" + ); + cy.get("[data-testid=asset-warranty-input] input").type("2025-12-25"); + cy.get("[data-testid=asset-support-name-input] input").type( + "Customer Support's Name" + ); + cy.get("#customer-support-phone-div").type(phone_number); + cy.get("[data-testid=asset-support-email-input] input").type( + "email@support.com" + ); + cy.get("[data-testid=asset-vendor-name-input] input").type("Vendor's Name"); + cy.get("[data-testid=asset-serial-number-input] input").type(serial_no); + cy.get("[data-testid=asset-last-serviced-on-input] input").type( + "2021-12-25" + ); + cy.get("[data-testid=asset-notes-input] textarea").type( + "Test note for asset creation!" + ); + cy.wait(500); + cy.get("#submit").contains("Create Asset").click(); + cy.verifyNotification("Asset created successfully"); + }); + it("Search Asset Name", () => { const initialUrl = cy.url(); cy.get("[name='search']").type("dummy camera 30"); @@ -30,13 +92,9 @@ describe("Assets List", () => { it("Next/Previous Page", () => { // only works for desktop mode - cy.get("button") - .should("contain", "Next") - .contains("Next") - .click({ force: true }); - cy.get("button") - .should("contain", "Previous") - .contains("Previous") - .click({ force: true }); + cy.get("button#next-pages").click(); + cy.url().should("include", "page=2"); + cy.get("button#prev-pages").click(); + cy.url().should("include", "page=1"); }); }); diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index 830ad77d4aa..22d46060049 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -30,11 +30,11 @@ describe("Edit Profile Testing", () => { it("Search by phone number", () => { cy.intercept(/\/api\/v1\/external_result/).as("external_result"); - cy.get("[placeholder='Search by Phone Number']").type("4738743424"); + cy.get("[placeholder='Search by Phone Number']").type("7387434255"); cy.wait("@external_result").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.url().should("include", "%2B914738743424"); + cy.url().should("include", "%2B91+73874+34255"); }); it("import", () => { diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts index eead81442e6..b03c17245b4 100644 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ b/cypress/e2e/facility_spec/facility.cy.ts @@ -13,7 +13,7 @@ class facility { } static update(facility) { - cy.get("[id=manage-facility-dropdown]").should("exist").click(); + cy.get("[id=manage-facility-dropdown]").click(); cy.get("[id=update-facility]").click(); cy.url().should("include", "update"); this.fillForm({ @@ -73,7 +73,7 @@ class facility { cy.get("input[id=pincode]").should("exist").clear().type(pincode); - cy.get("input[name=phone_number]").should("exist").type(phone); + cy.get("input[name=phone_number]").should("exist").clear().type(phone); cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity); cy.get("input[id=expected_oxygen_requirement]") @@ -138,7 +138,7 @@ describe("Facility", () => { ward: "MANAKKAPADY", address: "some address", pincode: "884656", - phone: "9985784535", + phone: "+919985784535", oxygen_capacity: "20", oxygen_requirement: "30", type_b_cylinders: "20", @@ -185,7 +185,7 @@ describe("Facility", () => { ward: "PAZHAMTHOTTAM", address: " update", pincode: "584675", - phone: "9985784535", + phone: "+919985784535", oxygen_capacity: "30", oxygen_requirement: "40", type_b_cylinders: "23", diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 55d2705490c..c2ce7497154 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -36,7 +36,7 @@ describe("Patient Creation with consultation", () => { cy.get("#phone_number-div").type(phone_number); cy.get("#emergency_phone_number-div").type(emergency_phone_number); cy.get("[data-testid=date-of-birth] button").click(); - cy.get("div").contains("1").click(); + cy.get("#date-1").click(); cy.get("[data-testid=name] input").type("Test E2E User"); cy.get("[data-testid=Gender] button") .click() @@ -64,7 +64,8 @@ describe("Patient Creation with consultation", () => { .then(() => { cy.get("[role='option']").contains("O+").click(); }); - cy.get("button").get("[data-testid=submit-button]").click(); + cy.get("button[data-testid='submit-button']").click(); + cy.get("h2").should("contain", "Create Consultation"); cy.url().should("include", "/patient"); cy.url().then((url) => { @@ -94,7 +95,27 @@ describe("Patient Creation with consultation", () => { it("Edit the patient details", () => { cy.awaitUrl(patient_url + "/update"); - cy.get("[data-testid=name] input").clear().type("Test E2E User Editted"); + cy.get("[data-testid=name] input").clear().type("Test E2E User Edited"); + cy.get("#emergency_phone_number-div") + .clear() + .then(() => { + cy.get("#emergency_phone_number__country").select("IN"); + }); + cy.get("#emergency_phone_number-div").type("9120330220"); + cy.get("#address").clear().type("Test Patient Address Edited"); + cy.get("#present_health").type("Severe Cough"); + cy.get("#ongoing_medication").type("Paracetamol"); + cy.get("#allergies").type("Dust"); + cy.get("[name=medical_history_check_1]").uncheck(); + cy.get("[name=medical_history_check_2]").check(); + cy.get("#medical_history_2").type("2 months ago"); + cy.get("[name=medical_history_check_3]").check(); + cy.get("#medical_history_3").type("1 month ago"); + cy.get("button").get("[data-testid=add-insurance-button]").click(); + cy.get("#subscriber_id").type("SUB123"); + cy.get("#policy_id").type("P123"); + cy.get("#insurer_id").type("GICOFINDIA"); + cy.get("#insurer_name").type("GICOFINDIA"); cy.get("button").get("[data-testid=submit-button]").click(); cy.url().should("include", "/patient"); cy.url().then((url) => { @@ -104,6 +125,34 @@ describe("Patient Creation with consultation", () => { }); }); + it("Patient Detail verification post edit", () => { + cy.log(patient_url); + cy.awaitUrl(patient_url); + cy.url().should("include", "/facility/"); + cy.get("[data-testid=patient-dashboard]").should( + "contain", + "Test E2E User Edited" + ); + cy.get("[data-testid=patient-dashboard]").should( + "contain", + "+919120330220" + ); + const patientDetails_values: string[] = [ + "Test Patient Address Edited", + "Severe Cough", + "Paracetamol", + "Dust", + "Diabetes", + "2 months ago", + "Heart Disease", + "1 month ago", + ]; + + patientDetails_values.forEach((value) => { + cy.get("[data-testid=patient-details]").should("contain", value); + }); + }); + it("Create a New consultation to existing patient", () => { cy.visit(patient_url + "/consultation"); cy.get("#consultation_status") @@ -156,6 +205,7 @@ describe("Patient Creation with consultation", () => { cy.get("button#submit").should("be.visible").click(); cy.get("[data-testid='return-to-patient-dashboard']").click(); }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/resource_spec/filter.cy.ts b/cypress/e2e/resource_spec/filter.cy.ts index f977dfbfa8f..88fc5d172b9 100644 --- a/cypress/e2e/resource_spec/filter.cy.ts +++ b/cypress/e2e/resource_spec/filter.cy.ts @@ -63,16 +63,42 @@ describe("Resource filter", () => { it("filter by created date", () => { cy.intercept(/\/api\/v1\/resource/).as("resource_filter"); - cy.get("[name='created_date_after']").type("22/05/2020"); - cy.get("[name='created_date_before']").type("09/09/2021"); + cy.get("[name='created_date_after']").click(); + cy.get( + "[role='button'][aria-label='Move backward to switch to the previous month.']" + ).click(); + cy.get("td[tabindex='-1']") + .first() + .then(($td) => { + $td[0].click(); + + cy.get("td[tabindex='-1']") + .eq(14) + .then(($td2) => { + $td2[0].click(); + }); + }); cy.contains("Apply").click(); cy.wait("@resource_filter"); }); it("filter by modified date", () => { cy.intercept(/\/api\/v1\/resource/).as("resource_filter"); - cy.get("[name='modified_date_after']").type("22/05/2020"); - cy.get("[name='modified_date_before']").type("09/09/2021"); + cy.get("[name='modified_date_after']").click(); + cy.get( + "[role='button'][aria-label='Move backward to switch to the previous month.']" + ).click(); + cy.get("td[tabindex='-1']") + .first() + .then(($td) => { + $td[0].click(); + + cy.get("td[tabindex='-1']") + .eq(14) + .then(($td2) => { + $td2[0].click(); + }); + }); cy.contains("Apply").click(); cy.wait("@resource_filter"); }); diff --git a/cypress/e2e/resource_spec/resources.cy.ts b/cypress/e2e/resource_spec/resources.cy.ts index 5a9287964b1..099e782277a 100644 --- a/cypress/e2e/resource_spec/resources.cy.ts +++ b/cypress/e2e/resource_spec/resources.cy.ts @@ -27,15 +27,15 @@ describe("Resource Page", () => { cy.wait("@resource").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.contains("Active").should("have.class", "bg-gray-200"); - cy.contains("Completed").should("have.class", "bg-white"); + cy.contains("Active").should("have.class", "text-primary-500"); + cy.contains("Completed").should("have.class", "text-white"); cy.intercept(/\/api\/v1\/resource/).as("resource"); cy.contains("Active").click(); cy.wait("@resource").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.contains("Active").should("have.class", "bg-white"); - cy.contains("Completed").should("have.class", "bg-gray-200"); + cy.contains("Active").should("have.class", "text-white"); + cy.contains("Completed").should("have.class", "text-primary-500"); }); it("switch between list view and board view", () => { diff --git a/cypress/e2e/sample_test_spec/filter.cy.ts b/cypress/e2e/sample_test_spec/filter.cy.ts index 23bf48e8fd8..8fe8fa50b81 100644 --- a/cypress/e2e/sample_test_spec/filter.cy.ts +++ b/cypress/e2e/sample_test_spec/filter.cy.ts @@ -13,15 +13,24 @@ describe("Sample Filter", () => { }); it("Filter by Status", () => { - cy.get("[name='status']").select("APPROVED"); + cy.get("#status").click(); + cy.get("li[role='option']") + .contains(/^APPROVED$/) + .click(); }); it("Filter by Asset Type", () => { - cy.get("[name='result']").select("POSITIVE"); + cy.get("#result").click(); + cy.get("li[role='option']") + .contains(/^POSITIVE$/) + .click(); }); it("Filter by sample type", () => { - cy.get("[name='sample_type']").select("Biopsy"); + cy.get("#sample_type").click(); + cy.get("li[role='option']") + .contains(/^Biopsy$/) + .click(); }); afterEach(() => { diff --git a/cypress/e2e/shifting_spec/filter.cy.ts b/cypress/e2e/shifting_spec/filter.cy.ts index 2429648946c..3e755db5c66 100644 --- a/cypress/e2e/shifting_spec/filter.cy.ts +++ b/cypress/e2e/shifting_spec/filter.cy.ts @@ -32,8 +32,11 @@ describe("Shifting section filter", () => { it("filter by assigned to user", () => { cy.intercept(/\/api\/v1\/users/).as("users_filter"); - cy.get("[name='assigned_to']").type("cypress").wait("@users_filter"); - cy.get("[name='assigned_to']").type("{downarrow}{enter}"); + cy.get("[id='assigned_to']") + .wait(100) + .type("cypress") + .wait("@users_filter"); + cy.get("[id='assigned_to']").wait(100).type("{downarrow}{enter}"); cy.contains("Apply").click(); }); diff --git a/cypress/e2e/shifting_spec/shifting.cy.ts b/cypress/e2e/shifting_spec/shifting.cy.ts index e32b701bee8..bc78e55f175 100644 --- a/cypress/e2e/shifting_spec/shifting.cy.ts +++ b/cypress/e2e/shifting_spec/shifting.cy.ts @@ -32,12 +32,12 @@ describe("Shifting Page", () => { it("switch between active/archived", () => { cy.intercept(/\/api\/v1\/shift/).as("shifting"); cy.contains("Archived").click().wait("@shifting"); - cy.contains("Active").should("have.class", "bg-gray-200"); - cy.contains("Archived").should("have.class", "bg-white"); + cy.contains("Active").should("have.class", "text-primary-500"); + cy.contains("Archived").should("have.class", "text-white"); cy.intercept(/\/api\/v1\/shift/).as("shifting"); cy.contains("Active").click().wait("@shifting"); - cy.contains("Active").should("have.class", "bg-white"); - cy.contains("Archived").should("have.class", "bg-gray-200"); + cy.contains("Active").should("have.class", "text-white"); + cy.contains("Archived").should("have.class", "text-primary-500"); }); afterEach(() => { diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index 405f5a07a41..e950e98e1c8 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -10,12 +10,9 @@ const makeid = (length: number) => { return result; }; -const makePhoneNumber = () => - "9199" + Math.floor(Math.random() * 99999999).toString(); - const username = makeid(25); -const phone_number = makePhoneNumber(); -const alt_phone_number = makePhoneNumber(); +const phone_number = 9999999999; +const alt_phone_number = 9999999999; describe("User management", () => { before(() => { @@ -39,22 +36,20 @@ describe("User management", () => { cy.get("[id='local_body'] > div > button").click(); cy.get("div").contains("Aikaranad").click(); cy.intercept(/\/api\/v1\/facility/).as("facility"); - cy.get("[name='facilities']").type("cypress facility").wait("@facility"); - cy.get("[name='facilities']").type("{enter}"); - cy.wait(1000); + cy.get("[name='facilities']") + .click() + .type("cypress facility") + .wait("@facility"); + cy.get("li[role='option']").contains("cypress facility").click(); cy.get("input[type='checkbox']").click(); - cy.wait(1000); - cy.get("[placeholder='Phone Number']").type(phone_number); - cy.wait(1000); - cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number, { - force: true, - }); + cy.get("[name='phone_number']").type(phone_number); + cy.get("[name='alt_phone_number']").type(alt_phone_number); cy.intercept(/users/).as("check_availability"); cy.get("[id='date_of_birth']").click(); cy.get("div").contains("20").click(); cy.get("[id='year-0']").click(); cy.get("[id='date-1']").click(); - cy.get("[name='username']").type(username, { force: true }); + cy.get("[name='username']").type(username); cy.wait("@check_availability").its("response.statusCode").should("eq", 200); cy.get("[name='password']").type("#@Cypress_test123"); cy.get("[name='c_password']").type("#@Cypress_test123"); @@ -63,9 +58,7 @@ describe("User management", () => { cy.get("[name='email']").type("cypress@tester.com"); cy.get("[id='gender'] > div > button").click(); cy.get("div").contains("Male").click(); - cy.get("button[id='submit']").contains("Save User").click({ - force: true, - }); + cy.get("button[id='submit']").contains("Save User").click(); cy.verifyNotification("User added successfully"); }); @@ -73,20 +66,21 @@ describe("User management", () => { cy.contains("Advanced Filters").click(); cy.get("[name='first_name']").type("Cypress Test"); cy.get("[name='last_name']").type("Tester"); - cy.get("[id='role'] > div > button").click(); - cy.get("div") - .contains(/^Ward Admin$/) + cy.get("#role button").click(); + cy.contains("#role li", "Ward Admin").click(); + cy.get("input[name='district']").click(); + cy.get("input[name='district']").type("Ernakulam"); + cy.get("li[id^='headlessui-combobox-option']") + .contains("Ernakulam") .click(); - cy.get("input[name='district']").type("Ernakulam").wait(1000); - cy.get("input[name='district']").type("{downarrow}{enter}"); + cy.get("[placeholder='Phone Number']").click(); cy.get("[placeholder='Phone Number']").type(phone_number); cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number); cy.contains("Apply").click(); cy.intercept(/\/api\/v1\/users/).as("getUsers"); cy.wait(1000); - cy.get("[name='username']").type(username, { force: true }); + cy.get("[name='username']").type(username); cy.wait("@getUsers"); - cy.wait(1000); cy.get("dd[id='count']").contains(/^1$/).click(); cy.get("div[id='usr_0']").within(() => { cy.intercept(`/api/v1/users/${username}/get_facilities/`).as( @@ -106,12 +100,15 @@ describe("User management", () => { }); it("link facility for user", () => { - cy.contains("Linked Facilities").click({ force: true }); + cy.contains("Linked Facilities").click(); cy.intercept(/\/api\/v1\/facility/).as("getFacilities"); - cy.get("[name='facility']").type("cypress facility").wait("@getFacilities"); - cy.get("[name='facility']").type("{downarrow}{enter}"); + cy.get("[name='facility']") + .click() + .type("cypress facility") + .wait("@getFacilities"); + cy.get("li[role='option']").contains("cypress facility").click(); cy.intercept(/\/api\/v1\/users\/\w+\/add_facility\//).as("addFacility"); - cy.get("button > span").contains("Add").click({ force: true }); + cy.get("button > span").contains("Add").click(); cy.wait("@addFacility") // .its("response.statusCode") // .should("eq", 201) @@ -121,14 +118,10 @@ describe("User management", () => { it("Next/Previous Page", () => { // only works for desktop mode - cy.get("button") - .should("contain", "Next") - .contains("Next") - .click({ force: true }); - cy.get("button") - .should("contain", "Previous") - .contains("Previous") - .click({ force: true }); + cy.get("button#next-pages").click(); + cy.url().should("include", "page=2"); + cy.get("button#prev-pages").click(); + cy.url().should("include", "page=1"); }); afterEach(() => { @@ -136,10 +129,7 @@ describe("User management", () => { }); }); -const backspace = - "{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}"; - -describe("Edit Profile Testing", () => { +describe("Edit User Profile & Error Validation", () => { before(() => { cy.loginByApi(username, "#@Cypress_test123"); cy.saveLocalStorage(); @@ -148,107 +138,56 @@ describe("Edit Profile Testing", () => { beforeEach(() => { cy.restoreLocalStorage(); cy.awaitUrl("/user/profile"); - cy.contains("Edit User Profile").click({ force: true }); + cy.contains("button", "Edit User Profile").click(); }); - it("Empty First-Name field of " + username, () => { - cy.get("input[name=firstName]").clear().trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.get(".error-text").contains("Field is required"); + it("First name Field Updation " + username, () => { + cy.get("input[name=firstName]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "Field is required"); + cy.get("input[name=firstName]").type("firstName updated"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid First-Name field of " + username, () => { - cy.get("input[name=firstName]") - .clear() - .type("User 1") - .trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt").contains("First Name").siblings().first().contains("User 1"); + it("Last name Field Updation " + username, () => { + cy.get("input[name=lastName]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "Field is required"); + cy.get("input[name=lastName]").type("lastName updated"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Empty Last-Name field of " + username, () => { - cy.get("input[name=lastName]").clear().trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.get(".error-text").contains("Field is required"); + it("Age Field Updation " + username, () => { + cy.get("input[name=age]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "This field is required"); + cy.get("input[name=age]").type("11"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid Last-Name field of " + username, () => { - cy.get("input[name=lastName]") - .clear() - .type("User 1") - .trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt").contains("Last Name").siblings().first().contains("User 1"); + it("Phone number Field Updation " + username, () => { + cy.get("input[name=phoneNumber]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should( + "contain", + "Please enter valid phone number" + ); + cy.get("input[name=phoneNumber]").type("+919999999999"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Invalid Whatsapp Number of " + username, () => { - const whatsapp_num = "11111-11111"; - cy.get("[placeholder='WhatsApp Number']") - .focus() - .type(`${backspace}${whatsapp_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${whatsapp_num}`); - cy.wait(1000); - cy.get("form") - .get("button[type='submit']") - .contains("Update") - .click() - .then(() => { - cy.get(".error-text").contains("Please enter valid mobile number"); - }); + it("Whatsapp number Field Updation " + username, () => { + cy.get("input[name=altPhoneNumber]").clear(); + cy.get("input[name=altPhoneNumber]").type("+919999999999"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid Whatsapp Number of " + username, () => { - const whatsapp_num = "91111-11111"; - cy.get("[placeholder='WhatsApp Number']") - .focus() - .type(`${backspace}${whatsapp_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${whatsapp_num}`); - cy.wait(1000); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt") - .contains("Whatsapp No") - .siblings() - .first() - .contains(`+91 ${whatsapp_num}`.replace(/[ -]/g, "")); - }); - - it("Invalid Phone Number of " + username, () => { - const phone_num = "11111-11111"; - cy.get("[placeholder='Phone Number']") - .focus() - .type(`${backspace}${phone_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${phone_num}`); - cy.wait(1000); - cy.get("form") - .get("button[type='submit']") - .contains("Update") - .click() - .then(() => { - cy.get(".error-text").contains("Please enter valid phone number"); - }); - }); - - it("Valid Phone Number of " + username, () => { - const phone_num = "99999-99999"; - cy.get("[placeholder='Phone Number']") - .focus() - .type(`${backspace}${phone_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${phone_num}`); - cy.wait(1000); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt") - .contains("Contact No") - .siblings() - .first() - .contains(`+91 ${phone_num}`.replace(/[ -]/g, "")); + it("Email Field Updation " + username, () => { + cy.get("input[name=email]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "This field is required"); + cy.get("input[name=email]").type("test@test.com"); + cy.contains("button[type='submit']", "Update").click(); }); afterEach(() => { @@ -256,15 +195,15 @@ describe("Edit Profile Testing", () => { }); }); -describe("Delete User", () => { - it("deletes user", () => { - cy.loginByApi("devdistrictadmin", "Coronasafe@123"); - cy.awaitUrl("/user"); - cy.get("[name='username']").type(username, { force: true }); - cy.get("button") - .should("contain", "Delete") - .contains("Delete") - .click({ force: true }); - cy.get("button.font-medium.btn.btn-danger").click(); - }); -}); +// describe("Delete User", () => { district admin wont be able to delete user +// it("deletes user", () => { +// cy.loginByApi("devdistrictadmin", "Coronasafe@123"); +// cy.awaitUrl("/user"); +// cy.get("[name='username']").type(username); +// cy.get("button") +// .should("contain", "Delete") +// .contains("Delete") +// .click(); +// cy.get("button.font-medium.btn.btn-danger").click(); +// }); +// }); diff --git a/package-lock.json b/package-lock.json index c5e43cd7cdc..3c736b57355 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,6 @@ "react-dom": "18.2.0", "react-google-recaptcha": "^2.1.0", "react-i18next": "^11.18.6", - "react-phone-input-2": "^2.15.1", "react-player": "^2.11.0", "react-qr-reader": "^2.2.1", "react-redux": "^8.0.4", @@ -7517,12 +7516,6 @@ "dev": true, "license": "MIT" }, - "node_modules/classnames": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", - "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==", - "license": "MIT" - }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -12532,6 +12525,7 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, "license": "MIT" }, "node_modules/lodash.isplainobject": { @@ -12541,12 +12535,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -12561,24 +12549,12 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", - "license": "MIT" - }, "node_modules/lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", "dev": true }, - "node_modules/lodash.startswith": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/lodash.startswith/-/lodash.startswith-4.2.1.tgz", - "integrity": "sha512-XClYR1h4/fJ7H+mmCKppbiBmljN/nGs73iq2SjCT9SF4CBPoUHzLvWmH1GtZMhMBZSiRkHXfeA2RY1eIlJ75ww==", - "license": "MIT" - }, "node_modules/lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -14625,23 +14601,6 @@ "react-dom": "^0.14 || >=15" } }, - "node_modules/react-phone-input-2": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/react-phone-input-2/-/react-phone-input-2-2.15.1.tgz", - "integrity": "sha512-W03abwhXcwUoq+vUFvC6ch2+LJYMN8qSOiO889UH6S7SyMCQvox/LF3QWt+cZagZrRdi5z2ON3omnjoCUmlaYw==", - "dependencies": { - "classnames": "^2.2.6", - "lodash.debounce": "^4.0.8", - "lodash.memoize": "^4.1.2", - "lodash.reduce": "^4.6.0", - "lodash.startswith": "^4.2.1", - "prop-types": "^15.7.2" - }, - "peerDependencies": { - "react": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", - "react-dom": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0" - } - }, "node_modules/react-player": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.11.0.tgz", @@ -23095,11 +23054,6 @@ "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", "dev": true }, - "classnames": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", - "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" - }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -26683,7 +26637,8 @@ "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true }, "lodash.isplainobject": { "version": "4.0.6", @@ -26691,11 +26646,6 @@ "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", "dev": true }, - "lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" - }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -26708,22 +26658,12 @@ "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", "dev": true }, - "lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==" - }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", "dev": true }, - "lodash.startswith": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/lodash.startswith/-/lodash.startswith-4.2.1.tgz", - "integrity": "sha512-XClYR1h4/fJ7H+mmCKppbiBmljN/nGs73iq2SjCT9SF4CBPoUHzLvWmH1GtZMhMBZSiRkHXfeA2RY1eIlJ75ww==" - }, "lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -28138,19 +28078,6 @@ "prop-types": "^15.7.2" } }, - "react-phone-input-2": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/react-phone-input-2/-/react-phone-input-2-2.15.1.tgz", - "integrity": "sha512-W03abwhXcwUoq+vUFvC6ch2+LJYMN8qSOiO889UH6S7SyMCQvox/LF3QWt+cZagZrRdi5z2ON3omnjoCUmlaYw==", - "requires": { - "classnames": "^2.2.6", - "lodash.debounce": "^4.0.8", - "lodash.memoize": "^4.1.2", - "lodash.reduce": "^4.6.0", - "lodash.startswith": "^4.2.1", - "prop-types": "^15.7.2" - } - }, "react-player": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.11.0.tgz", @@ -30627,4 +30554,4 @@ } } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 816d6099809..ba94c4ed55c 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "react-dom": "18.2.0", "react-google-recaptcha": "^2.1.0", "react-i18next": "^11.18.6", - "react-phone-input-2": "^2.15.1", "react-player": "^2.11.0", "react-qr-reader": "^2.2.1", "react-redux": "^8.0.4", @@ -210,4 +209,4 @@ "engines": { "node": "18.x" } -} \ No newline at end of file +} diff --git a/src/CAREUI/interactive/FiltersSlideover.tsx b/src/CAREUI/interactive/FiltersSlideover.tsx index 4e2d68cd6c5..581dcd25cd0 100644 --- a/src/CAREUI/interactive/FiltersSlideover.tsx +++ b/src/CAREUI/interactive/FiltersSlideover.tsx @@ -55,8 +55,8 @@ export const AdvancedFilterButton = ({ onClick }: { onClick: () => void }) => { className="bg-white w-full sm:w-auto" onClick={onClick} > - - {t("advanced_filters")} + + {t("advanced_filters")} ); }; diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 258352a65fd..5736327e16e 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -465,16 +465,16 @@ export const BLOOD_GROUPS = [ ]; export const SAMPLE_TYPE_CHOICES = [ - { id: 0, text: "UNKNOWN" }, - { id: 1, text: "BA/ETA" }, - { id: 2, text: "TS/NPS/NS" }, - { id: 3, text: "Blood in EDTA" }, - { id: 4, text: "Acute Sera" }, - { id: 5, text: "Covalescent sera" }, - { id: 6, text: "Biopsy" }, - { id: 7, text: "AMR" }, - { id: 8, text: "Communicable Diseases" }, - { id: 9, text: "OTHER TYPE" }, + { id: "0", text: "UNKNOWN" }, + { id: "1", text: "BA/ETA" }, + { id: "2", text: "TS/NPS/NS" }, + { id: "3", text: "Blood in EDTA" }, + { id: "4", text: "Acute Sera" }, + { id: "5", text: "Covalescent sera" }, + { id: "6", text: "Biopsy" }, + { id: "7", text: "AMR" }, + { id: "8", text: "Communicable Diseases" }, + { id: "9", text: "OTHER TYPE" }, ]; export const ICMR_CATEGORY = [ diff --git a/src/Common/hooks/useAsyncOptions.ts b/src/Common/hooks/useAsyncOptions.ts index 7ed5121e2a1..f0a1c895430 100644 --- a/src/Common/hooks/useAsyncOptions.ts +++ b/src/Common/hooks/useAsyncOptions.ts @@ -4,6 +4,7 @@ import { useDispatch } from "react-redux"; interface IUseAsyncOptionsArgs { debounceInterval?: number; + queryResponseExtractor?: (data: any) => any; } /** @@ -40,7 +41,10 @@ export function useAsyncOptions>( debounce(async (action: any) => { setIsLoading(true); const res = await dispatch(action); - if (res?.data) setQueryOptions(res.data as T[]); + if (res?.data) + setQueryOptions( + args?.queryResponseExtractor?.(res.data) ?? (res.data as T[]) + ); setIsLoading(false); }, args?.debounceInterval ?? 300), [dispatch, args?.debounceInterval] diff --git a/src/Common/hooks/useExport.tsx b/src/Common/hooks/useExport.tsx index f3af6e43400..6a0482714f0 100644 --- a/src/Common/hooks/useExport.tsx +++ b/src/Common/hooks/useExport.tsx @@ -1,31 +1,15 @@ import { useState } from "react"; import { useDispatch } from "react-redux"; -import CSVLink from "../../Components/Common/CSVLink"; - -interface CSVLinkProps { - id: string; - filename: string; - data: string; -} +import moment from "moment"; export default function useExport() { const dispatch: any = useDispatch(); const [isExporting, setIsExporting] = useState(false); - const [csvLinkProps, setCsvLinkProps] = useState({ - id: "csv-download-link", - filename: "", - data: "", - }); - - const _CSVLink = () => { - const { filename, data, id } = csvLinkProps; - return ; - }; const getTimestamp = () => { - const d = new Date(); - const date = d.toLocaleDateString(); - const time = d.toLocaleTimeString(); + const now = moment(); + const date = now.format("YYYY-MM-DD"); + const time = now.format("HH:mm:ss"); return date + "_" + time; }; @@ -41,8 +25,13 @@ export default function useExport() { const res = await dispatch(action); if (res.status === 200) { - setCsvLinkProps({ ...csvLinkProps, filename, data: parse(res.data) }); - document.getElementById(csvLinkProps.id)?.click(); + const a = document.createElement("a"); + const blob = new Blob([parse(res.data)], { + type: "text/css", + }); + a.href = URL.createObjectURL(blob); + a.download = filename; + a.click(); } setIsExporting(false); @@ -91,9 +80,6 @@ export default function useExport() { return { isExporting, - - _CSVLink, - exportCSV, exportJSON, exportFile, diff --git a/src/Common/static/countryPhoneAndFlags.json b/src/Common/static/countryPhoneAndFlags.json new file mode 100644 index 00000000000..687b08fdc25 --- /dev/null +++ b/src/Common/static/countryPhoneAndFlags.json @@ -0,0 +1 @@ +{"AD":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฉ","name":"Andorra","code":"376"},"AE":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ช","name":"United Arab Emirates","code":"971"},"AF":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ซ","name":"Afghanistan","code":"93"},"AG":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฌ","name":"Antigua & Barbuda","code":"+1-268"},"AI":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฎ","name":"Anguilla","code":"+1-264"},"AL":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฑ","name":"Albania","code":"355"},"AM":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฒ","name":"Armenia","code":"374"},"AO":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ด","name":"Angola","code":"244"},"AR":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ท","name":"Argentina","code":"54"},"AS":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ธ","name":"American Samoa","code":"+1-684"},"AT":{"flag":"๐Ÿ‡ฆ๐Ÿ‡น","name":"Austria","code":"43"},"AU":{"flag":"๐Ÿ‡ฆ๐Ÿ‡บ","name":"Australia","code":"61"},"AW":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ผ","name":"Aruba","code":"297"},"AX":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฝ","name":"ร…land Islands","code":"+358-18"},"AZ":{"flag":"๐Ÿ‡ฆ๐Ÿ‡ฟ","name":"Azerbaijan","code":"994"},"BA":{"flag":"๐Ÿ‡ง๐Ÿ‡ฆ","name":"Bosnia & Herzegovina","code":"387"},"BB":{"flag":"๐Ÿ‡ง๐Ÿ‡ง","name":"Barbados","code":"+1-246"},"BD":{"flag":"๐Ÿ‡ง๐Ÿ‡ฉ","name":"Bangladesh","code":"880"},"BE":{"flag":"๐Ÿ‡ง๐Ÿ‡ช","name":"Belgium","code":"32"},"BF":{"flag":"๐Ÿ‡ง๐Ÿ‡ซ","name":"Burkina Faso","code":"226"},"BG":{"flag":"๐Ÿ‡ง๐Ÿ‡ฌ","name":"Bulgaria","code":"359"},"BH":{"flag":"๐Ÿ‡ง๐Ÿ‡ญ","name":"Bahrain","code":"973"},"BI":{"flag":"๐Ÿ‡ง๐Ÿ‡ฎ","name":"Burundi","code":"257"},"BJ":{"flag":"๐Ÿ‡ง๐Ÿ‡ฏ","name":"Benin","code":"229"},"BL":{"flag":"๐Ÿ‡ง๐Ÿ‡ฑ","name":"St. Barthรฉlemy","code":"590"},"BM":{"flag":"๐Ÿ‡ง๐Ÿ‡ฒ","name":"Bermuda","code":"+1-441"},"BN":{"flag":"๐Ÿ‡ง๐Ÿ‡ณ","name":"Brunei","code":"673"},"BO":{"flag":"๐Ÿ‡ง๐Ÿ‡ด","name":"Bolivia","code":"591"},"BQ":{"flag":"๐Ÿ‡ง๐Ÿ‡ถ","name":"Caribbean Netherlands","code":"599"},"BR":{"flag":"๐Ÿ‡ง๐Ÿ‡ท","name":"Brazil","code":"55"},"BS":{"flag":"๐Ÿ‡ง๐Ÿ‡ธ","name":"Bahamas","code":"+1-242"},"BT":{"flag":"๐Ÿ‡ง๐Ÿ‡น","name":"Bhutan","code":"975"},"BW":{"flag":"๐Ÿ‡ง๐Ÿ‡ผ","name":"Botswana","code":"267"},"BY":{"flag":"๐Ÿ‡ง๐Ÿ‡พ","name":"Belarus","code":"375"},"BZ":{"flag":"๐Ÿ‡ง๐Ÿ‡ฟ","name":"Belize","code":"501"},"CA":{"flag":"๐Ÿ‡จ๐Ÿ‡ฆ","name":"Canada","code":"1"},"CC":{"flag":"๐Ÿ‡จ๐Ÿ‡จ","name":"Cocos (Keeling) Islands","code":"61"},"CD":{"flag":"๐Ÿ‡จ๐Ÿ‡ฉ","name":"Congo - Kinshasa","code":"243"},"CF":{"flag":"๐Ÿ‡จ๐Ÿ‡ซ","name":"Central African Republic","code":"236"},"CG":{"flag":"๐Ÿ‡จ๐Ÿ‡ฌ","name":"Congo - Brazzaville","code":"242"},"CH":{"flag":"๐Ÿ‡จ๐Ÿ‡ญ","name":"Switzerland","code":"41"},"CI":{"flag":"๐Ÿ‡จ๐Ÿ‡ฎ","name":"Cรดte dโ€™Ivoire","code":"225"},"CK":{"flag":"๐Ÿ‡จ๐Ÿ‡ฐ","name":"Cook Islands","code":"682"},"CL":{"flag":"๐Ÿ‡จ๐Ÿ‡ฑ","name":"Chile","code":"56"},"CM":{"flag":"๐Ÿ‡จ๐Ÿ‡ฒ","name":"Cameroon","code":"237"},"CN":{"flag":"๐Ÿ‡จ๐Ÿ‡ณ","name":"China","code":"86"},"CO":{"flag":"๐Ÿ‡จ๐Ÿ‡ด","name":"Colombia","code":"57"},"CR":{"flag":"๐Ÿ‡จ๐Ÿ‡ท","name":"Costa Rica","code":"506"},"CU":{"flag":"๐Ÿ‡จ๐Ÿ‡บ","name":"Cuba","code":"53"},"CV":{"flag":"๐Ÿ‡จ๐Ÿ‡ป","name":"Cape Verde","code":"238"},"CW":{"flag":"๐Ÿ‡จ๐Ÿ‡ผ","name":"Curaรงao","code":"599"},"CX":{"flag":"๐Ÿ‡จ๐Ÿ‡ฝ","name":"Christmas Island","code":"61"},"CY":{"flag":"๐Ÿ‡จ๐Ÿ‡พ","name":"Cyprus","code":"357"},"CZ":{"flag":"๐Ÿ‡จ๐Ÿ‡ฟ","name":"Czechia","code":"420"},"DE":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ช","name":"Germany","code":"49"},"DJ":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ฏ","name":"Djibouti","code":"253"},"DK":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ฐ","name":"Denmark","code":"45"},"DM":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ฒ","name":"Dominica","code":"+1-767"},"DO":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ด","name":"Dominican Republic","code":"+1-809 and 1-829"},"DZ":{"flag":"๐Ÿ‡ฉ๐Ÿ‡ฟ","name":"Algeria","code":"213"},"EC":{"flag":"๐Ÿ‡ช๐Ÿ‡จ","name":"Ecuador","code":"593"},"EE":{"flag":"๐Ÿ‡ช๐Ÿ‡ช","name":"Estonia","code":"372"},"EG":{"flag":"๐Ÿ‡ช๐Ÿ‡ฌ","name":"Egypt","code":"20"},"EH":{"flag":"๐Ÿ‡ช๐Ÿ‡ญ","name":"Western Sahara","code":"212"},"ER":{"flag":"๐Ÿ‡ช๐Ÿ‡ท","name":"Eritrea","code":"291"},"ES":{"flag":"๐Ÿ‡ช๐Ÿ‡ธ","name":"Spain","code":"34"},"ET":{"flag":"๐Ÿ‡ช๐Ÿ‡น","name":"Ethiopia","code":"251"},"FI":{"flag":"๐Ÿ‡ซ๐Ÿ‡ฎ","name":"Finland","code":"358"},"FJ":{"flag":"๐Ÿ‡ซ๐Ÿ‡ฏ","name":"Fiji","code":"679"},"FK":{"flag":"๐Ÿ‡ซ๐Ÿ‡ฐ","name":"Falkland Islands","code":"500"},"FM":{"flag":"๐Ÿ‡ซ๐Ÿ‡ฒ","name":"Micronesia","code":"691"},"FO":{"flag":"๐Ÿ‡ซ๐Ÿ‡ด","name":"Faroe Islands","code":"298"},"FR":{"flag":"๐Ÿ‡ซ๐Ÿ‡ท","name":"France","code":"33"},"GA":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฆ","name":"Gabon","code":"241"},"GB":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ง","name":"United Kingdom","code":"44"},"GD":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฉ","name":"Grenada","code":"+1-473"},"GE":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ช","name":"Georgia","code":"995"},"GF":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ซ","name":"French Guiana","code":"594"},"GG":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฌ","name":"Guernsey","code":"+44-1481"},"GH":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ญ","name":"Ghana","code":"233"},"GI":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฎ","name":"Gibraltar","code":"350"},"GL":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฑ","name":"Greenland","code":"299"},"GM":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ฒ","name":"Gambia","code":"220"},"GN":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ณ","name":"Guinea","code":"224"},"GP":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ต","name":"Guadeloupe","code":"590"},"GQ":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ถ","name":"Equatorial Guinea","code":"240"},"GR":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ท","name":"Greece","code":"30"},"GT":{"flag":"๐Ÿ‡ฌ๐Ÿ‡น","name":"Guatemala","code":"502"},"GU":{"flag":"๐Ÿ‡ฌ๐Ÿ‡บ","name":"Guam","code":"+1-671"},"GW":{"flag":"๐Ÿ‡ฌ๐Ÿ‡ผ","name":"Guinea-Bissau","code":"245"},"GY":{"flag":"๐Ÿ‡ฌ๐Ÿ‡พ","name":"Guyana","code":"592"},"HK":{"flag":"๐Ÿ‡ญ๐Ÿ‡ฐ","name":"Hong Kong SAR China","code":"852"},"HM":{"flag":"๐Ÿ‡ญ๐Ÿ‡ฒ","name":"Heard & McDonald Islands","code":" "},"HN":{"flag":"๐Ÿ‡ญ๐Ÿ‡ณ","name":"Honduras","code":"504"},"HR":{"flag":"๐Ÿ‡ญ๐Ÿ‡ท","name":"Croatia","code":"385"},"HT":{"flag":"๐Ÿ‡ญ๐Ÿ‡น","name":"Haiti","code":"509"},"HU":{"flag":"๐Ÿ‡ญ๐Ÿ‡บ","name":"Hungary","code":"36"},"ID":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ฉ","name":"Indonesia","code":"62"},"IE":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ช","name":"Ireland","code":"353"},"IL":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ฑ","name":"Israel","code":"972"},"IM":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ฒ","name":"Isle of Man","code":"+44-1624"},"IN":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ณ","name":"India","code":"91"},"IO":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ด","name":"British Indian Ocean Territory","code":"246"},"IQ":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ถ","name":"Iraq","code":"964"},"IR":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ท","name":"Iran","code":"98"},"IS":{"flag":"๐Ÿ‡ฎ๐Ÿ‡ธ","name":"Iceland","code":"354"},"IT":{"flag":"๐Ÿ‡ฎ๐Ÿ‡น","name":"Italy","code":"39"},"JE":{"flag":"๐Ÿ‡ฏ๐Ÿ‡ช","name":"Jersey","code":"+44-1534"},"JM":{"flag":"๐Ÿ‡ฏ๐Ÿ‡ฒ","name":"Jamaica","code":"+1-876"},"JO":{"flag":"๐Ÿ‡ฏ๐Ÿ‡ด","name":"Jordan","code":"962"},"JP":{"flag":"๐Ÿ‡ฏ๐Ÿ‡ต","name":"Japan","code":"81"},"KE":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ช","name":"Kenya","code":"254"},"KG":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ฌ","name":"Kyrgyzstan","code":"996"},"KH":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ญ","name":"Cambodia","code":"855"},"KI":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ฎ","name":"Kiribati","code":"686"},"KM":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ฒ","name":"Comoros","code":"269"},"KN":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ณ","name":"St. Kitts & Nevis","code":"+1-869"},"KP":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ต","name":"North Korea","code":"850"},"KR":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ท","name":"South Korea","code":"82"},"KW":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ผ","name":"Kuwait","code":"965"},"KY":{"flag":"๐Ÿ‡ฐ๐Ÿ‡พ","name":"Cayman Islands","code":"+1-345"},"KZ":{"flag":"๐Ÿ‡ฐ๐Ÿ‡ฟ","name":"Kazakhstan","code":"7"},"LA":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ฆ","name":"Laos","code":"856"},"LB":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ง","name":"Lebanon","code":"961"},"LC":{"flag":"๐Ÿ‡ฑ๐Ÿ‡จ","name":"St. Lucia","code":"+1-758"},"LI":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ฎ","name":"Liechtenstein","code":"423"},"LK":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ฐ","name":"Sri Lanka","code":"94"},"LR":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ท","name":"Liberia","code":"231"},"LS":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ธ","name":"Lesotho","code":"266"},"LT":{"flag":"๐Ÿ‡ฑ๐Ÿ‡น","name":"Lithuania","code":"370"},"LU":{"flag":"๐Ÿ‡ฑ๐Ÿ‡บ","name":"Luxembourg","code":"352"},"LV":{"flag":"๐Ÿ‡ฑ๐Ÿ‡ป","name":"Latvia","code":"371"},"LY":{"flag":"๐Ÿ‡ฑ๐Ÿ‡พ","name":"Libya","code":"218"},"MA":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฆ","name":"Morocco","code":"212"},"MC":{"flag":"๐Ÿ‡ฒ๐Ÿ‡จ","name":"Monaco","code":"377"},"MD":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฉ","name":"Moldova","code":"373"},"ME":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ช","name":"Montenegro","code":"382"},"MF":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ซ","name":"St. Martin","code":"590"},"MG":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฌ","name":"Madagascar","code":"261"},"MH":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ญ","name":"Marshall Islands","code":"692"},"MK":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฐ","name":"North Macedonia","code":"389"},"ML":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฑ","name":"Mali","code":"223"},"MM":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฒ","name":"Myanmar (Burma)","code":"95"},"MN":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ณ","name":"Mongolia","code":"976"},"MO":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ด","name":"Macao SAR China","code":"853"},"MP":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ต","name":"Northern Mariana Islands","code":"+1-670"},"MQ":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ถ","name":"Martinique","code":"596"},"MR":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ท","name":"Mauritania","code":"222"},"MS":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ธ","name":"Montserrat","code":"+1-664"},"MT":{"flag":"๐Ÿ‡ฒ๐Ÿ‡น","name":"Malta","code":"356"},"MU":{"flag":"๐Ÿ‡ฒ๐Ÿ‡บ","name":"Mauritius","code":"230"},"MV":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ป","name":"Maldives","code":"960"},"MW":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ผ","name":"Malawi","code":"265"},"MX":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฝ","name":"Mexico","code":"52"},"MY":{"flag":"๐Ÿ‡ฒ๐Ÿ‡พ","name":"Malaysia","code":"60"},"MZ":{"flag":"๐Ÿ‡ฒ๐Ÿ‡ฟ","name":"Mozambique","code":"258"},"NA":{"flag":"๐Ÿ‡ณ๐Ÿ‡ฆ","name":"Namibia","code":"264"},"NC":{"flag":"๐Ÿ‡ณ๐Ÿ‡จ","name":"New Caledonia","code":"687"},"NE":{"flag":"๐Ÿ‡ณ๐Ÿ‡ช","name":"Niger","code":"227"},"NF":{"flag":"๐Ÿ‡ณ๐Ÿ‡ซ","name":"Norfolk Island","code":"672"},"NG":{"flag":"๐Ÿ‡ณ๐Ÿ‡ฌ","name":"Nigeria","code":"234"},"NI":{"flag":"๐Ÿ‡ณ๐Ÿ‡ฎ","name":"Nicaragua","code":"505"},"NL":{"flag":"๐Ÿ‡ณ๐Ÿ‡ฑ","name":"Netherlands","code":"31"},"NO":{"flag":"๐Ÿ‡ณ๐Ÿ‡ด","name":"Norway","code":"47"},"NP":{"flag":"๐Ÿ‡ณ๐Ÿ‡ต","name":"Nepal","code":"977"},"NR":{"flag":"๐Ÿ‡ณ๐Ÿ‡ท","name":"Nauru","code":"674"},"NU":{"flag":"๐Ÿ‡ณ๐Ÿ‡บ","name":"Niue","code":"683"},"NZ":{"flag":"๐Ÿ‡ณ๐Ÿ‡ฟ","name":"New Zealand","code":"64"},"OM":{"flag":"๐Ÿ‡ด๐Ÿ‡ฒ","name":"Oman","code":"968"},"PA":{"flag":"๐Ÿ‡ต๐Ÿ‡ฆ","name":"Panama","code":"507"},"PE":{"flag":"๐Ÿ‡ต๐Ÿ‡ช","name":"Peru","code":"51"},"PF":{"flag":"๐Ÿ‡ต๐Ÿ‡ซ","name":"French Polynesia","code":"689"},"PG":{"flag":"๐Ÿ‡ต๐Ÿ‡ฌ","name":"Papua New Guinea","code":"675"},"PH":{"flag":"๐Ÿ‡ต๐Ÿ‡ญ","name":"Philippines","code":"63"},"PK":{"flag":"๐Ÿ‡ต๐Ÿ‡ฐ","name":"Pakistan","code":"92"},"PL":{"flag":"๐Ÿ‡ต๐Ÿ‡ฑ","name":"Poland","code":"48"},"PM":{"flag":"๐Ÿ‡ต๐Ÿ‡ฒ","name":"St. Pierre & Miquelon","code":"508"},"PN":{"flag":"๐Ÿ‡ต๐Ÿ‡ณ","name":"Pitcairn Islands","code":"870"},"PR":{"flag":"๐Ÿ‡ต๐Ÿ‡ท","name":"Puerto Rico","code":"+1-787 and 1-939"},"PS":{"flag":"๐Ÿ‡ต๐Ÿ‡ธ","name":"Palestinian Territories","code":"970"},"PT":{"flag":"๐Ÿ‡ต๐Ÿ‡น","name":"Portugal","code":"351"},"PW":{"flag":"๐Ÿ‡ต๐Ÿ‡ผ","name":"Palau","code":"680"},"PY":{"flag":"๐Ÿ‡ต๐Ÿ‡พ","name":"Paraguay","code":"595"},"QA":{"flag":"๐Ÿ‡ถ๐Ÿ‡ฆ","name":"Qatar","code":"974"},"RE":{"flag":"๐Ÿ‡ท๐Ÿ‡ช","name":"Rรฉunion","code":"262"},"RO":{"flag":"๐Ÿ‡ท๐Ÿ‡ด","name":"Romania","code":"40"},"RS":{"flag":"๐Ÿ‡ท๐Ÿ‡ธ","name":"Serbia","code":"381"},"RU":{"flag":"๐Ÿ‡ท๐Ÿ‡บ","name":"Russia","code":"7"},"RW":{"flag":"๐Ÿ‡ท๐Ÿ‡ผ","name":"Rwanda","code":"250"},"SA":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฆ","name":"Saudi Arabia","code":"966"},"SB":{"flag":"๐Ÿ‡ธ๐Ÿ‡ง","name":"Solomon Islands","code":"677"},"SC":{"flag":"๐Ÿ‡ธ๐Ÿ‡จ","name":"Seychelles","code":"248"},"SD":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฉ","name":"Sudan","code":"249"},"SE":{"flag":"๐Ÿ‡ธ๐Ÿ‡ช","name":"Sweden","code":"46"},"SG":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฌ","name":"Singapore","code":"65"},"SH":{"flag":"๐Ÿ‡ธ๐Ÿ‡ญ","name":"St. Helena","code":"290"},"SI":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฎ","name":"Slovenia","code":"386"},"SJ":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฏ","name":"Svalbard & Jan Mayen","code":"47"},"SK":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฐ","name":"Slovakia","code":"421"},"SL":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฑ","name":"Sierra Leone","code":"232"},"SM":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฒ","name":"San Marino","code":"378"},"SN":{"flag":"๐Ÿ‡ธ๐Ÿ‡ณ","name":"Senegal","code":"221"},"SO":{"flag":"๐Ÿ‡ธ๐Ÿ‡ด","name":"Somalia","code":"252"},"SR":{"flag":"๐Ÿ‡ธ๐Ÿ‡ท","name":"Suriname","code":"597"},"SS":{"flag":"๐Ÿ‡ธ๐Ÿ‡ธ","name":"South Sudan","code":"211"},"ST":{"flag":"๐Ÿ‡ธ๐Ÿ‡น","name":"Sรฃo Tomรฉ & Prรญncipe","code":"239"},"SV":{"flag":"๐Ÿ‡ธ๐Ÿ‡ป","name":"El Salvador","code":"503"},"SX":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฝ","name":"Sint Maarten","code":"599"},"SY":{"flag":"๐Ÿ‡ธ๐Ÿ‡พ","name":"Syria","code":"963"},"SZ":{"flag":"๐Ÿ‡ธ๐Ÿ‡ฟ","name":"Eswatini","code":"268"},"TC":{"flag":"๐Ÿ‡น๐Ÿ‡จ","name":"Turks & Caicos Islands","code":"+1-649"},"TD":{"flag":"๐Ÿ‡น๐Ÿ‡ฉ","name":"Chad","code":"235"},"TG":{"flag":"๐Ÿ‡น๐Ÿ‡ฌ","name":"Togo","code":"228"},"TH":{"flag":"๐Ÿ‡น๐Ÿ‡ญ","name":"Thailand","code":"66"},"TJ":{"flag":"๐Ÿ‡น๐Ÿ‡ฏ","name":"Tajikistan","code":"992"},"TK":{"flag":"๐Ÿ‡น๐Ÿ‡ฐ","name":"Tokelau","code":"690"},"TL":{"flag":"๐Ÿ‡น๐Ÿ‡ฑ","name":"Timor-Leste","code":"670"},"TM":{"flag":"๐Ÿ‡น๐Ÿ‡ฒ","name":"Turkmenistan","code":"993"},"TN":{"flag":"๐Ÿ‡น๐Ÿ‡ณ","name":"Tunisia","code":"216"},"TO":{"flag":"๐Ÿ‡น๐Ÿ‡ด","name":"Tonga","code":"676"},"TR":{"flag":"๐Ÿ‡น๐Ÿ‡ท","name":"Turkey","code":"90"},"TT":{"flag":"๐Ÿ‡น๐Ÿ‡น","name":"Trinidad & Tobago","code":"+1-868"},"TV":{"flag":"๐Ÿ‡น๐Ÿ‡ป","name":"Tuvalu","code":"688"},"TW":{"flag":"๐Ÿ‡น๐Ÿ‡ผ","name":"Taiwan","code":"886"},"TZ":{"flag":"๐Ÿ‡น๐Ÿ‡ฟ","name":"Tanzania","code":"255"},"UA":{"flag":"๐Ÿ‡บ๐Ÿ‡ฆ","name":"Ukraine","code":"380"},"UG":{"flag":"๐Ÿ‡บ๐Ÿ‡ฌ","name":"Uganda","code":"256"},"UM":{"flag":"๐Ÿ‡บ๐Ÿ‡ฒ","name":"U.S. Outlying Islands","code":"1"},"US":{"flag":"๐Ÿ‡บ๐Ÿ‡ธ","name":"United States","code":"1"},"UY":{"flag":"๐Ÿ‡บ๐Ÿ‡พ","name":"Uruguay","code":"598"},"UZ":{"flag":"๐Ÿ‡บ๐Ÿ‡ฟ","name":"Uzbekistan","code":"998"},"VA":{"flag":"๐Ÿ‡ป๐Ÿ‡ฆ","name":"Vatican City","code":"379"},"VC":{"flag":"๐Ÿ‡ป๐Ÿ‡จ","name":"St. Vincent & Grenadines","code":"+1-784"},"VE":{"flag":"๐Ÿ‡ป๐Ÿ‡ช","name":"Venezuela","code":"58"},"VG":{"flag":"๐Ÿ‡ป๐Ÿ‡ฌ","name":"British Virgin Islands","code":"+1-284"},"VI":{"flag":"๐Ÿ‡ป๐Ÿ‡ฎ","name":"U.S. Virgin Islands","code":"+1-340"},"VN":{"flag":"๐Ÿ‡ป๐Ÿ‡ณ","name":"Vietnam","code":"84"},"VU":{"flag":"๐Ÿ‡ป๐Ÿ‡บ","name":"Vanuatu","code":"678"},"WF":{"flag":"๐Ÿ‡ผ๐Ÿ‡ซ","name":"Wallis & Futuna","code":"681"},"WS":{"flag":"๐Ÿ‡ผ๐Ÿ‡ธ","name":"Samoa","code":"685"},"YE":{"flag":"๐Ÿ‡พ๐Ÿ‡ช","name":"Yemen","code":"967"},"YT":{"flag":"๐Ÿ‡พ๐Ÿ‡น","name":"Mayotte","code":"262"},"ZA":{"flag":"๐Ÿ‡ฟ๐Ÿ‡ฆ","name":"South Africa","code":"27"},"ZM":{"flag":"๐Ÿ‡ฟ๐Ÿ‡ฒ","name":"Zambia","code":"260"},"ZW":{"flag":"๐Ÿ‡ฟ๐Ÿ‡ผ","name":"Zimbabwe","code":"263"}} \ No newline at end of file diff --git a/src/Components/Assets/AssetsList.tsx b/src/Components/Assets/AssetsList.tsx index a9755ff79d5..a04286420f6 100644 --- a/src/Components/Assets/AssetsList.tsx +++ b/src/Components/Assets/AssetsList.tsx @@ -360,13 +360,16 @@ const AssetsList = () => { /> setIsScannerActive(true)} > Scan Asset QR -
+
{ - const generateCsvDataURI = (csvData: any) => { - const csvContent = `data:text/csv;charset=utf-8,${encodeURIComponent( - csvData - )}`; - return csvContent; - }; - return ( - - ); -}; -export default CSVLink; diff --git a/src/Components/Common/Export.tsx b/src/Components/Common/Export.tsx index edc4b7ec62a..61d9c84b865 100644 --- a/src/Components/Common/Export.tsx +++ b/src/Components/Common/Export.tsx @@ -36,11 +36,10 @@ export const ExportMenu = ({ disabled, exportItems, }: ExportMenuProps) => { - const { isExporting, exportFile, _CSVLink } = useExport(); + const { isExporting, exportFile } = useExport(); return (
- <_CSVLink /> { - const { isExporting, exportFile, _CSVLink } = useExport(); + const { isExporting, exportFile } = useExport(); return ( <> - <_CSVLink /> diff --git a/src/Components/Common/HelperInputFields.tsx b/src/Components/Common/HelperInputFields.tsx index a98172c015b..8d1de0b3b74 100644 --- a/src/Components/Common/HelperInputFields.tsx +++ b/src/Components/Common/HelperInputFields.tsx @@ -1,5 +1,3 @@ -import "react-phone-input-2/lib/high-res.css"; - import { Checkbox, Chip, @@ -21,13 +19,10 @@ import { KeyboardDateTimePicker, MuiPickersUtilsProvider, } from "@material-ui/pickers"; -import PhoneInput, { ICountryData } from "react-phone-input-2"; -import React, { ChangeEvent, useEffect, useState } from "react"; +import React from "react"; import Autocomplete from "@material-ui/lab/Autocomplete"; import Box from "@material-ui/core/Box"; -import ButtonV2 from "./components/ButtonV2"; -import CareIcon from "../../CAREUI/icons/CareIcon"; import DateFnsUtils from "@date-io/date-fns"; import FormControl from "@material-ui/core/FormControl"; import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date"; @@ -74,10 +69,6 @@ export interface DefaultNativeSelectInputProps extends NativeSelectInputProps { // Type Declarations type TextFieldPropsExtended = TextFieldProps & { errors: string }; -type ActionTextFieldProps = TextFieldPropsExtended & { - actionIcon?: React.ReactElement; - action?: () => void; -}; interface DateInputFieldProps extends DatePickerProps { value: string; @@ -136,54 +127,6 @@ export const LegacyTextInputField = (props: TextFieldPropsExtended) => { ); }; -/** - * Deprecated. Use `TextFormField` instead. - */ -export const LegacyActionTextInputField = (props: ActionTextFieldProps) => { - const { onChange, type, errors, onKeyDown } = props; - const inputType = type === "number" || type === "float" ? "text" : type; - const handleChange = (event: React.ChangeEvent) => { - if (typeof onChange !== "function") { - return; - } - if (type === "number" && event.target.value) { - event.target.value = event.target.value.replace(/\D/, ""); - } - if (type === "float" && event.target.value) { - event.target.value = event.target.value.replace(/(?!\.)\D/, ""); - } - onChange(event); - }; - const handleKeyDown = (event: React.KeyboardEvent) => { - if (typeof onKeyDown !== "function") { - return; - } - onKeyDown(event); - }; - return ( -
-
- - {props.actionIcon && ( -
- {props.actionIcon} -
- )} -
- -
- ); -}; - /** * Deprecated. Use `TextAreaFormField` instead. */ @@ -564,180 +507,3 @@ export const LegacyAutoCompleteAsyncField = ( ); }; - -/** - * Deprecated. Use `PhoneNumberFormField` instead. - */ -export const LegacyPhoneNumberField = (props: any) => { - const { - label, - placeholder, - errors, - onChange, - onlyIndia, - value, - turnOffAutoFormat, - disabled, - countryCodeEditable = false, - className, - id, - name, - requiredError = false, - } = props; - const [maxLength, setMaxLength] = useState(15); - const [enableTollFree, setEnableTollFree] = useState( - value.startsWith("1800") - ); - const countryRestriction = onlyIndia ? { onlyCountries: ["in"] } : {}; - const [randId, setRandId] = useState(""); - - useEffect(() => { - if (value.startsWith("1800")) { - setEnableTollFree(true); - } else { - setEnableTollFree(false); - } - }, [value]); - - useEffect(() => { - setRandId( - Math.random() - .toString(36) - .replace(/[^a-z]+/g, "a") - ); - }, []); - - const setFocus = () => { - setTimeout(() => { - const input = document.querySelector(`div#${randId} > div.visible input`); - if (input instanceof HTMLElement) { - input.focus(); - } - }, 10); - }; - - useEffect(() => { - if (enableTollFree) { - if (value.startsWith("1800")) { - setMaxLength(11); - } else { - setMaxLength(15); - } - } else { - setMaxLength(15); - } - }, [value]); - - const handleChange = ( - value: string, - data: Partial, - event: ChangeEvent, - formattedValue: string - ) => { - let phone = value; - if (phone.startsWith("91")) { - phone = phone.replace("91", ""); - } - if (phone.startsWith("1800")) { - setEnableTollFree(true); - setFocus(); - onChange(phone); - } else { - if (!value.startsWith("91") && !value.startsWith("1800")) { - onChange(`91${formattedValue}`); - } else { - onChange(formattedValue); - } - if (!value.startsWith("1800")) { - setEnableTollFree(false); - setFocus(); - } - } - setFocus(); - }; - - return ( - <> - {label && {label}} -
-
-
- -
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - {" "} - - -
-
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - - -
-
- {errors && } - - ); -}; diff --git a/src/Components/Common/Pagination.tsx b/src/Components/Common/Pagination.tsx index bf5a4354e49..e173e1d9b35 100644 --- a/src/Components/Common/Pagination.tsx +++ b/src/Components/Common/Pagination.tsx @@ -90,12 +90,14 @@ const Pagination = ({ {/* Mobile view */}
goToPage(currentPage - 1)} disabled={currentPage - 1 <= 0} children={} /> } onClick={() => goToPage(currentPage + 1)} @@ -106,12 +108,14 @@ const Pagination = ({ {/* Desktop view */}
-
- -
+ advancedFilter.setShow(true)} + />
+ [ badge("Name", "name"), diff --git a/src/Components/Facility/AssetCreate.tsx b/src/Components/Facility/AssetCreate.tsx index 27d9e6f63ed..07a7421ac42 100644 --- a/src/Components/Facility/AssetCreate.tsx +++ b/src/Components/Facility/AssetCreate.tsx @@ -510,7 +510,11 @@ const AssetCreate = (props: AssetProps) => { {/* General Details Section */} {sectionTitle("General Details")} {/* Asset Name */} -
+
{ Asset Location -
+
@@ -540,7 +548,11 @@ const AssetCreate = (props: AssetProps) => {
{/* Asset Type */}
-
+
{
{/* Asset Class */} -
+
{
{/* Description */} -
+
{ />
{/* Divider */} -
+

{ />
{/* Working Status */} -
+
{
{/* Asset QR ID */}
-
+
{
{
{
{
{
{
{
{
{
{/* Notes */} -
+
{ const middleware = - asset.meta?.middleware_hostname ?? facilityObj?.middleware_address; + asset.meta?.middleware_hostname || facilityObj?.middleware_address; const local_ip_address = asset.meta?.local_ip_address; return { diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index c311cda0327..6abb9cc4a3f 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -321,6 +321,7 @@ export const ConsultationForm = (props: any) => { is_telemedicine: `${res.data.is_telemedicine}`, is_kasp: `${res.data.is_kasp}`, assigned_to: res.data.assigned_to || "", + assigned_to_object: res.data.assigned_to_object, ett_tt: res.data.ett_tt ? Number(res.data.ett_tt) : 3, special_instruction: res.data.special_instruction || "", weight: res.data.weight ? res.data.weight : "", @@ -622,7 +623,9 @@ export const ConsultationForm = (props: any) => { action: state.form.action, review_interval: state.form.review_interval, assigned_to: - state.form.is_telemedicine === "true" ? state.form.assigned_to : "", + state.form.is_telemedicine.toString() === "true" + ? state.form.assigned_to + : "", special_instruction: state.form.special_instruction, weight: Number(state.form.weight), height: Number(state.form.height), @@ -1218,8 +1221,8 @@ export const ConsultationForm = (props: any) => { {JSON.parse(state.form.is_telemedicine) && ( diff --git a/src/Components/Facility/Consultations/Beds.tsx b/src/Components/Facility/Consultations/Beds.tsx index e7ab1418e4f..5f8e1b2ba12 100644 --- a/src/Components/Facility/Consultations/Beds.tsx +++ b/src/Components/Facility/Consultations/Beds.tsx @@ -9,13 +9,13 @@ import * as Notification from "../../../Utils/Notifications.js"; import Loading from "../../Common/Loading"; import { BedModel, CurrentBed } from "../models"; import { BedSelect } from "../../Common/BedSelect"; -import CircularProgress from "@material-ui/core/CircularProgress"; import { formatDate } from "../../../Utils/utils"; import { FieldLabel } from "../../Form/FormFields/FormField"; import ButtonV2 from "../../Common/components/ButtonV2"; import moment from "moment"; import CareIcon from "../../../CAREUI/icons/CareIcon"; import TextFormField from "../../Form/FormFields/TextFormField"; +import CircularProgress from "../../Common/components/CircularProgress"; const formatDateTime: () => string = () => { const current = new Date(); diff --git a/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx b/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx index a8a416bd3f8..d2c9889af6a 100644 --- a/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx @@ -37,7 +37,6 @@ const extractVirtualNursingAssistantFields = (round?: DailyRoundsModel) => { if (!round) return; const { temperature, - tempratureUnit, temperature_measured_at, bp, resp, @@ -48,7 +47,6 @@ const extractVirtualNursingAssistantFields = (round?: DailyRoundsModel) => { return { temperature, - tempratureUnit, temperature_measured_at, bp, resp, diff --git a/src/Components/Facility/Consultations/DailyRoundsList.tsx b/src/Components/Facility/Consultations/DailyRoundsList.tsx index 84fb8ccbaea..acc717ad3d1 100644 --- a/src/Components/Facility/Consultations/DailyRoundsList.tsx +++ b/src/Components/Facility/Consultations/DailyRoundsList.tsx @@ -9,8 +9,6 @@ import VirtualNursingAssistantLogUpdateCard from "./DailyRounds/VirtualNursingAs import DefaultLogUpdateCard from "./DailyRounds/DefaultLogUpdateCard"; import { useTranslation } from "react-i18next"; import LoadingLogUpdateCard from "./DailyRounds/LoadingCard"; -import { getTemperaturePreference } from "../../Common/utils/DevicePreference"; -import { fahrenheitToCelsius } from "../../../Utils/utils"; export const DailyRoundsList = (props: any) => { const { t } = useTranslation(); @@ -46,16 +44,7 @@ export const DailyRoundsList = (props: any) => { ); if (!status.aborted) { if (res && res.data) { - res.data.results.forEach((round: DailyRoundsModel) => { - round.temperatureUnit = getTemperaturePreference(); - round.temperature = - round.temperatureUnit === "F" - ? round.temperature - : fahrenheitToCelsius(round.temperature); - return round; - }); setDailyRoundsListData(res.data.results); - console.log(res.data.results); setTotalCount(res.data.count); } setIsDailyRoundLoading(false); @@ -106,7 +95,6 @@ export const DailyRoundsList = (props: any) => { return ( { diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index 0ea44f9e479..cb28aa8c3ab 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -1,4 +1,3 @@ -import { Modal } from "@material-ui/core"; import axios from "axios"; import { ChangeEventHandler, @@ -20,6 +19,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon"; import * as Notification from "../../Utils/Notifications.js"; import { useTranslation } from "react-i18next"; import { LocalStorageKeys } from "../../Common/constants"; +import DialogModal from "../Common/Dialog"; interface Props { open: boolean; onClose: (() => void) | undefined; @@ -173,26 +173,24 @@ const CoverImageEditModal = ({ {t("max_size_for_image_uploaded_should_be")} 1mb.
{t("allowed_formats_are")} jpg,png,jpeg. -
{t("recommended_aspect_ratio_for")} facility cover photo is 1:1 ); return ( - -
+ +
{!isCameraOpen ? ( -
-
- - {t("edit_cover_photo")} - - {facility.name} -
- + {hasImage ? ( <> -
+
{facility.name}

- {t("no_cover_photo_uploaded_for_this_facility")}.
- {commonHint} + {t("no_cover_photo_uploaded_for_this_facility")}. {commonHint}

)} -
+
) : ( -
-
+
+
{t("capture_cover_photo")} {facility.name}
-
+
{!previewImage ? ( <> )}
- + ); }; diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 66535bc187f..d15d88a3353 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -4,7 +4,6 @@ import { Cancel, Submit } from "../Common/components/ButtonV2"; import { useCallback, useEffect, useState } from "react"; import CareIcon from "../../CAREUI/icons/CareIcon"; -import { CircularProgress } from "@material-ui/core"; import ClaimDetailCard from "../HCX/ClaimDetailCard"; import { ConsultationModel } from "./models"; import CreateClaimCard from "../HCX/CreateClaimCard"; @@ -24,6 +23,7 @@ import useConfig from "../../Common/hooks/useConfig"; import { useDispatch } from "react-redux"; import { useMessageListener } from "../../Common/hooks/useMessageListener"; import PrescriptionBuilder from "../Medicine/PrescriptionBuilder"; +import CircularProgress from "../Common/components/CircularProgress"; interface PreDischargeFormInterface { discharge_reason: string; @@ -332,7 +332,7 @@ const DischargeModal = ({
{isSendingDischargeApi ? ( - + ) : ( handlePatientDischarge(false)} diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 6b4fe5e8769..d30015ddd8b 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -869,7 +869,7 @@ export const FacilityCreate = (props: FacilityProps) => { {...field("phone_number")} label={t("emergency_contact_number")} required - onlyIndia + disableCountry />
import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); export default function FacilityUsers(props: any) { const { facilityId } = props; @@ -235,9 +234,10 @@ export default function FacilityUsers(props: any) { >
{facility.name}
- setUnlinkFacilityData({ @@ -247,8 +247,8 @@ export default function FacilityUsers(props: any) { }) } > - - + +
))} @@ -452,7 +452,12 @@ export default function FacilityUsers(props: any) { } return ( -
+ {linkFacility.show && ( )} -
)} -
+
); } diff --git a/src/Components/Facility/InventoryList.tsx b/src/Components/Facility/InventoryList.tsx index ba78564ed00..e635ecd7bec 100644 --- a/src/Components/Facility/InventoryList.tsx +++ b/src/Components/Facility/InventoryList.tsx @@ -1,14 +1,14 @@ -import React, { useState, useCallback, useEffect } from "react"; +import { useState, useCallback, useEffect } from "react"; import loadable from "@loadable/component"; -import { Button } from "@material-ui/core"; import { navigate } from "raviger"; import { useDispatch } from "react-redux"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getInventorySummary, getAnyFacility } from "../../Redux/actions"; import Pagination from "../Common/Pagination"; -import { RoleButton } from "../Common/RoleButton"; import { classNames } from "../../Utils/utils"; -const PageTitle = loadable(() => import("../Common/PageTitle")); +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; const Loading = loadable(() => import("../Common/Loading")); export default function InventoryList(props: any) { @@ -152,52 +152,32 @@ export default function InventoryList(props: any) { } return ( -
- +
-
-
- - navigate(`/facility/${facilityId}/inventory/add`) - } - disableFor="readOnly" - buttonType="materialUI" - > - Manage Inventory - -
-
- -
+
+ + Manage Inventory + + + Minimum Quantity Required +
{inventoryItem}
-
+
); } diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index 64b631200b7..cebb7d95326 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -10,9 +10,10 @@ import { } from "../../Redux/actions"; import { statusType, useAbortableEffect } from "../../Common/utils"; import Pagination from "../Common/Pagination"; -import { Tooltip } from "@material-ui/core"; import { formatDate } from "../../Utils/utils"; -const PageTitle = loadable(() => import("../Common/PageTitle")); +import Page from "../Common/components/Page.js"; +import CareIcon from "../../CAREUI/icons/CareIcon.js"; +import ButtonV2 from "../Common/components/ButtonV2.js"; const Loading = loadable(() => import("../Common/Loading")); export default function InventoryLog(props: any) { @@ -146,43 +147,49 @@ export default function InventoryLog(props: any) {

- +
+ {inventoryItem.probable_accident ? (
Unmarks this transaction as accident
This action will not affect the total stock.
) : ( -
+
Marks this transaction as accident
This action will not affect the total stock. To delete the transaction, create another transaction that undos the effect of this, or click Delete Last Entry.
- ) - } - arrow={true} - > -
+ + {inventoryItem.probable_accident ? ( + flagFacility(inventoryItem.external_id)} + disabled={saving} + variant="primary" + > + + + UnMark - ) : ( - - + + ) : ( + flagFacility(inventoryItem.external_id)} + disabled={saving} + variant="danger" + > + + Mark as Accident - )} - - + + )} +
)); @@ -245,7 +252,7 @@ export default function InventoryLog(props: any) { return (
- -
-
-
-

Item: {itemName}

- {current_stock > 0 && ( - + > +
+
+
+

Item: {itemName}

+ {current_stock > 0 && ( +
+
Deletes the last transaction by creating an equivalent undo transaction and marks both the transactions as accident.
- } - arrow={true} - > - - - )} + + removeLastInventoryLog(inventory[0].item_object.id) + } + disabled={saving} + > + + + Delete Last Entry + + +
+ )} +
+ {inventoryItem}
- {inventoryItem}
-
+
); } diff --git a/src/Components/Form/FormFields/PhoneNumberFormField.tsx b/src/Components/Form/FormFields/PhoneNumberFormField.tsx index 14cd66af4bf..fcb7e6839ff 100644 --- a/src/Components/Form/FormFields/PhoneNumberFormField.tsx +++ b/src/Components/Form/FormFields/PhoneNumberFormField.tsx @@ -1,35 +1,103 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils"; - import FormField from "./FormField"; -import { LegacyPhoneNumberField } from "../../Common/HelperInputFields"; +import { AsYouType } from "libphonenumber-js"; +import { useMemo } from "react"; +import { classNames } from "../../../Utils/utils"; +import phoneCodesJson from "../../../Common/static/countryPhoneAndFlags.json"; + +interface CountryData { + flag: string; + name: string; + code: string; +} + +const phoneCodes: Record = phoneCodesJson; -type Props = FormFieldBaseProps & { +interface Props extends FormFieldBaseProps { placeholder?: string; autoComplete?: string; - noAutoFormat?: boolean; - onlyIndia?: boolean; - countryCodeEditable?: boolean; -}; + disableCountry?: boolean; +} -const PhoneNumberFormField = (props: Props) => { +export default function PhoneNumberFormField(props: Props) { const field = useFormFieldPropsResolver(props as any); + + const asYouType = useMemo(() => { + const asYouType = new AsYouType(); + + asYouType.reset(); + + if (field.value) { + asYouType.input(field.value); + } else { + asYouType.input("+91"); + field.handleChange(asYouType.getNumberValue()); + } + + return asYouType; + }, []); + + const setValue = (value: string) => { + asYouType.reset(); + field.handleChange(asYouType.input(value)); + }; + return ( - +
+ setValue(e.target.value)} + disabled={field.disabled} + /> + {!props.disableCountry && ( +
+ + +
+ )} +
); -}; +} -export default PhoneNumberFormField; +const conditionPhoneCode = (code: string) => { + code = code.split(" ")[0]; + return code.startsWith("+") ? code : "+" + code; +}; diff --git a/src/Components/Notifications/NotificationsList.tsx b/src/Components/Notifications/NotificationsList.tsx index 92d826ca97e..9f747ec4fb4 100644 --- a/src/Components/Notifications/NotificationsList.tsx +++ b/src/Components/Notifications/NotificationsList.tsx @@ -9,7 +9,6 @@ import { getPublicKey, } from "../../Redux/actions"; import { useSelector } from "react-redux"; -import { CircularProgress } from "@material-ui/core"; import Spinner from "../Common/Spinner"; import { NOTIFICATION_EVENTS } from "../../Common/constants"; import { Error } from "../../Utils/Notifications.js"; @@ -25,6 +24,7 @@ import SlideOver from "../../CAREUI/interactive/SlideOver"; import ButtonV2 from "../Common/components/ButtonV2"; import SelectMenuV2 from "../Form/SelectMenuV2"; import { useTranslation } from "react-i18next"; +import CircularProgress from "../Common/components/CircularProgress"; const RESULT_LIMIT = 14; @@ -348,7 +348,7 @@ export default function NotificationsList({ if (!offset && isLoading) { manageResults = (
- +
); } else if (data && data.length) { @@ -364,7 +364,7 @@ export default function NotificationsList({ ))} {isLoading && (
- +
)} {totalCount > RESULT_LIMIT && offset < totalCount - RESULT_LIMIT && ( diff --git a/src/Components/Patient/DailyRoundListDetails.tsx b/src/Components/Patient/DailyRoundListDetails.tsx index c1f45a55780..8e355f7b313 100644 --- a/src/Components/Patient/DailyRoundListDetails.tsx +++ b/src/Components/Patient/DailyRoundListDetails.tsx @@ -1,17 +1,14 @@ -import { Button } from "@material-ui/core"; -import { navigate } from "raviger"; import loadable from "@loadable/component"; import moment from "moment"; -import { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useState } from "react"; import { useDispatch } from "react-redux"; import { CURRENT_HEALTH_CHANGE, SYMPTOM_CHOICES } from "../../Common/constants"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getConsultationDailyRoundsDetails } from "../../Redux/actions"; import { DailyRoundsModel } from "./models"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; -import { celsiusToFahrenheit, fahrenheitToCelsius } from "../../Utils/utils"; +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); const symptomChoices = [...SYMPTOM_CHOICES]; const currentHealthChoices = [...CURRENT_HEALTH_CHANGE]; @@ -37,11 +34,8 @@ export const DailyRoundListDetails = (props: any) => { const data: DailyRoundsModel = { ...res.data, temperature: Number(res.data.temperature) - ? getTemperaturePreference() === "F" - ? res.data.temperature - : fahrenheitToCelsius(Number(res.data.temperature)) + ? res.data.temperature : "", - temperatureUnit: getTemperaturePreference(), additional_symptoms_text: "", medication_given: Object.keys(res.data.medication_given).length === 0 @@ -77,53 +71,15 @@ export const DailyRoundListDetails = (props: any) => { [dispatch, fetchpatient] ); - const toggleTemperatureOnLocalChange = () => { - const isCelcius = - dailyRoundListDetailsData.temperatureUnit === "C" ? true : false; - const temp = dailyRoundListDetailsData.temperature; - - const data = { ...dailyRoundListDetailsData }; - data.temperature = isCelcius - ? celsiusToFahrenheit(temp) - : fahrenheitToCelsius(temp); - data.temperatureUnit = isCelcius ? "F" : "C"; - setDailyRoundListDetails(data); - }; - - const handleLocalTemperatureChange = (e: any) => { - if (e.key === "temperature") { - if ( - dailyRoundListDetailsData.temperatureUnit === "C" && - e.newValue === "F" - ) { - toggleTemperatureOnLocalChange(); - } - if ( - dailyRoundListDetailsData.temperatureUnit === "F" && - e.newValue === "C" - ) { - toggleTemperatureOnLocalChange(); - } - } - }; - - useEffect(() => { - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, [dailyRoundListDetailsData.temperature]); - if (isLoading) { return ; } return ( -
- +
@@ -137,19 +93,11 @@ export const DailyRoundListDetails = (props: any) => {
- +
@@ -157,8 +105,7 @@ export const DailyRoundListDetails = (props: any) => {
Temperature: - {`${dailyRoundListDetailsData.temperature} ยฐ${dailyRoundListDetailsData.temperatureUnit}` || - "-"} + {dailyRoundListDetailsData.temperature || "-"}
Taken at: @@ -252,6 +199,6 @@ export const DailyRoundListDetails = (props: any) => {
-
+
); }; diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 1fad194e1b8..0ba60f4cf5c 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -40,8 +40,6 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import { Cancel, Submit } from "../Common/components/ButtonV2"; import useAppHistory from "../../Common/hooks/useAppHistory"; -import { celsiusToFahrenheit, fahrenheitToCelsius } from "../../Utils/utils"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -64,7 +62,7 @@ const initForm: any = { diastolic: null, pulse: null, resp: null, - tempInCelsius: false, + tempInCelcius: false, temperature: null, rhythm: "0", rhythm_detail: "", @@ -155,11 +153,6 @@ export const DailyRounds = (props: any) => { (i) => i.text === res.data.patient_category )?.id || "Comfort" : "Comfort", - tempInCelsius: getTemperaturePreference() === "C" ? true : false, - temperature: - getTemperaturePreference() === "C" - ? fahrenheitToCelsius(res.data.temperature) - : res.data.temperature, admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select", }; dispatch({ type: "set_form", form: data }); @@ -236,6 +229,16 @@ export const DailyRounds = (props: any) => { return !invalidForm; }; + const fahrenheitToCelcius = (x: any) => { + const t = (Number(x) - 32.0) * (5.0 / 9.0); + return String(t.toFixed(1)); + }; + + const celciusToFahrenheit = (x: any) => { + const t = (Number(x) * 9.0) / 5.0 + 32.0; + return String(t.toFixed(1)); + }; + const calculateMAP = (systolic: any, diastolic: any) => { let map = 0; if (systolic && diastolic) { @@ -296,8 +299,8 @@ export const DailyRounds = (props: any) => { : undefined, pulse: state.form.pulse, resp: Number(state.form.resp), - temperature: state.form.tempInCelsius - ? celsiusToFahrenheit(state.form.temperature) + temperature: state.form.tempInCelcius + ? celciusToFahrenheit(state.form.temperature) : state.form.temperature, rhythm: Number(state.form.rhythm) || 0, rhythm_detail: state.form.rhythm_detail, @@ -478,33 +481,17 @@ export const DailyRounds = (props: any) => { }; const toggleTemperature = () => { - const isCelsius = state.form.tempInCelsius; + const isCelcius = state.form.tempInCelcius; const temp = state.form.temperature; const form = { ...state.form }; - form.temperature = isCelsius - ? celsiusToFahrenheit(temp) - : fahrenheitToCelsius(temp); - form.tempInCelsius = !isCelsius; + form.temperature = isCelcius + ? celciusToFahrenheit(temp) + : fahrenheitToCelcius(temp); + form.tempInCelcius = !isCelcius; dispatch({ type: "set_form", form }); }; - function handleLocalTemperatureChange(e: any) { - if (e.key === "temperature") { - if (e.newValue === "F" && state.form.tempInCelsius) { - toggleTemperature(); - } else if (e.newValue === "C" && !state.form.tempInCelsius) { - toggleTemperature(); - } - } - } - useEffect(() => { - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, [state.form.temperature]); - if (isLoading) { return ; } @@ -811,7 +798,7 @@ export const DailyRounds = (props: any) => {
Temperature{" "} - {state.form.tempInCelsius + {state.form.tempInCelcius ? getStatus( 36.4, "Low", @@ -835,7 +822,7 @@ export const DailyRounds = (props: any) => { variant="standard" value={state.form.temperature} options={ - state.form.tempInCelsius + state.form.tempInCelcius ? generateOptions(35, 41, 0.1, 1) : generateOptions(95, 106, 0.1, 1) } @@ -863,7 +850,7 @@ export const DailyRounds = (props: any) => { > {" "} - {state.form.tempInCelsius ? "C" : "F"}{" "} + {state.form.tempInCelcius ? "C" : "F"}{" "}
diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 00deb0e734d..6f1d7c78195 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -1525,7 +1525,7 @@ export const FileUpload = (props: FileUploadProps) => { InputLabelProps={{ shrink: !!audioName }} value={audioName} disabled={uploadStarted} - onChange={(e: any) => { + onChange={(e: React.ChangeEvent) => { setAudioName(e.target.value); }} errors={audioFileError} @@ -1534,7 +1534,7 @@ export const FileUpload = (props: FileUploadProps) => { Please allow browser permission before you start speaking
{audiouploadStarted ? ( - + ) : (
{audioBlobExists && ( @@ -1542,9 +1542,7 @@ export const FileUpload = (props: FileUploadProps) => { { - deleteAudioBlob(); - }} + onClick={deleteAudioBlob} > Delete @@ -1558,12 +1556,7 @@ export const FileUpload = (props: FileUploadProps) => { /> {audioBlobExists && (
- { - handleAudioUpload(); - }} - className="w-full" - > + Save @@ -1598,7 +1591,7 @@ export const FileUpload = (props: FileUploadProps) => { {uploadStarted ? ( ) : ( -
+
{({ isAuthorized }) => isAuthorized ? ( @@ -1617,18 +1610,27 @@ export const FileUpload = (props: FileUploadProps) => { ) } - setModalOpenForCamera(true)}> - - Open Camera - - handleUpload({ status })} - > - - {t("upload")} - +
+ setModalOpenForCamera(true)} + > + + Open Camera + +
+ +
+ handleUpload({ status })} + > + + {t("upload")} + +
)} {file && ( diff --git a/src/Components/Patient/LegacyPatientVitalsCard.tsx b/src/Components/Patient/LegacyPatientVitalsCard.tsx index 5673870a837..867d1ebfe9a 100644 --- a/src/Components/Patient/LegacyPatientVitalsCard.tsx +++ b/src/Components/Patient/LegacyPatientVitalsCard.tsx @@ -1,17 +1,11 @@ import React, { ReactNode, useEffect, useRef, useState } from "react"; import { useDispatch } from "react-redux"; import { listAssetBeds, getPermittedFacility } from "../../Redux/actions"; -import { - celsiusToFahrenheit, - classNames, - fahrenheitToCelsius, -} from "../../Utils/utils"; +import { classNames } from "../../Utils/utils"; import { AssetData } from "../Assets/AssetTypes"; import ToolTip from "../Common/utils/Tooltip"; import { PatientModel } from "./models"; import Waveform, { WaveformType } from "./Waveform"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; -import { fahrenheitToCelcius } from "../CriticalCareRecording/HemodynamicParameters/CriticalCare__HemodynamicParametersEditor.bs"; export interface IPatientVitalsCardProps { facilityId?: string; @@ -54,68 +48,6 @@ export default function LegacyPatientVitalsCard({ const [wsUrl, setWsUrl] = useState(""); const [patientObservations, setPatientObservations] = React.useState(); const [stats, setStats] = React.useState(false); - const [temperatureUnit, setTemperatureUnit] = useState( - getTemperaturePreference() - ); - - const initialTemperature = () => { - if (patient?.last_consultation?.last_daily_round?.temperature) { - patient = { - ...patient, - last_consultation: { - ...patient?.last_consultation, - last_daily_round: { - ...patient?.last_consultation?.last_daily_round, - temperature: - temperatureUnit === "F" - ? patient?.last_consultation?.last_daily_round?.temperature - : fahrenheitToCelcius( - patient?.last_consultation?.last_daily_round?.temperature - ), - }, - }, - }; - } - }; - initialTemperature(); - - const handleTemperatureChange = (change: "C->F" | "F->C") => { - if (patient?.last_consultation?.last_daily_round?.temperature) { - patient = { - ...patient, - last_consultation: { - ...patient?.last_consultation, - last_daily_round: { - ...patient?.last_consultation?.last_daily_round, - temperature: - change === "C->F" - ? celsiusToFahrenheit( - patient?.last_consultation?.last_daily_round?.temperature - ) - : fahrenheitToCelsius( - patient?.last_consultation?.last_daily_round?.temperature - ), - }, - }, - }; - } - }; - - useEffect(() => { - function handleLocalTemperatureChange(e: any) { - if (e.key === "temperature") { - if (temperatureUnit === "C" && e.newValue === "F") - handleTemperatureChange("C->F"); - else if (temperatureUnit === "F" && e.newValue === "C") - handleTemperatureChange("F->C"); - setTemperatureUnit(e.newValue); - } - } - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, []); useEffect(() => { const fetchFacility = async () => { @@ -247,9 +179,7 @@ export default function LegacyPatientVitalsCard({ //waveformDefaultSpace: true }, { - label: shrinked - ? `Temp. (ยฐ${temperatureUnit})` - : `Temperature (ยฐ${temperatureUnit})`, + label: shrinked ? "Temp. (ยฐF)" : "Temperature (ยฐF)", liveKey: "body-temperature1", vitalKey: "temperature", }, diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index aa52650c266..fe00c0f1c75 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -29,12 +29,12 @@ import { ExportMenu } from "../Common/Export"; import FacilitiesSelectDialogue from "../ExternalResult/FacilitiesSelectDialogue"; import { FieldChangeEvent } from "../Form/FormFields/Utils"; import FilterBadge from "../../CAREUI/display/FilterBadge"; -import NavTabs from "../Common/NavTabs"; import PatientFilter from "./PatientFilter"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; import RecordMeta from "../../CAREUI/display/RecordMeta"; import SearchInput from "../Form/SearchInput"; import SortDropdownMenu from "../Common/SortDropdown"; +import SwitchTabs from "../Common/components/SwitchTabs"; import SwipeableViews from "react-swipeable-views"; import { Tooltip } from "@material-ui/core"; import loadable from "@loadable/component"; @@ -111,7 +111,7 @@ export const PatientManager = () => { const setPhoneNum = (phone_number: string) => { setPhoneNumber(phone_number); - if (phone_number.length === 15) { + if (phone_number.length >= 13) { setPhoneNumberError(""); updateQuery({ phone_number }); return; @@ -128,7 +128,7 @@ export const PatientManager = () => { const setEmergencyPhoneNum = (emergency_phone_number: string) => { setEmergencyPhoneNumber(emergency_phone_number); - if (emergency_phone_number.length === 15) { + if (emergency_phone_number.length >= 13) { setEmergencyPhoneNumberError(""); updateQuery({ emergency_phone_number }); return; @@ -729,30 +729,46 @@ export const PatientManager = () => { }} />
- -
- {showDoctorConnect && ( - { - setShowDoctors(true); - }} - > - -

Doctor Connect

-
- )} +
+ { qParams.facility ? navigate(`/facility/${qParams.facility}/patient`) : setShowDialog(true); }} + className="w-full lg:w-fit" >

Add Patient Details

+
+
+ updateQuery({ is_active: "True" })} + onClickTab2={() => updateQuery({ is_active: "False" })} + activeTab={tabValue ? true : false} + /> + {showDoctorConnect && ( + { + setShowDoctors(true); + }} + > + +

Doctor Connect

+
+ )} + advancedFilter.setShow(true)} /> { count={totalCount} loading={isLoading} icon={"user-injured"} - containerClass="pb-8" + containerClass="pb-10" />
{/*
@@ -941,14 +957,6 @@ export const PatientManager = () => {
- updateQuery({ is_active: tab ? "False" : "True" })} - options={[ - { value: 0, label: "Live" }, - { value: 1, label: "Discharged" }, - ]} - active={tabValue} - />
{managePatients}
diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index f48a1a95b7f..c3bc1009a40 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -1022,7 +1022,10 @@ export const PatientHome = (props: any) => {
-
+
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 919a27ef2d6..da32db60872 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -105,8 +105,8 @@ const initForm: any = { name: "", age: "", gender: "", - phone_number: "", - emergency_phone_number: "", + phone_number: "+91", + emergency_phone_number: null, blood_group: "", disease_status: diseaseStatus[2], is_declared_positive: "false", @@ -362,7 +362,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchDistricts(res.data.district_object.state), fetchLocalBody(res.data.district), fetchWards(res.data.local_body), - duplicateCheck("+91" + res.data.mobile_number), + duplicateCheck(res.data.mobile_number), ]); setShowImport(false); @@ -2120,6 +2120,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, ]) } + data-testid="add-insurance-button" > Add Insurance Details diff --git a/src/Components/Patient/SampleDetails.tsx b/src/Components/Patient/SampleDetails.tsx index 9dcb7d0c50f..79a75141896 100644 --- a/src/Components/Patient/SampleDetails.tsx +++ b/src/Components/Patient/SampleDetails.tsx @@ -1,4 +1,3 @@ -import { Card, CardContent, Button } from "@material-ui/core"; import loadable from "@loadable/component"; import { useCallback, useState } from "react"; import { useDispatch } from "react-redux"; @@ -10,16 +9,17 @@ import { navigate } from "raviger"; import { GENDER_TYPES, TEST_TYPE_CHOICES } from "../../Common/constants"; import _ from "lodash"; import { formatDate } from "../../Utils/utils"; +import Card from "../../CAREUI/display/Card"; +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface SampleDetailsProps { id: number; } -export const SampleDetails = (props: SampleDetailsProps) => { - const { id } = props; +export const SampleDetails = ({ id }: SampleDetailsProps) => { const dispatch: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [sampleDetails, setSampleDetails] = useState({}); @@ -46,7 +46,7 @@ export const SampleDetails = (props: SampleDetailsProps) => { }, [dispatch, fetchData, id] ); - const yesornoBadge = (param: any) => + const yesOrNoBadge = (param: any) => param ? ( Yes ) : ( @@ -180,13 +180,13 @@ export const SampleDetails = (props: SampleDetailsProps) => { Contact with confirmed carrier:{" "} - {yesornoBadge(patientData?.contact_with_confirmed_carrier)} + {yesOrNoBadge(patientData?.contact_with_confirmed_carrier)}
Contact with suspected carrier:{" "} - {yesornoBadge(patientData?.contact_with_suspected_carrier)} + {yesOrNoBadge(patientData?.contact_with_suspected_carrier)}
{patientData?.estimated_contact_date && (
@@ -200,13 +200,13 @@ export const SampleDetails = (props: SampleDetailsProps) => { Has SARI (Severe Acute Respiratory illness)?:{" "} - {yesornoBadge(patientData?.has_SARI)} + {yesOrNoBadge(patientData?.has_SARI)}
Domestic/international Travel (within last 28 days):{" "} - {yesornoBadge(patientData?.past_travel)} + {yesOrNoBadge(patientData?.past_travel)}
{patientData?.countries_travelled && !!patientData?.countries_travelled.length && ( @@ -257,31 +257,25 @@ export const SampleDetails = (props: SampleDetailsProps) => { const renderFlow = (flow: FlowModel) => { return ( - - -
-
- Status: {" "} - {_.startCase(_.camelCase(flow.status))} -
-
- Label:{" "} - {_.capitalize(flow.notes)} -
-
- - Created On : - {" "} - {flow.created_date ? formatDate(flow.created_date) : "-"} -
-
- - Modified on: - {" "} - {flow.modified_date ? formatDate(flow.modified_date) : "-"} -
+ +
+
+ Status: {" "} + {_.startCase(_.camelCase(flow.status))} +
+
+ Label:{" "} + {_.capitalize(flow.notes)} +
+
+ Created On :{" "} + {flow.created_date ? formatDate(flow.created_date) : "-"} +
+
+ Modified on:{" "} + {flow.modified_date ? formatDate(flow.modified_date) : "-"}
- +
); }; @@ -291,162 +285,153 @@ export const SampleDetails = (props: SampleDetailsProps) => { } return ( -
- - {sampleDetails.patient && ( -
- -
- )} - - -
-
- Status: - {_.startCase(_.camelCase(sampleDetails.status))} -
-
- Result: - {_.startCase(_.camelCase(sampleDetails.result))} -
-
- Patient: - {sampleDetails.patient_name} -
- {sampleDetails.facility_object && ( -
- - Facility:{" "} - - {sampleDetails.facility_object.name} -
- )} -
- Tested on: - {sampleDetails.date_of_result - ? formatDate(sampleDetails.date_of_result) - : "-"} -
+ + + ICMR Specimen Referral Form + +
+ ) + } + > + +
+
+ Status: + {_.startCase(_.camelCase(sampleDetails.status))} +
+
+ Result: + {_.startCase(_.camelCase(sampleDetails.result))} +
+
+ Patient: + {sampleDetails.patient_name} +
+ {sampleDetails.facility_object && (
- Result on: - {sampleDetails.date_of_result - ? formatDate(sampleDetails.date_of_result) - : "-"} + Facility: + {sampleDetails.facility_object.name}
- {sampleDetails.fast_track && ( -
- - Fast track testing reason:{" "} - - {sampleDetails.fast_track} -
- )} - {sampleDetails.doctor_name && ( -
- - Doctor's Name:{" "} - - {_.startCase(_.camelCase(sampleDetails.doctor_name))} -
- )} - {sampleDetails.diagnosis && ( -
- - Diagnosis:{" "} - - {sampleDetails.diagnosis} -
- )} - {sampleDetails.diff_diagnosis && ( -
- - Differential diagnosis:{" "} - - {sampleDetails.diff_diagnosis} -
- )} - {sampleDetails.etiology_identified && ( -
- - Etiology identified:{" "} - - {sampleDetails.etiology_identified} -
- )} -
+ )} +
+ Tested on: + {sampleDetails.date_of_result + ? formatDate(sampleDetails.date_of_result) + : "-"} +
+
+ Result on: + {sampleDetails.date_of_result + ? formatDate(sampleDetails.date_of_result) + : "-"} +
+ {sampleDetails.fast_track && ( +
- Is Atypical presentation{" "} + Fast track testing reason:{" "} - {yesornoBadge(sampleDetails.is_atypical_presentation)} + {sampleDetails.fast_track}
-
+ )} + {sampleDetails.doctor_name && ( +
- Is unusual course{" "} + Doctor's Name:{" "} - {yesornoBadge(sampleDetails.is_unusual_course)} + {_.startCase(_.camelCase(sampleDetails.doctor_name))}
- {sampleDetails.atypical_presentation && ( -
- - Atypical presentation details:{" "} - - {sampleDetails.atypical_presentation} -
- )} -
- - SARI - Severe Acute Respiratory illness{" "} - - {yesornoBadge(sampleDetails.has_sari)} + )} + {sampleDetails.diagnosis && ( +
+ Diagnosis: + {sampleDetails.diagnosis}
-
+ )} + {sampleDetails.diff_diagnosis && ( +
- ARI - Acute Respiratory illness{" "} + Differential diagnosis:{" "} - {yesornoBadge(sampleDetails.has_ari)} + {sampleDetails.diff_diagnosis}
-
+ )} + {sampleDetails.etiology_identified && ( +
- Contact with confirmed carrier{" "} + Etiology identified:{" "} - {yesornoBadge(sampleDetails.patient_has_confirmed_contact)} + {sampleDetails.etiology_identified}
-
+ )} +
+ + Is Atypical presentation{" "} + + {yesOrNoBadge(sampleDetails.is_atypical_presentation)} +
+
+ + Is unusual course{" "} + + {yesOrNoBadge(sampleDetails.is_unusual_course)} +
+ {sampleDetails.atypical_presentation && ( +
- Contact with suspected carrier{" "} + Atypical presentation details:{" "} - {yesornoBadge(sampleDetails.patient_has_suspected_contact)} + {sampleDetails.atypical_presentation}
- {sampleDetails.patient_travel_history && - sampleDetails.patient_travel_history.length !== 0 && ( -
- - Countries travelled:{" "} - - {JSON.parse(sampleDetails.patient_travel_history).join(", ")} -
- )} - {sampleDetails.sample_type && ( + )} +
+ + SARI - Severe Acute Respiratory illness{" "} + + {yesOrNoBadge(sampleDetails.has_sari)} +
+
+ + ARI - Acute Respiratory illness{" "} + + {yesOrNoBadge(sampleDetails.has_ari)} +
+
+ + Contact with confirmed carrier{" "} + + {yesOrNoBadge(sampleDetails.patient_has_confirmed_contact)} +
+
+ + Contact with suspected carrier{" "} + + {yesOrNoBadge(sampleDetails.patient_has_suspected_contact)} +
+ {sampleDetails.patient_travel_history && + sampleDetails.patient_travel_history.length !== 0 && (
- Sample Type:{" "} + Countries travelled:{" "} - {_.startCase(_.camelCase(sampleDetails.sample_type))} + {JSON.parse(sampleDetails.patient_travel_history).join(", ")}
)} -
- + {sampleDetails.sample_type && ( +
+ + Sample Type:{" "} + + {_.startCase(_.camelCase(sampleDetails.sample_type))} +
+ )} +
@@ -454,13 +439,11 @@ export const SampleDetails = (props: SampleDetailsProps) => { {showPatientCard(sampleDetails.patient_object)}
- - {sampleDetails.flow && - sampleDetails.flow.map((flow: FlowModel) => renderFlow(flow))} +
+

Sample Test History

+ {sampleDetails.flow && + sampleDetails.flow.map((flow: FlowModel) => renderFlow(flow))} +
{ unspecified={true} audio={true} /> -
+ ); }; diff --git a/src/Components/Patient/SampleFilters.tsx b/src/Components/Patient/SampleFilters.tsx index a7be9852642..db22e54ac80 100644 --- a/src/Components/Patient/SampleFilters.tsx +++ b/src/Components/Patient/SampleFilters.tsx @@ -1,5 +1,4 @@ import { useState, useEffect } from "react"; -import { LegacySelectField } from "../Common/HelperInputFields"; import { SAMPLE_TEST_STATUS, SAMPLE_TEST_RESULT, @@ -10,9 +9,12 @@ import { FacilitySelect } from "../Common/FacilitySelect"; import { FacilityModel } from "../Facility/models"; import { getAnyFacility } from "../../Redux/actions"; import { useDispatch } from "react-redux"; -import { CircularProgress } from "@material-ui/core"; import useMergeState from "../../Common/hooks/useMergeState"; import FiltersSlideover from "../../CAREUI/interactive/FiltersSlideover"; +import CircularProgress from "../Common/components/CircularProgress"; +import { FieldLabel } from "../Form/FormFields/FormField"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { FieldChangeEvent } from "../Form/FormFields/Utils"; const clearFilterState = { status: "", @@ -36,13 +38,8 @@ export default function UserFilter(props: any) { const [isFacilityLoading, setFacilityLoading] = useState(false); const dispatch: any = useDispatch(); - const handleChange = (event: any) => { - const { name, value } = event.target; - - const filterData: any = { ...filterState }; - filterData[name] = value; - - setFilterState(filterData); + const handleChange = ({ name, value }: FieldChangeEvent) => { + setFilterState({ ...filterState, [name]: value }); }; const applyFilter = () => { @@ -70,6 +67,8 @@ export default function UserFilter(props: any) { fetchData(); }, [dispatch]); + console.log(filterState.sample_type); + return ( -
-
Status
- { - return { id, text: text.replaceAll("_", " ") }; - }), - ]} - onChange={handleChange} - errors="" - /> -
+ { + return { id, text: text.replaceAll("_", " ") }; + })} + optionValue={(option) => option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Result
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Sample Test Type
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + />
- Facility -
+ Facility +
{isFacilityLoading ? ( - + ) : ( )} diff --git a/src/Components/Patient/SampleViewAdmin.tsx b/src/Components/Patient/SampleViewAdmin.tsx index b7105ef2fd5..2f1204a34c4 100644 --- a/src/Components/Patient/SampleViewAdmin.tsx +++ b/src/Components/Patient/SampleViewAdmin.tsx @@ -401,7 +401,7 @@ export default function SampleViewAdmin() { "Sample Test Type", "sample_type", SAMPLE_TYPE_CHOICES.find( - (type) => type.id.toString() === qParams.sample_type + (type) => type.id === qParams.sample_type )?.text || "" ), value("Facility", "facility", facilityName), diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index e863ae3fd84..c4bb347cfcb 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -314,7 +314,7 @@ export const ShiftCreate = (props: patientShiftProps) => { label="Contact person phone" name="refering_facility_contact_number" required - onlyIndia + disableCountry value={state.form.refering_facility_contact_number} onChange={handleFormFieldChange} error={state.errors.refering_facility_contact_number} diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index 9ed633feed0..3da59b9ba4a 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -260,7 +260,6 @@ export interface DailyRoundsModel { pulse?: number; resp?: number; temperature?: string; - temperatureUnit?: "C" | "F"; temperature_measured_at?: string; physical_examination_info?: string; other_details?: string; diff --git a/src/Components/Resource/ListView.tsx b/src/Components/Resource/ListView.tsx index 222bce4f3a0..15c5bd4baba 100644 --- a/src/Components/Resource/ListView.tsx +++ b/src/Components/Resource/ListView.tsx @@ -13,6 +13,10 @@ import BadgesList from "./BadgesList"; import { formatDate } from "../../Utils/utils"; import useFilters from "../../Common/hooks/useFilters"; import { ExportButton } from "../Common/Export"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { useTranslation } from "react-i18next"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -24,6 +28,7 @@ export default function ListView() { const [data, setData] = useState([]); const [totalCount, setTotalCount] = useState(0); const [isLoading, setIsLoading] = useState(false); + const { t } = useTranslation(); const onBoardViewBtnClick = () => navigate("/resource/board-view", { query: qParams }); @@ -199,28 +204,13 @@ export default function ListView() { />
-
-
- -
-
- -
+
+ + + {t("board_view")} + + + advancedFilter.setShow(true)} />
diff --git a/src/Components/Resource/ResourceBoard.tsx b/src/Components/Resource/ResourceBoard.tsx index 9d9f53bd0eb..3f42e82e2e0 100644 --- a/src/Components/Resource/ResourceBoard.tsx +++ b/src/Components/Resource/ResourceBoard.tsx @@ -4,15 +4,12 @@ import { listResourceRequests, downloadResourceRequests, } from "../../Redux/actions"; -import CircularProgress from "@material-ui/core/CircularProgress"; import { navigate } from "raviger"; import moment from "moment"; import { classNames } from "../../Utils/utils"; import { useDrag, useDrop } from "react-dnd"; import { formatDate } from "../../Utils/utils"; -import ButtonV2 from "../Common/components/ButtonV2"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import CSVLink from "../Common/CSVLink"; +import { ExportButton } from "../Common/Export"; const limit = 14; @@ -22,8 +19,6 @@ interface boardProps { formatFilter: any; } -const now = moment().format("DD-MM-YYYY:hh:mm:ss"); - const renderBoardTitle = (board: string) => board; const reduceLoading = (action: string, current: any) => { @@ -163,10 +158,8 @@ export default function ResourceBoard({ }: boardProps) { const dispatch: any = useDispatch(); const [data, setData] = useState([]); - const [downloadFile, setDownloadFile] = useState(""); const [totalCount, setTotalCount] = useState(); const [currentPage, setCurrentPage] = useState(1); - const [downloadLoading, setDownloadLoading] = useState(false); const [isLoading, setIsLoading] = useState({ board: false, more: false }); const [{ isOver }, drop] = useDrop(() => ({ accept: "resource-card", @@ -195,21 +188,6 @@ export default function ResourceBoard({ }); }; - const triggerDownload = async () => { - // while is getting ready - setDownloadLoading(true); - const res = await dispatch( - downloadResourceRequests({ - ...formatFilter({ ...filterProp, status: board }), - csv: 1, - }) - ); - // file ready to download - setDownloadLoading(false); - setDownloadFile(res.data); - document.getElementById(`resourceRequests-${board}`)?.click(); - }; - useEffect(() => { fetchData(); }, [ @@ -264,22 +242,15 @@ export default function ResourceBoard({

{renderBoardTitle(board)}{" "} - {downloadLoading ? ( - - ) : ( - - - - Download - - - )} + + downloadResourceRequests({ + ...formatFilter({ ...filterProp, status: board }), + csv: 1, + }) + } + filenamePrefix={`resource_requests_${board}`} + />

{totalCount || "0"} @@ -321,11 +292,6 @@ export default function ResourceBoard({ ))}
-
); } diff --git a/src/Components/Resource/ResourceBoardView.tsx b/src/Components/Resource/ResourceBoardView.tsx index 616c23b38fb..e3f147f41b6 100644 --- a/src/Components/Resource/ResourceBoardView.tsx +++ b/src/Components/Resource/ResourceBoardView.tsx @@ -10,6 +10,11 @@ import BadgesList from "./BadgesList"; import { formatFilter } from "./Commons"; import useFilters from "../../Common/hooks/useFilters"; import { ExportButton } from "../Common/Export"; +import SwitchTabs from "../Common/components/SwitchTabs"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { useTranslation } from "react-i18next"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -25,6 +30,7 @@ export default function BoardView() { // eslint-disable-next-line const [isLoading, setIsLoading] = useState(false); const appliedFilters = formatFilter(qParams); + const { t } = useTranslation(); const onListViewBtnClick = () => { navigate("/resource/list-view", { query: qParams }); @@ -33,7 +39,7 @@ export default function BoardView() { return (
-
+
-
-
- - -
-
- - + />
diff --git a/src/Components/Resource/ResourceCreate.tsx b/src/Components/Resource/ResourceCreate.tsx index 14b0a593599..2f1203bdc91 100644 --- a/src/Components/Resource/ResourceCreate.tsx +++ b/src/Components/Resource/ResourceCreate.tsx @@ -244,7 +244,7 @@ export default function ResourceCreate(props: resourceProps) { label={t("contact_phone")} name="refering_facility_contact_number" required - onlyIndia + disableCountry value={state.form.refering_facility_contact_number} onChange={handleFormFieldChange} error={state.errors.refering_facility_contact_number} diff --git a/src/Components/Shifting/BoardView.tsx b/src/Components/Shifting/BoardView.tsx index 79c85fb7572..d4d95d93e70 100644 --- a/src/Components/Shifting/BoardView.tsx +++ b/src/Components/Shifting/BoardView.tsx @@ -17,6 +17,10 @@ import useFilters from "../../Common/hooks/useFilters"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import withScrolling from "react-dnd-scrolling"; +import ButtonV2 from "../Common/components/ButtonV2"; +import SwitchTabs from "../Common/components/SwitchTabs"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -55,7 +59,7 @@ export default function BoardView() { return (
-
+
-
+
updateQuery({ [e.name]: e.value })} placeholder={t("search_patient")} /> -
- - -
-
- - + />
diff --git a/src/Components/Shifting/ListFilter.tsx b/src/Components/Shifting/ListFilter.tsx index 099926f78e4..ed6baa7d32d 100644 --- a/src/Components/Shifting/ListFilter.tsx +++ b/src/Components/Shifting/ListFilter.tsx @@ -18,7 +18,6 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import FiltersSlideover from "../../CAREUI/interactive/FiltersSlideover"; import { LegacySelectField } from "../Common/HelperInputFields"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; -import { UserSelect } from "../Common/UserSelect2"; import moment from "moment"; import { navigate } from "raviger"; import parsePhoneNumberFromString from "libphonenumber-js"; @@ -26,6 +25,7 @@ import useConfig from "../../Common/hooks/useConfig"; import { useDispatch } from "react-redux"; import useMergeState from "../../Common/hooks/useMergeState"; import { useTranslation } from "react-i18next"; +import UserAutocompleteFormField from "../Common/UserAutocompleteFormField"; const clearFilterState = { orgin_facility: "", @@ -57,7 +57,6 @@ export default function ListFilter(props: any) { const [isOriginLoading, setOriginLoading] = useState(false); const [isShiftingLoading, setShiftingLoading] = useState(false); const [isAssignedLoading, setAssignedLoading] = useState(false); - const [isAssignedUserLoading, setAssignedUserLoading] = useState(false); const { t } = useTranslation(); const shiftStatusOptions = ( @@ -143,16 +142,13 @@ export default function ListFilter(props: any) { useEffect(() => { async function fetchData() { if (filter.assigned_to) { - setAssignedUserLoading(true); const res = await dispatch(getUserList({ id: filter.assigned_to })); - if (res && res.data && res.data.count) { setFilterState({ ...filterState, assigned_user_ref: res.data.results[0], }); } - setAssignedUserLoading(false); } } fetchData(); @@ -345,23 +341,16 @@ export default function ListFilter(props: any) {
-
- {t("assigned_to")} - {isAssignedUserLoading ? ( - - ) : ( - setAssignedUser(obj)} - className="shifting-page-filter-dropdown" - errors={""} - /> - )} -
+ setAssignedUser(value)} + errorClassName="hidden" + /> -
+
{t("ordering")} import("../Common/Loading")); @@ -302,30 +304,20 @@ export default function ListView() {
{/* dummy div to align space as per board view */}
-
-
- -
-
- -
+
+ + navigate("/shifting/board-view", { query: qParams }) + } + > + + {t("board_view")} + + + advancedFilter.setShow(true)} + />
} diff --git a/src/Components/Shifting/ShiftingBoard.tsx b/src/Components/Shifting/ShiftingBoard.tsx index d0ad71beb48..cdd5b8dce65 100644 --- a/src/Components/Shifting/ShiftingBoard.tsx +++ b/src/Components/Shifting/ShiftingBoard.tsx @@ -8,15 +8,13 @@ import { import { useDrag, useDrop } from "react-dnd"; import ButtonV2 from "../Common/components/ButtonV2"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import CircularProgress from "../Common/components/CircularProgress"; import ConfirmDialogV2 from "../Common/ConfirmDialogV2"; import moment from "moment"; import { navigate } from "raviger"; import useConfig from "../../Common/hooks/useConfig"; import { useDispatch, useSelector } from "react-redux"; import { useTranslation } from "react-i18next"; -import CSVLink from "../Common/CSVLink"; +import { ExportButton } from "../Common/Export"; const limit = 14; @@ -27,8 +25,6 @@ interface boardProps { formatFilter: any; } -const now = moment().format("DD-MM-YYYY:hh:mm:ss"); - const reduceLoading = (action: string, current: any) => { switch (action) { case "MORE": @@ -259,11 +255,9 @@ export default function ShiftingBoard({ }: boardProps) { const dispatch: any = useDispatch(); const [data, setData] = useState([]); - const [downloadFile, setDownloadFile] = useState(""); const [totalCount, setTotalCount] = useState(); const [currentPage, setCurrentPage] = useState(1); const [isLoading, setIsLoading] = useState({ board: false, more: false }); - const [downloadLoading, setDownloadLoading] = useState(false); const [{ isOver }, drop] = useDrop(() => ({ accept: "shift-card", drop: (item: any) => { @@ -288,21 +282,6 @@ export default function ShiftingBoard({ }); }; - const triggerDownload = async () => { - // while is getting ready - setDownloadLoading(true); - const res = await dispatch( - downloadShiftRequests({ - ...formatFilter({ ...filterProp, status: board }), - csv: 1, - }) - ); - // file ready to download - setDownloadLoading(false); - setDownloadFile(res.data); - document.getElementById(`shiftRequests-${board}`)?.click(); - }; - useEffect(() => { fetchData(); }, [ @@ -367,22 +346,15 @@ export default function ShiftingBoard({

{title || board}{" "} - {downloadLoading ? ( - - ) : ( - - - - {t("download")} - - - )} + + downloadShiftRequests({ + ...formatFilter({ ...filterProp, status: board }), + csv: 1, + }) + } + filenamePrefix={`shift_requests_${board}`} + />

{totalCount || "0"} @@ -424,11 +396,6 @@ export default function ShiftingBoard({ ))}
-
); } diff --git a/src/Components/Users/SkillsSlideOver.tsx b/src/Components/Users/SkillsSlideOver.tsx index 785a2513a18..2a1dfbcbfde 100644 --- a/src/Components/Users/SkillsSlideOver.tsx +++ b/src/Components/Users/SkillsSlideOver.tsx @@ -94,8 +94,8 @@ export default ({ show, setShow, username }: IProps) => { setDeleteSkill(null)} - handleOk={() => removeSkill(username, deleteSkill.id)} + onCancel={() => setDeleteSkill(null)} + onSubmit={() => removeSkill(username, deleteSkill.id)} /> )} void; - handleOk: () => void; + onCancel: () => void; + onSubmit: () => void; } -const UnlinkSkillDialog = (props: ConfirmDialogProps) => { - const { skillName, userName, handleCancel, handleOk } = props; - - const [disable, setDisable] = useState(false); +export default function UnlinkSkillDialog(props: Props) { + const [disabled, setDisabled] = useState(false); const handleSubmit = () => { - handleOk(); - setDisable(true); + props.onSubmit(); + setDisabled(true); }; + return ( - - -
- -
- Are you sure you want to unlink the skill{" "} - {skillName} from user {userName} - ? the user will not have the skill associated anymore. -
-
-
-
- - - - -
+ + Are you sure you want to unlink the skill{" "} + {props.skillName} from user{" "} + {props.userName}? the user will not have the skill + associated anymore. + + } + > ); -}; - -export default UnlinkSkillDialog; +} diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index fd22eddf470..3bad31a865d 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -1,4 +1,3 @@ -import { Card, CardContent, CircularProgress } from "@material-ui/core"; import loadable from "@loadable/component"; import { Link, navigate } from "raviger"; import { parsePhoneNumberFromString } from "libphonenumber-js/max"; @@ -39,9 +38,11 @@ import Checkbox from "../Common/components/CheckBox"; import DateFormField from "../Form/FormFields/DateFormField"; import { FieldLabel } from "../Form/FormFields/FormField"; import useAppHistory from "../../Common/hooks/useAppHistory"; +import Page from "../Common/components/Page"; +import Card from "../../CAREUI/display/Card"; +import CircularProgress from "../Common/components/CircularProgress"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface UserProps { userId?: number; @@ -86,8 +87,8 @@ const initForm: UserForm = { first_name: "", last_name: "", email: "", - phone_number: "", - alt_phone_number: "", + phone_number: "+91", + alt_phone_number: "+91", age: 0, date_of_birth: null, state: 0, @@ -632,322 +633,315 @@ export const UserAdd = (props: UserProps) => { }; return ( -
- -  Need Help? - - } - justifyContents="justify-between" - backUrl="/users" - /> - - - -
handleSubmit(e)}> -
-
- Facilities - -
- - o.role + ((o.readOnly && " (Read Only)") || "") - } - optionValue={(o) => o.id} - /> - - {state.form.user_type === "Doctor" && ( - <> - - - - - - - )} - - option.name} - optionValue={(option) => option.id} - onChange={handleFieldChange} + +  Need Help? + + } + backUrl="/users" + > + + handleSubmit(e)}> +
+
+ Facilities + - -
- + + o.role + ((o.readOnly && " (Read Only)") || "") + } + optionValue={(o) => o.id} + /> + + {state.form.user_type === "Doctor" && ( + <> + - -
- - -
{ - handleFieldChange(e); - setUsernameInput(e.value); - }} - onFocus={() => setUsernameInputInFocus(true)} - onBlur={() => { - setUsernameInputInFocus(false); - }} + min={0} + type="number" + label="Years of experience" + placeholder="Years of experience of the Doctor" /> - {usernameInputInFocus && ( -
-
- {usernameExists !== userExistsEnums.idle && ( - <> - {usernameExists === userExistsEnums.checking ? ( - - checking... - - ) : ( - <> - {usernameExists === userExistsEnums.exists ? ( -
- {" "} - - Username is not available - -
- ) : ( -
- {" "} - - Username is available - -
- )} - - )} - - )} -
-
- {validateRule( - state.form.username?.length >= 2, - "Username should be atleast 2 characters long" - )} -
-
- {validateRule( - /[^.@+_-]/.test( - state.form.username[state.form.username?.length - 1] - ), - "Username can't end with ^ . @ + _ -" - )} -
-
- )} -
- - -
setPasswordInputInFocus(true)} - onBlur={() => setPasswordInputInFocus(false)} + label="Medical Council Registration" + placeholder="Doctor's medical council registration number" /> - {passwordInputInFocus && ( -
- {validateRule( - state.form.password?.length >= 8, - "Password should be atleast 8 characters long" - )} - {validateRule( - state.form.password !== state.form.password.toUpperCase(), - "Password should contain at least 1 lowercase letter" + + )} + + option.name} + optionValue={(option) => option.id} + onChange={handleFieldChange} + /> + +
+ + +
+ + + +
+ { + handleFieldChange(e); + setUsernameInput(e.value); + }} + onFocus={() => setUsernameInputInFocus(true)} + onBlur={() => { + setUsernameInputInFocus(false); + }} + /> + {usernameInputInFocus && ( +
+
+ {usernameExists !== userExistsEnums.idle && ( + <> + {usernameExists === userExistsEnums.checking ? ( + + checking... + + ) : ( + <> + {usernameExists === userExistsEnums.exists ? ( +
+ {" "} + + Username is not available + +
+ ) : ( +
+ {" "} + + Username is available + +
+ )} + + )} + )} +
+
{validateRule( - state.form.password !== state.form.password.toLowerCase(), - "Password should contain at least 1 uppercase letter" + state.form.username?.length >= 2, + "Username should be atleast 2 characters long" )} +
+
{validateRule( - /\d/.test(state.form.password), - "Password should contain at least 1 number" + /[^.@+_-]/.test( + state.form.username[state.form.username?.length - 1] + ), + "Username can't end with ^ . @ + _ -" )}
- )} -
-
- setConfirmPasswordInputInFocus(true)} - onBlur={() => setConfirmPasswordInputInFocus(false)} - /> - {confirmPasswordInputInFocus && - state.form.c_password.length > 0 && - validateRule( - state.form.c_password === state.form.password, - "Confirm password should match the entered password" - )} -
+
+ )} +
+ + + +
setPasswordInputInFocus(true)} + onBlur={() => setPasswordInputInFocus(false)} /> + {passwordInputInFocus && ( +
+ {validateRule( + state.form.password?.length >= 8, + "Password should be atleast 8 characters long" + )} + {validateRule( + state.form.password !== state.form.password.toUpperCase(), + "Password should contain at least 1 lowercase letter" + )} + {validateRule( + state.form.password !== state.form.password.toLowerCase(), + "Password should contain at least 1 uppercase letter" + )} + {validateRule( + /\d/.test(state.form.password), + "Password should contain at least 1 number" + )} +
+ )} +
+
setConfirmPasswordInputInFocus(true)} + onBlur={() => setConfirmPasswordInputInFocus(false)} /> - 0 && + validateRule( + state.form.c_password === state.form.password, + "Confirm password should match the entered password" + )} +
+ + + + o.text} + optionValue={(o) => o.text} + /> + + {isStateLoading ? ( + + ) : ( + o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchDistricts(e.value); + }} /> + )} + + {isDistrictLoading ? ( + + ) : ( o.text} - optionValue={(o) => o.text} + placeholder="Choose District" + options={districts} + optionLabel={(o) => o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchLocalBody(e.value); + }} /> + )} - {isStateLoading ? ( - - ) : ( - o.name} - optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchDistricts(e.value); - }} - /> - )} - - {isDistrictLoading ? ( - + {showLocalbody && + (isLocalbodyLoading ? ( + ) : ( o.name} optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchLocalBody(e.value); - }} /> - )} - - {showLocalbody && - (isLocalbodyLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - /> - - ))} -
-
- goBack()} /> - -
- - + ))} +
+
+ goBack()} /> + +
+ -
+
); }; diff --git a/src/Components/Users/UserFilter.tsx b/src/Components/Users/UserFilter.tsx index 57fe365935f..1fee0624b99 100644 --- a/src/Components/Users/UserFilter.tsx +++ b/src/Components/Users/UserFilter.tsx @@ -23,8 +23,8 @@ export default function UserFilter(props: any) { const [filterState, setFilterState] = useMergeState({ first_name: filter.first_name || "", last_name: filter.last_name || "", - phone_number: filter.phone_number || "", - alt_phone_number: filter.alt_phone_number || "", + phone_number: filter.phone_number || "+91", + alt_phone_number: filter.alt_phone_number || "+91", user_type: filter.user_type || "", district_id: filter.district_id || "", district_ref: null, @@ -33,8 +33,8 @@ export default function UserFilter(props: any) { const clearFilterState = { first_name: "", last_name: "", - phone_number: "", - alt_phone_number: "", + phone_number: "+91", + alt_phone_number: "+91", user_type: "", district_id: "", district_ref: null, @@ -59,8 +59,9 @@ export default function UserFilter(props: any) { const data = { first_name: first_name || "", last_name: last_name || "", - phone_number: parsePhoneNumberForFilterParam(phone_number), - alt_phone_number: parsePhoneNumberForFilterParam(alt_phone_number), + phone_number: parsePhoneNumberForFilterParam(phone_number) || "+91", + alt_phone_number: + parsePhoneNumberForFilterParam(alt_phone_number) || "+91", user_type: user_type || "", district_id: district_id || "", }; diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 79ed0b5de1f..e647c9dbfb4 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -23,7 +23,6 @@ import { SelectFormField } from "../Form/FormFields/SelectFormField"; import moment from "moment"; import { SkillModel, SkillObjectModel } from "../Users/models"; import UpdatableApp, { checkForUpdate } from "../Common/UpdatableApp"; -import { TemperatureSelector } from "../Common/TemperatureSelector"; const Loading = loadable(() => import("../Common/Loading")); @@ -708,21 +707,6 @@ export default function UserProfile() {
-
-
-
-

- Temperature Unit -

-

- Set your temperature unit preference -

-
-
-
- -
-
diff --git a/src/Components/Users/models.tsx b/src/Components/Users/models.tsx index fd5f24c2736..6f26ec8cc93 100644 --- a/src/Components/Users/models.tsx +++ b/src/Components/Users/models.tsx @@ -2,7 +2,7 @@ interface HomeFacilityObjectModel { id?: string; name?: string; } -export interface UserModel { +export type UserModel = { id?: number; username?: string; first_name?: string; @@ -23,7 +23,7 @@ export interface UserModel { doctor_qualification?: string; doctor_experience_commenced_on?: string; doctor_medical_council_registration?: string; -} +}; export interface SkillObjectModel { id: string; diff --git a/src/Utils/VoiceRecorder.tsx b/src/Utils/VoiceRecorder.tsx index fdf45e819d0..60f03dba5a2 100644 --- a/src/Utils/VoiceRecorder.tsx +++ b/src/Utils/VoiceRecorder.tsx @@ -67,6 +67,7 @@ export const VoiceRecorder = (props: any) => { {t("record")} diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index f97837e2232..35ad46408b1 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -224,15 +224,3 @@ export const formatCurrency = (price: number) => style: "currency", currency: "INR", }); - -export const fahrenheitToCelsius = (x: any) => { - if (x === null || x === undefined) return x; - const t = (Number(x) - 32.0) * (5.0 / 9.0); - return String(t.toFixed(1)); -}; - -export const celsiusToFahrenheit = (x: any) => { - if (x === null || x === undefined) return x; - const t = (Number(x) * 9.0) / 5.0 + 32.0; - return String(t.toFixed(1)); -}; diff --git a/src/index.tsx b/src/index.tsx index dfebfd4fdaf..4df33b7357d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -import ReactDOM from "react-dom"; +import { createRoot } from "react-dom/client"; import reducer from "../src/Redux/Reducer"; import { createTheme, ThemeProvider } from "@material-ui/core/styles"; import App from "./App"; @@ -30,11 +30,11 @@ const theme = createTheme({ }, }); -ReactDOM.render( +const root = createRoot(document.getElementById("root") as HTMLElement); +root.render( - , - document.getElementById("root") + ); diff --git a/src/react-phone-input-2.d.ts b/src/react-phone-input-2.d.ts deleted file mode 100644 index 0b2ad81da0f..00000000000 --- a/src/react-phone-input-2.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -declare module "react-phone-input-2" { - import React from "react"; - - export interface ICountryData { - name: string; - dialCode: string; - countryCode: string; - format: string; - } - - interface IStyle { - containerClass?: string; - inputClass?: string; - buttonClass?: string; - dropdownClass?: string; - searchClass?: string; - - containerStyle?: React.CSSProperties; - inputStyle?: React.CSSProperties; - buttonStyle?: React.CSSProperties; - dropdownStyle?: React.CSSProperties; - searchStyle?: React.CSSProperties; - } - - interface IPhoneInputEventsProps { - onChange?( - value: string, - data: ICountryData | {}, - event: ChangeEvent, - formattedValue: string - ): void; - onFocus?( - event: React.FocusEvent, - data: ICountryData | {} - ): void; - onBlur?( - event: React.FocusEvent, - data: ICountryData | {} - ): void; - onClick?( - event: React.MouseEvent, - data: ICountryData | {} - ): void; - onKeyDown?(event: React.KeyboardEvent): void; - } - - export interface IPhoneInputProps extends IPhoneInputEventsProps, IStyle { - country?: string; - value?: string; - onlyCountries?: string[]; - preferredCountries?: string[]; - excludeCountries?: string[]; - placeholder?: string; - searchPlaceholder?: string; - inputProps?: object; - - autoFormat?: boolean; - disabled?: boolean; - disableDropdown?: boolean; - disableCountryCode?: boolean; - enableAreaCodes?: boolean; - enableTerritories?: boolean; - enableLongNumbers?: boolean; - countryCodeEditable?: boolean; - enableSearch?: boolean; - disableSearchIcon?: boolean; - } - const PhoneInput: React.FC; - export default PhoneInput; -} diff --git a/vite.config.ts b/vite.config.ts index 53f1491e7b4..0244935cee0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -57,6 +57,7 @@ export default defineConfig({ // workaround for react-phone-input-2 https://github.com/vitejs/vite/issues/2139#issuecomment-1405624744 defaultIsModuleExports(id) { try { + // eslint-disable-next-line @typescript-eslint/no-var-requires const module = require(id); if (module?.default) { return false;