Skip to content

Commit

Permalink
Merge branch 'develop' into issue/ohcnetwork#10071/selection-slot
Browse files Browse the repository at this point in the history
  • Loading branch information
AnveshNalimela committed Jan 23, 2025
2 parents 8498116 + 074d97a commit 5dd34d6
Show file tree
Hide file tree
Showing 37 changed files with 651 additions and 372 deletions.
8 changes: 5 additions & 3 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FacilityCreation } from "../../pageObject/facility/FacilityCreation";
import { generatePhoneNumber } from "../../utils/commonUtils";
import { generateFacilityData } from "../../utils/facilityData";
import { FacilityCreation } from "pageObject/facility/FacilityCreation";
import { generatePhoneNumber } from "utils/commonUtils";
import { generateFacilityData } from "utils/facilityData";

const LOCATION_HIERARCHY = {
localBody: "Aluva",
Expand All @@ -12,6 +12,8 @@ describe("Facility Management", () => {
const facilityType = "Primary Health Centre";

beforeEach(() => {
// Set larger viewport to ensure all elements are visible
cy.viewport(1920, 1080);
cy.visit("/login");
cy.loginByApi("nurse");
});
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/patient_spec/patient_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { patientCreation } from "pageObject/Patients/PatientCreation";
import { patientDashboard } from "pageObject/Patients/PatientDashboard";
import { patientVerify } from "pageObject/Patients/PatientVerify";
import { FacilityCreation } from "pageObject/facility/FacilityCreation";

import {
generateAddress,
generateName,
generatePhoneNumber,
} from "../../utils/commonUtils";
} from "utils/commonUtils";

const facilityCreation = new FacilityCreation();
const ENCOUNTER_TYPE = "Observation";
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe("User Creation", () => {
email: `${generateUsername(firstName)}@test.com`,
phoneNumber: generatePhoneNumber(),
userType: "Doctor",
gender: "Male",
state: "Kerala",
district: "Ernakulam",
localBody: "Aluva",
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageObject/Patients/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class PatientCreation {
}

selectLocalBody(localBody: string) {
cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody);
cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody, false);
return this;
}

Expand Down
9 changes: 8 additions & 1 deletion cypress/pageObject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface UserData {
district?: string;
localBody?: string;
ward?: string;
gender?: string;
}

export class UserCreation {
Expand Down Expand Up @@ -98,7 +99,7 @@ export class UserCreation {
}

selectLocalBody(localBody: string) {
cy.clickAndSelectOption('[data-cy="select-local_body"]', localBody);
cy.typeAndSelectOption('[data-cy="select-local_body"]', localBody, false);
return this;
}

Expand All @@ -107,6 +108,11 @@ export class UserCreation {
return this;
}

selectGender(gender: string) {
cy.clickAndSelectOption('[data-cy="gender-select"]', gender);
return this;
}

fillUserDetails(userData: UserData & { confirmPassword?: string }) {
if (userData.userType) this.selectUserType(userData.userType);
if (userData.firstName) this.fillFirstName(userData.firstName);
Expand All @@ -118,6 +124,7 @@ export class UserCreation {
}
if (userData.email) this.fillEmail(userData.email);
if (userData.phoneNumber) this.fillPhoneNumber(userData.phoneNumber);
if (userData.gender) this.selectGender(userData.gender);
if (userData.state) this.selectState(userData.state);
if (userData.district) this.selectDistrict(userData.district);
if (userData.localBody) this.selectLocalBody(userData.localBody);
Expand Down
8 changes: 7 additions & 1 deletion cypress/pageObject/facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export class FacilityCreation {
}

fillLocationHierarchy(location: { localBody: string; ward: string }) {
cy.typeAndSelectOption('[data-cy="select-local_body"]', location.localBody);
// Don't verify selection for local body (false parameter)
cy.typeAndSelectOption(
'[data-cy="select-local_body"]',
location.localBody,
false,
);
// Verify selection for ward (default behavior)
cy.typeAndSelectOption('[data-cy="select-ward"]', location.ward);
return this;
}
Expand Down
35 changes: 23 additions & 12 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,30 @@ Cypress.Commands.add("clickCancelButton", (buttonText = "Cancel") => {

Cypress.Commands.add(
"typeAndSelectOption",
(selector: string, value: string) => {
(selector: string, value: string, verify: boolean = true) => {
// Click to open the dropdown
cy.get(selector).click();

// Type in the command input
cy.get("[cmdk-input]").should("be.visible").clear().type(value);

// Select the filtered option from command menu
cy.get("[cmdk-list]")
.find("[cmdk-item]")
.contains(value)
.should("be.visible")
.click();
cy.get(selector)
.click()
.then(() => {
// Type in the command input
cy.get("[cmdk-input]")
.should("be.visible")
.type(value)
.then(() => {
// Select the filtered option from command menu
cy.get("[cmdk-list]")
.find("[cmdk-item]")
.contains(value)
.should("be.visible")
.click()
.then(() => {
// Verify the selected value is present in the selector (if verify is true)
if (verify) {
cy.get(selector).should("contain", value);
}
});
});
});
},
);

Expand Down
3 changes: 2 additions & 1 deletion cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ declare global {
clickCancelButton(buttonText?: string): Chainable<Element>;
typeAndSelectOption(
element: string,
referance: string,
reference: string,
skipVerification?: boolean,
): Chainable<Element>;
clickAndMultiSelectOption(
selector: string,
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"react-hook-form": "^7.53.2",
"react-i18next": "^15.2.0",
"react-infinite-scroll-component": "^6.1.0",
"react-intersection-observer": "^9.15.0",
"react-intersection-observer": "^9.15.1",
"react-pdf": "^9.2.1",
"react-webcam": "^7.2.0",
"recharts": "^2.15.0",
Expand Down
12 changes: 12 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,11 @@
"created_on": "Created On",
"creating": "Creating...",
"creating_facility": "Creating Facility...",
"critical": "Critical",
"criticality": "Criticality",
"csv_file_in_the_specified_format": "Select a CSV file in the specified format",
"current_address": "Current Address",
"current_organizations": "Current Organizations",
"current_password": "Current Password",
"current_role": "Current Role",
"current_status": "Current Status",
Expand Down Expand Up @@ -910,6 +912,7 @@
"encounter_discharge_disposition__snf": "Skilled nursing facility",
"encounter_duration_confirmation": "The duration of this encounter would be",
"encounter_id": "Encounter ID",
"encounter_manage_organization_description": "Add or remove organizations from this encouter",
"encounter_marked_as_complete": "Encounter Completed",
"encounter_notes__all_discussions": "All Discussions",
"encounter_notes__be_first_to_send": "Be the first to send a message",
Expand Down Expand Up @@ -1238,6 +1241,7 @@
"last_modified": "Last Modified",
"last_modified_by": "Last Modified By",
"last_name": "Last Name",
"last_occurrence": "Last Occurrence",
"last_online": "Last Online",
"last_serviced_on": "Last Serviced On",
"last_updated_by": "Last updated by",
Expand Down Expand Up @@ -1381,6 +1385,7 @@
"next_week_short": "Next wk",
"no": "No",
"no_address_provided": "No address provided",
"no_allergies_recorded": "No allergies recorded",
"no_appointments": "No appointments found",
"no_attachments_found": "This communication has no attachments.",
"no_availabilities_yet": "No availabilities yet",
Expand Down Expand Up @@ -1412,6 +1417,7 @@
"no_notices_for_you": "No notices for you.",
"no_observations": "No Observations",
"no_ongoing_medications": "No Ongoing Medications",
"no_organizations_added_yet": "No organizations added yet",
"no_organizations_found": "No Organizations Found",
"no_organizations_selected": "No organizations selected",
"no_patient_record_found": "No Patient Records Found",
Expand Down Expand Up @@ -1482,6 +1488,7 @@
"on_hold": "On Hold",
"ongoing_medications": "Ongoing Medications",
"only_indian_mobile_numbers_supported": "Currently only Indian numbers are supported",
"onset": "Onset",
"op_encounter": "OP Encounter",
"op_file_closed": "OP file closed",
"open": "Open",
Expand Down Expand Up @@ -1773,6 +1780,7 @@
"required_quantity": "Required Quantity",
"reschedule": "Reschedule",
"reschedule_appointment": "Reschedule Appointment",
"reschedule_appointment_with": "Reschedule Appointment with",
"rescheduled": "Rescheduled",
"rescheduling": "Rescheduling...",
"resend_otp": "Resend OTP",
Expand Down Expand Up @@ -1948,6 +1956,7 @@
"set_home_facility": "Set as home facility",
"set_your_local_language": "Set your local language",
"settings_and_filters": "Settings and Filters",
"severity": "Severity",
"severity_of_breathlessness": "Severity of Breathlessness",
"sex": "Sex",
"shared_by": "Shared By",
Expand Down Expand Up @@ -2018,13 +2027,15 @@
"subscribed_successfully": "Subscribed Successfully",
"subscription_error": "Subscription Error",
"subscription_failed": "Subscription Failed",
"substance": "Substance",
"suggested_investigations": "Suggested Investigations",
"suggestion": "Suggestion",
"summary": "Summary",
"support": "Support",
"switch": "Switch",
"switch_bed": "Switch Bed",
"switch_camera_is_not_available": "Switch camera is not available.",
"symptom": "Symptom",
"symptoms": "Symptoms",
"symptoms_empty_message": "No symptoms recorded",
"systolic": "Systolic",
Expand Down Expand Up @@ -2215,6 +2226,7 @@
"ventilator_oxygen_modality": "Oxygen Modality",
"ventilator_oxygen_modality_oxygen_rate": "Oxygen Flow Rate",
"ventilator_spo2": "SpO₂",
"verification": "Verification",
"verification_failed": "Verification Failed",
"verify": "Verify",
"verify_and_link": "Verify and Link",
Expand Down
15 changes: 15 additions & 0 deletions src/Routers/PatientRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ const AppointmentRoutes = {
facilityId: string;
staffId: string;
}) => <ScheduleAppointment facilityId={facilityId} staffId={staffId} />,
"/facility/:facilityId/appointments/:staffId/reschedule/:appointmentId": ({
facilityId,
staffId,
appointmentId,
}: {
facilityId: string;
staffId: string;
appointmentId: string;
}) => (
<ScheduleAppointment
facilityId={facilityId}
staffId={staffId}
appointmentId={appointmentId}
/>
),
"/facility/:facilityId/appointments/:staffId/patient-select": ({
facilityId,
staffId,
Expand Down
10 changes: 2 additions & 8 deletions src/Routers/routes/ResourceRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { Redirect } from "raviger";

import View from "@/components/Common/View";
import BoardView from "@/components/Resource/ResourceBoard";
import ResourceDetails from "@/components/Resource/ResourceDetails";
import { ResourceDetailsUpdate } from "@/components/Resource/ResourceDetailsUpdate";
import ListView from "@/components/Resource/ResourceList";

import { AppRoutes } from "@/Routers/AppRouter";

const getDefaultView = () =>
localStorage.getItem("defaultResourceView") === "list" ? "list" : "board";

const ResourceRoutes: AppRoutes = {
"/resource": () => <Redirect to={`/resource/${getDefaultView()}`} />,
"/resource/board": () => <BoardView />,
"/resource/list": () => <ListView />,
"/resource": () => <View name="resource" board={BoardView} list={ListView} />,
"/resource/:id": ({ id }) => <ResourceDetails id={id} />,
"/resource/:id/update": ({ id }) => <ResourceDetailsUpdate id={id} />,
};
Expand Down
23 changes: 23 additions & 0 deletions src/Utils/ViewCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const getKey = (name: string) => {
return `${name}`;
};

/**
* Clears the view preference.
*/
const invalidate = (name: string) => {
localStorage.removeItem(getKey(name));
};

/**
* Clears all the view preferences.
*/
const invalidateAll = () => {
const viewKeys = ["users", "resource", "appointments"];
viewKeys.forEach(invalidate);
};

export default {
invalidate,
invalidateAll,
};
26 changes: 26 additions & 0 deletions src/Utils/useView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useEffect, useState } from "react";

export function useView(
name: string,
defaultView: string,
): [string, (view: string) => void] {
const [view, setView] = useState(() => {
return localStorage.getItem(name) || defaultView;
});
const updateView = (newView: string) => {
localStorage.setItem(name, newView);
setView(newView);
};
useEffect(() => {
const interval = setInterval(() => {
const storedView = localStorage.getItem(name);
if (storedView !== view) {
setView(storedView || defaultView);
}
}, 100);
return () => {
clearInterval(interval);
};
}, [name, view]);
return [view, updateView];
}
2 changes: 2 additions & 0 deletions src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import BrowserWarning from "@/components/ErrorPages/BrowserWarning";
import { useAuthContext } from "@/hooks/useAuthUser";

import FiltersCache from "@/Utils/FiltersCache";
import ViewCache from "@/Utils/ViewCache";
import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import request from "@/Utils/request/request";
Expand Down Expand Up @@ -242,6 +243,7 @@ const Login = (props: LoginProps) => {

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
ViewCache.invalidateAll();
const validated = validateData();
if (!validated) return;

Expand Down
Loading

0 comments on commit 5dd34d6

Please sign in to comment.