Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/DonXavierdev/care_fe int…
Browse files Browse the repository at this point in the history
…o issues/10387/Cypress-Medicine-Test
  • Loading branch information
DonXavierdev committed Mar 7, 2025
2 parents d49281f + 93be23b commit e90695b
Show file tree
Hide file tree
Showing 48 changed files with 1,186 additions and 831 deletions.
5 changes: 4 additions & 1 deletion .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn"
REACT_DEFAULT_COUNTRY=

# Maps fallback URL template (default:"https://www.openstreetmap.org/?mlat={lat}&mlon={long}&zoom=15")
REACT_MAPS_FALLBACK_URL_TEMPLATE=
REACT_MAPS_FALLBACK_URL_TEMPLATE=

# OTP resend timeout in seconds (eg. 90 seconds) (default : 120 seconds)
REACT_APP_RESEND_OTP_TIMEOUT=
4 changes: 4 additions & 0 deletions care.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ const careConfig = {
env.REACT_OBSERVATION_PLOTS_CONFIG_URL || "/config/plots.json",

defaultCountry: (env.REACT_DEFAULT_COUNTRY || "IN") as CountryCode,

resendOtpTimeout: env.REACT_APP_RESEND_OTP_TIMEOUT
? parseInt(env.REACT_APP_RESEND_OTP_TIMEOUT, 10)
: 30,
} as const;

export default careConfig;
31 changes: 31 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"SYSTEM__govt_org_type__corporation": "Corporation",
"SYSTEM__govt_org_type__default": "State",
"SYSTEM__govt_org_type__district": "District",
"SYSTEM__govt_org_type__district_panchayat": "District Panchayat",
"SYSTEM__govt_org_type__grama_panchayat": "Grama Panchayat",
"SYSTEM__govt_org_type__local_body": "Local Body",
"SYSTEM__govt_org_type__municipality": "Municipality",
Expand Down Expand Up @@ -285,11 +286,13 @@
"active_location_cannot_be_in_future": "Active location cannot be in the future",
"active_prescriptions": "Active Prescriptions",
"add": "Add",
"add_another": "Add Another",
"add_another_session": "Add another session",
"add_as": "Add as",
"add_attachments": "Add Attachments",
"add_beds": "Add Bed(s)",
"add_beds_to_configure_presets": "Add beds to this location to configure presets for them.",
"add_condition": "Add Condition",
"add_consultation": "Add consultation",
"add_consultation_update": "Add Consultation Update",
"add_contact_point": "Add Contact Point",
Expand All @@ -312,19 +315,22 @@
"add_notes_about_diagnosis": "Add notes about the diagnosis...",
"add_notes_about_symptom": "Add notes about the symptom...",
"add_notes_about_the_allergy": "Add notes about the allergy",
"add_option": "Add Option",
"add_organizations": "Add Organizations",
"add_patient_updates": "Add Patient Updates",
"add_policy": "Add Insurance Policy",
"add_prescription_medication": "Add Prescription Medication",
"add_prescription_to_consultation_note": "Add a new prescription to this consultation.",
"add_preset": "Add preset",
"add_prn_prescription": "Add PRN Prescription",
"add_question": "Add Question",
"add_questionnaire": "Add Questionnaire",
"add_remarks": "Add remarks",
"add_schedule_exceptions": "Add Schedule Exceptions",
"add_schedule_exceptions_description": "Configure absences or add availability beyond the regular schedule.",
"add_skill": "Add Skill",
"add_spoke": "Add Spoke Facility",
"add_sub_question": "Add Sub-Question",
"add_tags": "Add Tags",
"add_user": "Add User",
"added_on": "Added on",
Expand Down Expand Up @@ -551,6 +557,7 @@
"choose_date_time": "Choose Date and Time",
"choose_district": "Choose District",
"choose_file": "Upload From Device",
"choose_layout_style": "Choose the layout style that best fits your sub-questions from the available options.",
"choose_localbody": "Choose Local Body",
"choose_location": "Choose Location",
"choose_other_search_type": "Choose other search types",
Expand Down Expand Up @@ -604,10 +611,16 @@
"click_manage_sub_locations": "Click <strong>See Details</strong><ArrowIcon/> to manage sub-locations.",
"click_manage_sub_locations_mobile": "Click <PenLine/>to edit and <ArrowIcon/> to manage sub-locations.",
"click_on": "Click on",
"clone_questionnaire": "Clone Questionnaire",
"close": "Close",
"close_scanner": "Close Scanner",
"collapse_all": "Collapse All",
"collapse_sidebar": "Collapse Sidebar",
"collect": "Collect",
"collect_body_site": "Collect Body Site",
"collect_method": "Collect Method",
"collect_performer": "Collect Performer",
"collect_time": "Collect Time",
"combine_files_pdf": "Combine Files To PDF",
"comment_added_successfully": "Comment added successfully",
"comment_min_length": "Comment Should Contain At Least 1 Character",
Expand Down Expand Up @@ -875,6 +888,7 @@
"edit_device_description": "Edit the details of the device",
"edit_facility": "Edit Facility",
"edit_facility_details": "Edit Facility Details",
"edit_form": "Edit Form",
"edit_history": "Edit History",
"edit_location": "Edit Location",
"edit_location_description": "Edit the Location to make any changes",
Expand Down Expand Up @@ -1506,7 +1520,9 @@
"more_details": "More details",
"more_info": "More Info",
"morning_slots": "Morning Slots",
"move_down": "Move Down",
"move_to_onvif_preset": "Move to an ONVIF Preset",
"move_up": "Move Up",
"moving_camera": "Moving Camera",
"my_doctors": "My Doctors",
"my_organizations": "My Organizations",
Expand Down Expand Up @@ -1603,6 +1619,7 @@
"no_reason_provided": "No reason provided",
"no_records_found": "No Records Found",
"no_remarks": "No remarks",
"no_requested_questionnaires_found": "The requested questionnaire could not be found.",
"no_resource_requests_found": "No requests found",
"no_resources_found": "No resources found",
"no_results": "No results",
Expand Down Expand Up @@ -1680,10 +1697,12 @@
"ordering": "Ordering",
"organization": "Organization",
"organization_access_help": "Organizations help you manage facilities, users, and resources efficiently. Contact your administrator to get access.",
"organization_added_successfully": "Organization added successfully",
"organization_created_successfully": "Organization created successfully",
"organization_for_care_support": "Organization for Care Support",
"organization_forbidden": "You don't have access to any organizations yet.",
"organization_not_found": "No Organizations Found",
"organization_removed_successfully": "Organization removed successfully",
"organization_required": "Organization is required",
"organizations": "Organizations",
"organizations_fetch_error": "Error while fetching organizations",
Expand Down Expand Up @@ -1867,6 +1886,8 @@
"preset_name_placeholder": "Specify an identifiable name for the new preset",
"preset_updated": "Preset updated",
"prev_sessions": "Prev Sessions",
"preview": "Preview",
"preview_form": "Preview form",
"previous": "Previous",
"primary_ph_no": "Primary Ph No.",
"primary_phone_no": "Primary ph. no.",
Expand Down Expand Up @@ -1896,12 +1917,18 @@
"quantity_approved": "Quantity Approved",
"quantity_requested": "Quantity Requested",
"quantity_required": "Quantity Required",
"question": "Question",
"questionnaire_diagnosis_no_encounter": "Diagnosis cannot be recorded without an active encounter",
"questionnaire_error_loading": "Error loading questionnaire",
"questionnaire_medication_request_no_encounter": "Medication requests cannot be recorded without an active encounter",
"questionnaire_medication_statement_no_encounter": "Medication statements cannot be recorded without an active encounter",
"questionnaire_no_encounter": "Create an encounter first in order to update it",
"questionnaire_not_exist": "The questionnaire you tried to access does not exist.",
"questionnaire_one": "Questionnaire",
"questionnaire_other": "Questionnaires",
"questionnaire_submission_failed": "Failed to submit questionnaire",
"questionnaire_submitted_successfully": "Questionnaire submitted successfully",
"questionnaire_symptom_no_encounter": "Symptoms cannot be recorded without an active encounter",
"quick_access": "Quick Access",
"quick_actions": "Quick Actions",
"quick_actions_description": "Schedule an appointment or create a new encounter",
Expand Down Expand Up @@ -1960,6 +1987,7 @@
"remove_user_warn": "Are you sure you want to remove {{firstName}} {{lastName}} from this organization? This action cannot be undone.",
"rename": "Rename",
"rename_file": "Rename File",
"repeatable": "Repeatable",
"replace_home_facility": "Replace Home Facility",
"replace_home_facility_confirm": "Are you sure you want to replace",
"replace_home_facility_confirm_as": "as home facility for user",
Expand Down Expand Up @@ -1993,6 +2021,7 @@
"rescheduled": "Rescheduled",
"rescheduling": "Rescheduling...",
"resend_otp": "Resend OTP",
"resend_otp_timer": "Resend OTP in {{time}} seconds",
"reserved": "Reserved",
"reset": "Reset",
"reset_password": "Reset Password",
Expand Down Expand Up @@ -2287,7 +2316,9 @@
"stream_stop_due_to_inativity": "The live feed will stop streaming due to inactivity",
"stream_stopped_due_to_inativity": "The live feed has stopped streaming due to inactivity",
"stream_uuid": "Stream UUID",
"structured_type": "Structured Type",
"sub_category": "Sub Category",
"sub_questions": "sub-questions",
"subject": "Subject",
"subject_type": "Subject Type",
"submit": "Submit",
Expand Down
4 changes: 2 additions & 2 deletions src/Routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function AppRouter() {
const appPages = useRoutes(routes);
const adminPages = useRoutes(AdminRouter);

const sidebarFor = appPages ? SidebarFor.FACILITY : SidebarFor.ADMIN;
const sidebarFor = adminPages ? SidebarFor.ADMIN : SidebarFor.FACILITY;

const pages = appPages || adminPages || <ErrorPage />;

Expand All @@ -105,7 +105,7 @@ export default function AppRouter() {
)}
<main
id="pages"
className="flex flex-col flex-1 min-h-[calc(100svh-theme(spacing.4))] md:m-2 md:peer-data-[state=collapsed]:ml-0 border rounded-lg shadow bg-gray-50 focus:outline-none"
className="overflow-y-auto flex flex-col flex-1 min-h-[calc(100svh-theme(spacing.4))] md:m-2 md:peer-data-[state=collapsed]:ml-0 border rounded-lg shadow bg-gray-50 focus:outline-none"
>
<div className="relative z-10 flex h-16 bg-white shadow shrink-0 md:hidden">
<div className="flex items-center">
Expand Down
40 changes: 23 additions & 17 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const consultationRoutes: AppRoutes = {
facilityId={facilityId}
encounterId={encounterId}
patientId={patientId}
subjectType="encounter"
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire/:slug":
Expand All @@ -38,35 +39,37 @@ const consultationRoutes: AppRoutes = {
encounterId={encounterId}
questionnaireSlug={slug}
patientId={patientId}
subjectType="encounter"
/>
),

"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
({ patientId, id }) => (
<QuestionnaireResponseView responseId={id} patientId={patientId} />
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/:tab": ({
facilityId,
patientId,
encounterId,
tab,
}) => (
<EncounterShow
facilityId={facilityId}
patientId={patientId}
encounterId={encounterId}
tab={tab}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/:tab/:subPage":
({ facilityId, encounterId, patientId, tab, subPage }) => (
...["facility", "organization"].reduce((acc: AppRoutes, identifier) => {
acc[`/${identifier}/:id/patient/:patientId/encounter/:encounterId/:tab`] =
({ id, encounterId, tab, patientId }) => (
<EncounterShow
patientId={patientId}
encounterId={encounterId}
tab={tab}
facilityId={identifier === "facility" ? id : undefined}
/>
);
acc[
`/${identifier}/:id/patient/:patientId/encounter/:encounterId/:tab/:subPage`
] = ({ id, encounterId, patientId, tab, subPage }) => (
<EncounterShow
facilityId={facilityId}
patientId={patientId}
encounterId={encounterId}
tab={tab}
facilityId={identifier === "facility" ? id : undefined}
subPage={subPage}
/>
),
);
return acc;
}, {}),
"/facility/:facilityId/patient/:patientId/consultation": ({
facilityId,
patientId,
Expand All @@ -87,6 +90,9 @@ const consultationRoutes: AppRoutes = {
subjectType="patient"
/>
),
"/patient/:patientId/questionnaire": ({ patientId }) => (
<EncounterQuestionnaire patientId={patientId} subjectType="patient" />
),
};

export default consultationRoutes;
7 changes: 2 additions & 5 deletions src/Routers/routes/PatientRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
facilityPatientTabs,
patientTabs,
} from "@/components/Patient/PatientDetailsTab";
import { patientTabs } from "@/components/Patient/PatientDetailsTab";
import { PatientHome } from "@/components/Patient/PatientHome";
import PatientIndex from "@/components/Patient/PatientIndex";
import PatientRegistration from "@/components/Patient/PatientRegistration";
Expand Down Expand Up @@ -34,7 +31,7 @@ const PatientRoutes: AppRoutes = {
"/facility/:facilityId/patient/:id": ({ facilityId, id }) => (
<PatientHome facilityId={facilityId} id={id} page="demography" />
),
...facilityPatientTabs.reduce((acc: AppRoutes, tab) => {
...patientTabs.reduce((acc: AppRoutes, tab) => {
acc["/facility/:facilityId/patient/:id/" + tab.route] = ({
facilityId,
id,
Expand Down
48 changes: 46 additions & 2 deletions src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ interface LoginProps {

const Login = (props: LoginProps) => {
const { signIn, patientLogin, isAuthenticating } = useAuthContext();
const { reCaptchaSiteKey, urls, stateLogo, customLogo, customLogoAlt } =
careConfig;
const {
reCaptchaSiteKey,
urls,
stateLogo,
customLogo,
customLogoAlt,
resendOtpTimeout,
} = careConfig;
const customDescriptionHtml = __CUSTOM_DESCRIPTION_HTML__;
const initForm: any = {

Check warning on line 81 in src/components/Auth/Login.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Unexpected any. Specify a different type
username: "",
Expand All @@ -93,6 +99,21 @@ const Login = (props: LoginProps) => {
const [otp, setOtp] = useState("");
const [otpError, setOtpError] = useState<string>("");
const [otpValidationError, setOtpValidationError] = useState<string>("");
const [resendOtpCountdown, setResendOtpCountdown] =
useState(resendOtpTimeout);

// Timer Function for resend OTP
useEffect(() => {
if (resendOtpCountdown <= 0) {
return;
}

const timer = setInterval(() => {
setResendOtpCountdown((prevTime) => prevTime - 1);
}, 1000);

return () => clearInterval(timer);
}, []);

Check warning on line 116 in src/components/Auth/Login.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

React Hook useEffect has a missing dependency: 'resendOtpCountdown'. Either include it or remove the dependency array

// Remember the last login mode
useEffect(() => {
Expand Down Expand Up @@ -272,6 +293,7 @@ const Login = (props: LoginProps) => {

if (!isOtpSent) {
sendOtp({ phone_number: phone });
setResendOtpCountdown(resendOtpTimeout);
} else {
verifyOtp({ phone_number: phone, otp });
}
Expand Down Expand Up @@ -673,6 +695,28 @@ const Login = (props: LoginProps) => {
t("send_otp")
)}
</Button>
{isOtpSent &&
(resendOtpCountdown <= 0 ? (
<div className="flex justify-center">
<Button
variant="link"
type="button"
className=" text-center cursor-pointer hover:underline inline-block "
onClick={() => {
sendOtp({ phone_number: phone });
setResendOtpCountdown(resendOtpTimeout);
}}
>
{t("resend_otp")}
</Button>
</div>
) : (
<p className=" text-gray-500 text-center mt-5 ">
{t("resend_otp_timer", {
time: resendOtpCountdown,
})}
</p>
))}
</form>
</TabsContent>
</Tabs>
Expand Down
Loading

0 comments on commit e90695b

Please sign in to comment.