Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit feature for facilities in organization | pincode, geo_organization info auto populates #9662

Merged
merged 74 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
03fd617
pincode updated
Mahendar0701 Jan 2, 2025
d1a6ca1
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 2, 2025
7db9c3a
populated geo_organization values
Mahendar0701 Jan 3, 2025
080f442
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 3, 2025
8159f13
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 3, 2025
fc0413e
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 3, 2025
d0daf9c
autofill of state and districts
Mahendar0701 Jan 4, 2025
f7db9bc
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 4, 2025
02a4ca0
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 4, 2025
ab383d5
translation
Mahendar0701 Jan 4, 2025
7dff65f
commit
Mahendar0701 Jan 4, 2025
4eda986
added usequery
Mahendar0701 Jan 4, 2025
c811b60
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 4, 2025
d9078ad
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 5, 2025
884fc82
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 5, 2025
0f49a53
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 5, 2025
b6b2318
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 5, 2025
fd3241f
moved useFetchOrganizationByName organizationapi.ts
Mahendar0701 Jan 5, 2025
f9d4e49
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 5, 2025
3a9dcbf
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 5, 2025
e87535d
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 5, 2025
213eb95
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 6, 2025
87db767
added conditions
Mahendar0701 Jan 6, 2025
4599c93
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 6, 2025
8df1055
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 9, 2025
80dde3f
added edit option
Mahendar0701 Jan 9, 2025
f63a324
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 9, 2025
dcad86a
added edit option
Mahendar0701 Jan 9, 2025
0e370c9
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 10, 2025
9b57759
resolved conflicts
Mahendar0701 Jan 10, 2025
a5d9d6e
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 11, 2025
a932b00
autopopulation of existing details
Mahendar0701 Jan 11, 2025
15eb9d3
added i18n and pincode limit
Mahendar0701 Jan 11, 2025
f735ac9
added i18n and pincode limit
Mahendar0701 Jan 11, 2025
a68184f
link wrap in button
Mahendar0701 Jan 11, 2025
4a9f3a6
autofill pincode
Mahendar0701 Jan 11, 2025
43caefd
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 12, 2025
5ffb199
added form.watch
Mahendar0701 Jan 12, 2025
5bda95e
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 12, 2025
ed06a75
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 13, 2025
f763eba
facility edit sheet
Mahendar0701 Jan 13, 2025
8dbda7e
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 13, 2025
ec1014e
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 13, 2025
763b4aa
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 14, 2025
439a061
Update FacilityHome.tsx
Mahendar0701 Jan 14, 2025
0a6f616
organization error on update fixed
Mahendar0701 Jan 14, 2025
281e692
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 14, 2025
d1ac44c
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 14, 2025
02ee915
organization selector autofill
Mahendar0701 Jan 14, 2025
ddfc48a
added i8n
Mahendar0701 Jan 14, 2025
7a197f8
autofill pincode and editsheet wrapped out
Mahendar0701 Jan 14, 2025
9f20cde
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 14, 2025
5ef6fae
edit button
Mahendar0701 Jan 14, 2025
652a56a
coderabbit suggestions
Mahendar0701 Jan 14, 2025
bd099ec
test case fixed
Mahendar0701 Jan 14, 2025
7ce8dfc
remove commented code
Mahendar0701 Jan 15, 2025
4ecaac4
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 15, 2025
1138110
invalidate queries
Mahendar0701 Jan 15, 2025
802e5b3
added i18n
Mahendar0701 Jan 15, 2025
75ea5ee
Trigger Build
Mahendar0701 Jan 15, 2025
048f685
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 15, 2025
130fe35
removed feature flags
Mahendar0701 Jan 15, 2025
ff675f7
added changes
Mahendar0701 Jan 16, 2025
f59b850
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 16, 2025
e953ed8
Trigger
Mahendar0701 Jan 16, 2025
fe992a5
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 16, 2025
2c80f20
Update useStateAndDistrictFromPincode.ts
Mahendar0701 Jan 16, 2025
23fb716
added changes
Mahendar0701 Jan 16, 2025
88f4110
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 16, 2025
e849923
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 16, 2025
d1bac5e
Merge branch 'facility-edit' of https://github.com/Mahendar0701/care_…
Mahendar0701 Jan 16, 2025
cf9b5f3
Merge branch 'develop' into facility-edit
Mahendar0701 Jan 16, 2025
15ada03
testcases
Mahendar0701 Jan 16, 2025
195b2a1
adjusted the cypress issue
nihal467 Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@
"select_investigation_groups": "Select Investigation Groups",
"select_investigations": "Select Investigations",
"select_local_body": "Select Local Body",
"select_location_from": "Select location from",
"select_patient": "Select Patient",
"select_policy": "Select an Insurance Policy",
"select_policy_to_add_items": "Select a Policy to Add Items",
Expand Down
7 changes: 4 additions & 3 deletions src/components/Facility/FacilityCreate.tsx
Mahendar0701 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const FacilityCreate = (props: FacilityProps) => {
name: facilityData.name,
description: facilityData.description || "",
features: facilityData.features || [],
pincode: facilityData.pincode,
pincode: facilityData.pincode?.toString() || "",
geo_organization: facilityData.geo_organization,
address: facilityData.address,
phone_number: facilityData.phone_number,
Expand Down Expand Up @@ -214,7 +214,7 @@ export const FacilityCreate = (props: FacilityProps) => {

return (
<Page
title={facilityId ? "Update Facility" : "Create Facility"}
title={facilityId ? t("update_facility") : t("create_facility")}
crumbsReplacements={{
[facilityId || "????"]: { name: form.watch("name") },
}}
Expand Down Expand Up @@ -329,6 +329,7 @@ export const FacilityCreate = (props: FacilityProps) => {
<div className="col-span-2 grid grid-cols-2 gap-5">
<OrganizationSelector
required={true}
value={facilityData?.geo_organization}
onChange={(value) => form.setValue("geo_organization", value)}
/>
</div>
Expand Down Expand Up @@ -411,7 +412,7 @@ export const FacilityCreate = (props: FacilityProps) => {
>
<CareIcon icon="l-map-marker" className="text-xl" />
<span className="tooltip-text tooltip-bottom">
Select location from map
{t("select_location_from")}
</span>
</Button>
</PopoverButton>
Expand Down
28 changes: 25 additions & 3 deletions src/pages/Organization/components/OrganizationSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { useState } from "react";
import { useEffect, useState } from "react";

import CareIcon from "@/CAREUI/icons/CareIcon";

Expand Down Expand Up @@ -28,10 +28,32 @@ interface AutoCompleteOption {
}

export default function OrganizationSelector(props: OrganizationSelectorProps) {
const { onChange, required } = props;
const { value, onChange, required } = props;
const [selectedLevels, setSelectedLevels] = useState<Organization[]>([]);
const [searchQuery, setSearchQuery] = useDebouncedState("", 500);

useEffect(() => {
if (value) {
try {
const parsedValue =
typeof value === "string" ? JSON.parse(value) : value;
if (parsedValue) {
const levels: Organization[] = [];
let current = parsedValue;

while (current.parent) {
levels.unshift(current);
current = current.parent;
}

setSelectedLevels(levels);
}
} catch (e) {
console.error("Invalid value for geo_organization:", e);
}
}
}, [value]);

const headers = props.authToken
? {
headers: {
Expand Down Expand Up @@ -146,7 +168,7 @@ export default function OrganizationSelector(props: OrganizationSelectorProps) {
required={selectedLevels.length === 0 && required}
>
<Autocomplete
value=""
value={selectedLevels[selectedLevels.length - 1]?.id || ""}
options={getOrganizationOptions(
selectedLevels.length === 0
? getAllOrganizations?.results
Expand Down
Loading