Skip to content

Commit

Permalink
Added Location sheet, removed Location Question (#10810)
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 authored Feb 27, 2025
1 parent b6b9181 commit 432c614
Show file tree
Hide file tree
Showing 16 changed files with 547 additions and 330 deletions.
12 changes: 12 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
"active": "Active",
"active_encounters": "Active Encounters",
"active_files": "Active Files",
"active_location_cannot_be_in_future": "Active location cannot be in the future",
"active_prescriptions": "Active Prescriptions",
"add": "Add",
"add_another_session": "Add another session",
Expand All @@ -304,6 +305,7 @@
"add_location_description": "Create a Location such as Rooms/Beds",
"add_new_beds": "Add New Bed(s)",
"add_new_facility": "Add New Facility",
"add_new_location": "Add New Location",
"add_new_patient": "Add New Patient",
"add_new_user": "Add New User",
"add_notes": "Add notes",
Expand Down Expand Up @@ -689,6 +691,7 @@
"create_department_team_description": "Create a new department/team in this facility.",
"create_encounter": "Create Encounter",
"create_facility": "Create Facility",
"create_location_association": "Create Location Association",
"create_new": "Create New",
"create_new_asset": "Create New Asset",
"create_new_encounter": "Create a new encounter to get started",
Expand Down Expand Up @@ -1009,6 +1012,7 @@
"end_time": "End Time",
"end_time_before_start_error": "End time cannot be before start time",
"end_time_future_error": "End time cannot be in the future",
"end_time_required": "End time is required",
"ended": "Ended",
"enter_contact_value": "Enter contact value",
"enter_department_team_description": "Enter department/team description (optional)",
Expand Down Expand Up @@ -1354,6 +1358,8 @@
"local_ip_address_example": "e.g. 192.168.0.123",
"location": "Location",
"location_associated_successfully": "Location associated successfully",
"location_association_created_successfully": "Location association created successfully",
"location_association_updated_successfully": "Location association updated successfully",
"location_beds_empty": "No beds available in this location",
"location_created": "Location Created",
"location_description": "Location Description",
Expand Down Expand Up @@ -1406,6 +1412,7 @@
"manage_my_schedule": "Manage my schedule",
"manage_organizations": "Manage Organizations",
"manage_organizations_description": "Add or remove organizations from this questionnaire",
"manage_patient_location_and_transfers": "Manage patient location and transfers",
"manage_prescriptions": "Manage Prescriptions",
"manage_preset": "Manage preset {{ name }}",
"manage_tags": "Manage Tags",
Expand Down Expand Up @@ -1772,6 +1779,8 @@
"pincode_district_auto_fill_error": "Failed to auto-fill district information",
"pincode_must_be_6_digits": "Pincode must be a 6-digit number",
"pincode_state_auto_fill_error": "Failed to auto-fill state and district information",
"planned": "Planned",
"planned_reserved_cannot_be_in_past": "Planned/Reserved cannot be in the past",
"play": "Play",
"play_audio": "Play Audio",
"please_assign_bed_to_patient": "Please assign a bed to this patient",
Expand Down Expand Up @@ -1965,6 +1974,7 @@
"rescheduled": "Rescheduled",
"rescheduling": "Rescheduling...",
"resend_otp": "Resend OTP",
"reserved": "Reserved",
"reset": "Reset",
"reset_password": "Reset Password",
"reset_password_note_self": "Enter your current password, then create and confirm your new password",
Expand Down Expand Up @@ -2094,6 +2104,7 @@
"see_details": "See Details",
"see_note": "See Note",
"select": "Select",
"select_a_status": "Select a status",
"select_a_value_set": "Select a Value Set",
"select_additional_instructions": "Select additional instructions",
"select_admit_source": "Select Admit Source",
Expand Down Expand Up @@ -2242,6 +2253,7 @@
"start_time_before_authored_error": "Start time cannot be before the medication was prescribed",
"start_time_future_error": "Start time cannot be in the future",
"start_time_must_be_before_end_time": "Start time must be before end time",
"start_time_required": "Start time is required",
"start_typing_to_search": "Start typing to search...",
"state": "State",
"state_reason_for_archiving": "State reason for archiving <strong>{{name}}</strong> file?",
Expand Down
49 changes: 0 additions & 49 deletions src/components/Location/LocationHistorySheet.tsx

This file was deleted.

29 changes: 6 additions & 23 deletions src/components/Location/LocationSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import { t } from "i18next";
import { useState } from "react";
import { useTranslation } from "react-i18next";

import {
Command,
Expand All @@ -16,6 +16,7 @@ import {
} from "@/components/ui/popover";

import query from "@/Utils/request/query";
import { stringifyNestedObject } from "@/Utils/utils";
import { LocationList } from "@/types/location/location";
import locationApi from "@/types/location/locationApi";

Expand All @@ -34,15 +35,14 @@ export function LocationSearch({
disabled,
value,
}: LocationSearchProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [search, setSearch] = useState("");

const { data: locations } = useQuery({
queryKey: ["locations", facilityId, mode, search],
queryFn: query(locationApi.list, {
pathParams: { facility_id: facilityId },
queryParams: { mode, name: search },
queryParams: { mode, name: search, form: "bd", available: "true" },
}),
enabled: facilityId !== "preview",
});
Expand All @@ -54,7 +54,7 @@ export function LocationSearch({
role="combobox"
aria-expanded={open}
>
{value?.name || "Select location..."}
{stringifyNestedObject(value || { name: "" }) || "Select location..."}
</div>
</PopoverTrigger>
<PopoverContent className="w-[400px] p-0">
Expand All @@ -65,7 +65,7 @@ export function LocationSearch({
className="outline-none border-none ring-0 shadow-none"
onValueChange={setSearch}
/>
<CommandEmpty>No locations found.</CommandEmpty>
<CommandEmpty>{t("no_locations_found")}</CommandEmpty>
<CommandGroup>
{locations?.results.map((location) => (
<CommandItem
Expand All @@ -76,15 +76,7 @@ export function LocationSearch({
setOpen(false);
}}
>
<span>{location.name}</span>
<span className="text-xs text-gray-500">
{t(`location_form__${location.form}`)}
{" in "}
{formatLocationParent(location)}
</span>
<span className="text-xs text-gray-500 ml-auto">
{t(`location_status__${location.status}`)}
</span>
{stringifyNestedObject(location)}
</CommandItem>
))}
</CommandGroup>
Expand All @@ -93,12 +85,3 @@ export function LocationSearch({
</Popover>
);
}

const formatLocationParent = (location: LocationList) => {
const parents: string[] = [];
while (location.parent?.name) {
parents.push(location.parent?.name);
location = location.parent;
}
return parents.reverse().join(" > ");
};
Loading

0 comments on commit 432c614

Please sign in to comment.