From dd7109af0e8eba8411dcc7169578c3e6b9dcca29 Mon Sep 17 00:00:00 2001 From: Bodhish Thomas Date: Sun, 5 Jan 2025 17:56:23 +0530 Subject: [PATCH] Add public flag to facility (#9759) --- public/locale/en.json | 2 +- .../QuestionnaireResponsesList.tsx | 1 - .../Facility/CreateFacilityForm.tsx | 342 +++++++++++------- src/components/Facility/FacilityCreate.tsx | 36 +- src/components/Facility/FacilityHome.tsx | 18 +- src/components/Facility/models.tsx | 1 + .../Questionnaire/QuestionnaireForm.tsx | 2 - src/components/ui/sidebar/app-sidebar.tsx | 48 ++- .../ui/sidebar/facility-switcher.tsx | 5 +- .../ui/sidebar/organization-switcher.tsx | 3 +- src/pages/Organization/OrganizationUsers.tsx | 2 +- .../components/OrganizationLayout.tsx | 1 + .../components/OrganizationSelector.tsx | 1 + src/types/facility/facility.ts | 2 + 14 files changed, 304 insertions(+), 160 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index 172d3316935..e53709ae7ff 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -230,7 +230,7 @@ "SYSTEM__govt_org_type__district": "District", "SYSTEM__govt_org_type__grama_panchayat": "Grama Panchayat", "SYSTEM__govt_org_type__local_body": "Local Body", - "SYSTEM__govt_org_type__muncipality": "Muncipality", + "SYSTEM__govt_org_type__municipality": "Municipality", "SYSTEM__govt_org_type__state": "State", "SYSTEM__govt_org_type__ward": "Ward", "SYSTEM__org_type__default": "Organization", diff --git a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx index 5f3d62b9809..b82b37aaca5 100644 --- a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx +++ b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx @@ -258,7 +258,6 @@ export default function QuestionnaireResponsesList({ encounter }: Props) { // New structured response rendering Object.entries(item.structured_responses).map( ([type, response]) => { - console.log("LOGGG", type, response); return ( !val || validateLongitude(val), "Invalid longitude"), + is_public: z.boolean().default(false), }); type FacilityFormValues = z.infer; @@ -77,6 +80,7 @@ export default function CreateFacilityForm({ }: Props) { const { t } = useTranslation(); const queryClient = useQueryClient(); + const [isGettingLocation, setIsGettingLocation] = useState(false); const form = useForm({ resolver: zodResolver(facilityFormSchema), @@ -90,6 +94,7 @@ export default function CreateFacilityForm({ phone_number: "+91", latitude: "", longitude: "", + is_public: false, }, }); @@ -132,16 +137,23 @@ export default function CreateFacilityForm({ const handleGetCurrentLocation = () => { if (navigator.geolocation) { + setIsGettingLocation(true); navigator.geolocation.getCurrentPosition( (position) => { form.setValue("latitude", position.coords.latitude.toString()); form.setValue("longitude", position.coords.longitude.toString()); + setIsGettingLocation(false); + Notification.Success({ + msg: "Location updated successfully", + }); }, (error) => { + setIsGettingLocation(false); Notification.Error({ msg: "Unable to get location: " + error.message, }); }, + { timeout: 10000 }, // 10 second timeout ); } else { Notification.Error({ @@ -152,108 +164,138 @@ export default function CreateFacilityForm({ return (
- -
- ( - - Facility Type - + + + + + + + {FACILITY_TYPES.map((type) => ( + + {type.text} + + ))} + + + + + )} + /> + + ( + + Facility Name - - - + - - {FACILITY_TYPES.map((type) => ( - - {type.text} - - ))} - - - - - )} - /> + + + )} + /> +
( - Facility Name + Description - +