diff --git a/public/locale/en.json b/public/locale/en.json index 20885bf0435..2a485441d4f 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/CreateFacilityForm.tsx b/src/components/Facility/CreateFacilityForm.tsx index 264c99be558..8ad9887d2ef 100644 --- a/src/components/Facility/CreateFacilityForm.tsx +++ b/src/components/Facility/CreateFacilityForm.tsx @@ -1,5 +1,6 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import * as z from "zod"; @@ -7,6 +8,7 @@ import * as z from "zod"; import CareIcon from "@/CAREUI/icons/CareIcon"; import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; import { Form, FormControl, @@ -62,6 +64,7 @@ const facilityFormSchema = z.object({ .string() .optional() .refine((val) => !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 - +