diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index e6f22b1592f..1937ddcd4ca 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -2,6 +2,11 @@ import { FacilityCreation } from "../../pageObject/facility/FacilityCreation"; import { generatePhoneNumber } from "../../utils/commonUtils"; import { generateFacilityData } from "../../utils/facilityData"; +const LOCATION_HIERARCHY = { + localBody: "Aluva", + ward: "4", +}; + describe("Facility Management", () => { const facilityPage = new FacilityCreation(); const facilityType = "Primary Health Centre"; @@ -36,6 +41,8 @@ describe("Facility Management", () => { testFacility.address, ); + facilityPage.fillLocationHierarchy(LOCATION_HIERARCHY); + facilityPage.fillLocationDetails( testFacility.coordinates.latitude, testFacility.coordinates.longitude, diff --git a/cypress/pageObject/facility/FacilityCreation.ts b/cypress/pageObject/facility/FacilityCreation.ts index 9a8bbe7ec4b..3c00df258b9 100644 --- a/cypress/pageObject/facility/FacilityCreation.ts +++ b/cypress/pageObject/facility/FacilityCreation.ts @@ -96,7 +96,7 @@ export class FacilityCreation { label: "Phone Number", message: "Phone number must start with +91 followed by 10 digits", }, - { label: "Pincode", message: "Invalid pincode" }, + { label: "Pincode", message: "Invalid Pincode" }, ]); } @@ -106,8 +106,7 @@ export class FacilityCreation { // Split string into array of characters using spread in Array.from Array.from(facilityName).forEach((char, index) => { cy.get('[data-cy="search-facility"]').type(char, { - delay: 500, - force: true, + delay: 200, }); // Wait for the last character's API call @@ -126,4 +125,10 @@ export class FacilityCreation { .should("be.visible") .should("not.be.empty"); } + + fillLocationHierarchy(location: { localBody: string; ward: string }) { + cy.typeAndSelectOption('[data-cy="select-local_body"]', location.localBody); + cy.typeAndSelectOption('[data-cy="select-ward"]', location.ward); + return this; + } } diff --git a/package-lock.json b/package-lock.json index 3605a282009..9f3fc288d33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "@radix-ui/react-tabs": "^1.1.1", "@radix-ui/react-toast": "^1.2.4", "@radix-ui/react-tooltip": "^1.1.6", - "@sentry/browser": "^8.48.0", + "@sentry/browser": "^8.50.0", "@tanstack/react-query": "^5.64.1", "@tanstack/react-query-devtools": "^5.64.0", "@vitejs/plugin-react": "^4.3.4", @@ -81,7 +81,7 @@ "react-pdf": "^9.2.1", "react-webcam": "^7.2.0", "recharts": "^2.15.0", - "sonner": "^1.7.0", + "sonner": "^1.7.2", "tailwind-merge": "^2.5.5", "tailwindcss-animate": "^1.0.7", "use-keyboard-shortcut": "^1.1.6", @@ -6028,50 +6028,50 @@ ] }, "node_modules/@sentry-internal/browser-utils": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.48.0.tgz", - "integrity": "sha512-pLtu0Fa1Ou0v3M1OEO1MB1EONJVmXEGtoTwFRCO1RPQI2ulmkG6BikINClFG5IBpoYKZ33WkEXuM6U5xh+pdZg==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.50.0.tgz", + "integrity": "sha512-hZm6ngWTEzZhaMHpLIKB4wWp0Od1MdCZdvR5FRdIThUMLa1P8rXeolovTRfOE81NE755EiwJHzj4O7rq3EjA+A==", "license": "MIT", "dependencies": { - "@sentry/core": "8.48.0" + "@sentry/core": "8.50.0" }, "engines": { "node": ">=14.18" } }, "node_modules/@sentry-internal/feedback": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.48.0.tgz", - "integrity": "sha512-6PwcJNHVPg0EfZxmN+XxVOClfQpv7MBAweV8t9i5l7VFr8sM/7wPNSeU/cG7iK19Ug9ZEkBpzMOe3G4GXJ5bpw==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.50.0.tgz", + "integrity": "sha512-79WlvSJYCXL/D0PBC8AIT4JbyS44AE3h6lP05IESXMqzTZl3KeSqCx317rwJw1KaxzeFd/JQwkFq95jaKAcLhg==", "license": "MIT", "dependencies": { - "@sentry/core": "8.48.0" + "@sentry/core": "8.50.0" }, "engines": { "node": ">=14.18" } }, "node_modules/@sentry-internal/replay": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.48.0.tgz", - "integrity": "sha512-csILVupc5RkrsTrncuUTGmlB56FQSFjXPYWG8I8yBTGlXEJ+o8oTuF6+55R4vbw3EIzBveXWi4kEBbnQlXW/eg==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.50.0.tgz", + "integrity": "sha512-mhRPujzO6n+mb6ZR+wQNkSpjqIqDriR0hZEvdzHQdyXu9zVdCHUJ3sINkzpT1XwiypQVCEfxB6Oh9y/NmcQfGg==", "license": "MIT", "dependencies": { - "@sentry-internal/browser-utils": "8.48.0", - "@sentry/core": "8.48.0" + "@sentry-internal/browser-utils": "8.50.0", + "@sentry/core": "8.50.0" }, "engines": { "node": ">=14.18" } }, "node_modules/@sentry-internal/replay-canvas": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.48.0.tgz", - "integrity": "sha512-LdivLfBXXB9us1aAc6XaL7/L2Ob4vi3C/fEOXElehg3qHjX6q6pewiv5wBvVXGX1NfZTRvu+X11k6TZoxKsezw==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.50.0.tgz", + "integrity": "sha512-Hv1bBaPpe62xFPLpuaUxVBUHd/Ed9bnGndeqN4hueeEGDT9T6NyVokgm35O5xE9/op6Yodm/3NfUkEg8oE++Aw==", "license": "MIT", "dependencies": { - "@sentry-internal/replay": "8.48.0", - "@sentry/core": "8.48.0" + "@sentry-internal/replay": "8.50.0", + "@sentry/core": "8.50.0" }, "engines": { "node": ">=14.18" @@ -6107,25 +6107,25 @@ } }, "node_modules/@sentry/browser": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.48.0.tgz", - "integrity": "sha512-fuuVULB5/1vI8NoIwXwR3xwhJJqk+y4RdSdajExGF7nnUDBpwUJyXsmYJnOkBO+oLeEs58xaCpotCKiPUNnE3g==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.50.0.tgz", + "integrity": "sha512-aGJSpuKiHVKkLvd1VklJSZ2oCsl4wcKUVxKIa8dhJC8KjDY0vREQCywrlWuS5KYP0xFy4k28pg6PPR3HKkUlNw==", "license": "MIT", "dependencies": { - "@sentry-internal/browser-utils": "8.48.0", - "@sentry-internal/feedback": "8.48.0", - "@sentry-internal/replay": "8.48.0", - "@sentry-internal/replay-canvas": "8.48.0", - "@sentry/core": "8.48.0" + "@sentry-internal/browser-utils": "8.50.0", + "@sentry-internal/feedback": "8.50.0", + "@sentry-internal/replay": "8.50.0", + "@sentry-internal/replay-canvas": "8.50.0", + "@sentry/core": "8.50.0" }, "engines": { "node": ">=14.18" } }, "node_modules/@sentry/core": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.48.0.tgz", - "integrity": "sha512-VGwYgTfLpvJ5LRO5A+qWo1gpo6SfqaGXL9TOzVgBucAdpzbrYHpZ87sEarDVq/4275uk1b0S293/mfsskFczyw==", + "version": "8.50.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.50.0.tgz", + "integrity": "sha512-q71m8Ha9YGwqn4Gd7sWvcFTRgbHXxEfU4QeIFtwMBpwHfq2Q+9koiF8DOoOHqIEOsnlvZWRQgGggIOdHzajnVw==", "license": "MIT", "engines": { "node": ">=14.18" @@ -18689,9 +18689,9 @@ } }, "node_modules/sonner": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.7.1.tgz", - "integrity": "sha512-b6LHBfH32SoVasRFECrdY8p8s7hXPDn3OHUFbZZbiB1ctLS9Gdh6rpX2dVrpQA0kiL5jcRzDDldwwLkSKk3+QQ==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.7.2.tgz", + "integrity": "sha512-zMbseqjrOzQD1a93lxahm+qMGxWovdMxBlkTbbnZdNqVLt4j+amF9PQxUCL32WfztOFt9t9ADYkejAL3jF9iNA==", "license": "MIT", "peerDependencies": { "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", diff --git a/package.json b/package.json index 6ce2c52f0b3..80a70336867 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@radix-ui/react-tabs": "^1.1.1", "@radix-ui/react-toast": "^1.2.4", "@radix-ui/react-tooltip": "^1.1.6", - "@sentry/browser": "^8.48.0", + "@sentry/browser": "^8.50.0", "@tanstack/react-query": "^5.64.1", "@tanstack/react-query-devtools": "^5.64.0", "@vitejs/plugin-react": "^4.3.4", @@ -119,7 +119,7 @@ "react-pdf": "^9.2.1", "react-webcam": "^7.2.0", "recharts": "^2.15.0", - "sonner": "^1.7.0", + "sonner": "^1.7.2", "tailwind-merge": "^2.5.5", "tailwindcss-animate": "^1.0.7", "use-keyboard-shortcut": "^1.1.6", diff --git a/public/locale/en.json b/public/locale/en.json index 24dde8da790..663d52be1ed 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -331,6 +331,7 @@ "add_insurance_details": "Add Insurance Details", "add_location": "Add Location", "add_new_beds": "Add New Bed(s)", + "add_new_facility": "Add New Facility", "add_new_patient": "Add New Patient", "add_new_user": "Add New User", "add_notes": "Add notes", @@ -682,11 +683,12 @@ "create_asset": "Create Asset", "create_consultation": "Create Consultation", "create_encounter": "Create Encounter", - "create_facility": "Create a new facility", + "create_facility": "Create Facility", "create_new_abha_address": "Create New ABHA Address", "create_new_abha_profile": "Don't have an ABHA Number", "create_new_asset": "Create New Asset", "create_new_encounter": "Create a new encounter to get started", + "create_new_facility": "Create a new facility and add it to the organization.", "create_new_tag": "Create New Tag", "create_position_preset": "Create a new position preset", "create_position_preset_description": "Creates a new position preset in Care from the current position of the camera for the given name", @@ -701,6 +703,7 @@ "created_date": "Created Date", "created_on": "Created On", "creating": "Creating...", + "creating_facility": "Creating Facility...", "criticality": "Criticality", "csv_file_in_the_specified_format": "Select a CSV file in the specified format", "current_address": "Current Address", @@ -815,6 +818,7 @@ "edit_avatar_permission_error": "You do not have permissions to edit the avatar of this user", "edit_caution_note": "A new prescription will be added to the consultation with the edited details and the current prescription will be discontinued.", "edit_cover_photo": "Edit Cover Photo", + "edit_facility": "Edit Facility", "edit_history": "Edit History", "edit_policy": "Edit Insurance Policy", "edit_policy_description": "Add or edit patient's insurance details", @@ -1009,7 +1013,9 @@ "facility_preference": "Facility preference", "facility_search_placeholder_text": "Search by Facility name", "facility_type": "Facility Type", + "facility_type_required": "Facility type is required", "facility_updated_success": "Facility updated successfully", + "facility_updated_successfully": "Facility updated successfully", "failed_to_create_appointment": "Failed to create an appointment", "failed_to_link_abha_number": "Failed to link ABHA Number. Please try again later.", "fast_track_testing_reason": "Fast track testing reason", @@ -1077,7 +1083,9 @@ "geolocation_is_not_supported_by_this_browser": "Geolocation is not supported by this browser", "get_auth_methods": "Get Available Authentication Methods", "get_auth_mode_error": "Could not find any supported authentication methods, Please try again with a different authentication method", + "get_current_location": "Get Current Location", "get_tests": "Get Tests", + "getting_location": "Getting Location...", "go_back": "Go Back", "goal": "Our goal is to continuously improve the quality and accessibility of public healthcare services using digital tools.", "granted_on": "Granted On", @@ -1151,7 +1159,9 @@ "invalid_email": "Please enter a valid email address", "invalid_email_address": "Invalid email address", "invalid_ip_address": "Invalid IP Address", + "invalid_latitude": "Invalid latitude", "invalid_link_msg": "It appears that the password reset link you have used is either invalid or expired. Please request a new password reset link.", + "invalid_longitude": "Invalid longitude", "invalid_otp": "Invalid OTP, Please check the OPT and try Again", "invalid_password": "Password doesn't meet the requirements", "invalid_password_reset_link": "Invalid password reset link", @@ -1247,6 +1257,7 @@ "local_ip_address_example": "e.g. 192.168.0.123", "location": "Location", "location_beds_empty": "No beds available in this location", + "location_details": "Location Details", "location_management": "Location Management", "location_updated_successfully": "Location updated successfully", "log_lab_results": "Log Lab Results", @@ -1463,6 +1474,7 @@ "organization_forbidden": "You don't have access to any organizations yet.", "organization_not_found": "No Organizations Found", "organizations": "Organizations", + "organizations_fetch_error": "Error while fetching organizations", "origin_facility": "Current facility", "other_details": "Other details", "otp_verification_error": "Failed to verify OTP. Please try again later.", @@ -1569,7 +1581,9 @@ "phone_number_verified": "Phone Number Verified", "pincode": "Pincode", "pincode_autofill": "State and District auto-filled from Pincode", + "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", "play": "Play", "play_audio": "Play Audio", "please_assign_bed_to_patient": "Please assign a bed to this patient", @@ -2082,6 +2096,7 @@ "update_asset_service_record": "Update Asset Service Record", "update_available": "Update Available", "update_bed": "Update Bed", + "update_existing_facility": "Update the details of the existing facility.", "update_facility": "Update Facility", "update_facility_middleware_success": "Facility middleware updated successfully", "update_log": "Update Log", @@ -2101,6 +2116,7 @@ "updated_on": "Updated On", "updates": "Updates", "updating": "Updating...", + "updating_facility": "Updating Facility...", "upload": "Upload", "upload_an_image": "Upload an image", "upload_file": "Upload File", @@ -2194,6 +2210,7 @@ "view_users": "View Users", "village": "Village", "virtual_nursing_assistant": "Virtual Nursing Assistant", + "visibility_settings": "Visibility Settings", "vitals": "Vitals", "vitals_monitor": "Vitals Monitor", "vitals_present": "Vitals Monitor present", diff --git a/src/Routers/routes/FacilityRoutes.tsx b/src/Routers/routes/FacilityRoutes.tsx index 44637fdbcf8..655d809bd33 100644 --- a/src/Routers/routes/FacilityRoutes.tsx +++ b/src/Routers/routes/FacilityRoutes.tsx @@ -1,6 +1,5 @@ import { Redirect } from "raviger"; -import { FacilityCreate } from "@/components/Facility/FacilityCreate"; import { FacilityHome } from "@/components/Facility/FacilityHome"; import FacilityUsers from "@/components/Facility/FacilityUsers"; import ResourceCreate from "@/components/Resource/ResourceCreate"; @@ -12,10 +11,7 @@ import FacilityOrganizationView from "@/pages/FacilityOrganization/FacilityOrgan const FacilityRoutes: AppRoutes = { "/facility": () => , - "/facility/create": () => , - "/facility/:facilityId/update": ({ facilityId }) => ( - - ), + "/facility/:facilityId": ({ facilityId }) => ( ), diff --git a/src/Utils/request/api.tsx b/src/Utils/request/api.tsx index 68e3a926e6b..71c2e36f821 100644 --- a/src/Utils/request/api.tsx +++ b/src/Utils/request/api.tsx @@ -196,7 +196,7 @@ const routes = { getPermittedFacility: { path: "/api/v1/facility/{id}/", method: "GET", - TRes: Type(), + TRes: Type(), }, getAnyFacility: { diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 5b6af0ac5a6..df4905709bd 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -1,5 +1,6 @@ import { differenceInMinutes, format } from "date-fns"; import html2canvas from "html2canvas"; +import { toast } from "sonner"; import { AREACODES, IN_LANDLINE_AREA_CODES } from "@/common/constants"; import phoneCodesJson from "@/common/static/countryPhoneAndFlags.json"; @@ -112,6 +113,10 @@ export const getPincodeDetails = async (pincode: string, apiKey: string) => { `https://api.data.gov.in/resource/6176ee09-3d56-4a3b-8115-21841576b2f6?api-key=${apiKey}&format=json&filters[pincode]=${pincode}&limit=1`, ); const data = await response.json(); + if (!data.records || data.records.length === 0) { + toast.error("Invalid pincode"); + return null; + } return data.records[0]; }; diff --git a/src/components/Facility/FacilityCreate.tsx b/src/components/Facility/FacilityCreate.tsx deleted file mode 100644 index 59b87633a8f..00000000000 --- a/src/components/Facility/FacilityCreate.tsx +++ /dev/null @@ -1,521 +0,0 @@ -import { - Popover, - PopoverButton, - PopoverPanel, - Transition, -} from "@headlessui/react"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useQuery } from "@tanstack/react-query"; -import { navigate } from "raviger"; -import { useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; -import { useTranslation } from "react-i18next"; -import { toast } from "sonner"; -import * as z from "zod"; - -import Card from "@/CAREUI/display/Card"; -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import { Button } from "@/components/ui/button"; -import { Checkbox } from "@/components/ui/checkbox"; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Textarea } from "@/components/ui/textarea"; - -import GLocationPicker from "@/components/Common/GLocationPicker"; -import Loading from "@/components/Common/Loading"; -import Page from "@/components/Common/Page"; -import { FacilityRequest } from "@/components/Facility/models"; -import { PhoneNumberValidator } from "@/components/Form/FieldValidators"; -import PhoneNumberFormField from "@/components/Form/FormFields/PhoneNumberFormField"; -import { MultiSelectFormField } from "@/components/Form/FormFields/SelectFormField"; -import TextAreaFormField from "@/components/Form/FormFields/TextAreaFormField"; -import TextFormField from "@/components/Form/FormFields/TextFormField"; - -import useAppHistory from "@/hooks/useAppHistory"; - -import { FACILITY_FEATURE_TYPES, FACILITY_TYPES } from "@/common/constants"; -import { - phonePreg, - validateLatitude, - validateLongitude, - validatePincode, -} from "@/common/validation"; - -import routes from "@/Utils/request/api"; -import query from "@/Utils/request/query"; -import request from "@/Utils/request/request"; -import { parsePhoneNumber } from "@/Utils/utils"; -import OrganizationSelector from "@/pages/Organization/components/OrganizationSelector"; - -interface FacilityProps { - facilityId?: string; -} -export const FacilityCreate = (props: FacilityProps) => { - const { t } = useTranslation(); - const { facilityId } = props; - const [isLoading, setIsLoading] = useState(false); - const { goBack } = useAppHistory(); - - const facilityFormSchema = z.object({ - facility_type: z.string().min(1, { message: t("required") }), - name: z.string().min(1, { message: t("required") }), - description: z.string().optional(), - features: z.array(z.number()).default([]), - pincode: z.string().refine(validatePincode, { - message: t("invalid_pincode"), - }), - geo_organization: z.string().min(1, { message: t("required") }), - address: z.string().min(1, { message: t("required") }), - phone_number: z - .string() - .min(1, { message: t("required") }) - .refine( - (val: string) => { - if ( - !PhoneNumberValidator(["mobile", "landline"])(val) === undefined || - !phonePreg(val) - ) { - return false; - } - return true; - }, - { - message: t("invalid_phone_number"), - }, - ), - latitude: z - .string() - .min(1, { message: t("required") }) - .refine((val) => !val || validateLatitude(val), { - message: t("latitude_invalid"), - }), - longitude: z - .string() - .min(1, { message: t("required") }) - .refine((val) => !val || validateLongitude(val), { - message: t("longitude_invalid"), - }), - is_public: z.boolean().default(false), - }); - - type FacilityFormValues = z.infer; - - const { data: facilityData } = useQuery({ - queryKey: ["facility", facilityId], - queryFn: query(routes.getPermittedFacility, { - pathParams: { id: facilityId || "" }, - }), - enabled: !!facilityId, - }); - - const form = useForm({ - resolver: zodResolver(facilityFormSchema), - defaultValues: { - facility_type: "", - name: "", - description: "", - features: [], - pincode: "", - geo_organization: "", - address: "", - phone_number: "", - latitude: "", - longitude: "", - is_public: false, - }, - }); - - // Update form when facility data is loaded - useEffect(() => { - if (facilityData) { - form.reset({ - facility_type: facilityData.facility_type, - name: facilityData.name, - description: facilityData.description || "", - features: facilityData.features || [], - pincode: facilityData.pincode?.toString() || "", - geo_organization: facilityData.geo_organization, - address: facilityData.address, - phone_number: facilityData.phone_number, - latitude: facilityData.latitude?.toString() || "", - longitude: facilityData.longitude?.toString() || "", - is_public: facilityData.is_public, - }); - } - }, [facilityData, form]); - - const handleLocationChange = (location: google.maps.LatLng | undefined) => { - if (location) { - form.setValue("latitude", location.lat().toFixed(7)); - form.setValue("longitude", location.lng().toFixed(7)); - } - }; - - const handleSelectCurrentLocation = ( - setCenter: (lat: number, lng: number) => void, - ) => { - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition((position) => { - form.setValue("latitude", String(position.coords.latitude)); - form.setValue("longitude", String(position.coords.longitude)); - setCenter?.(position.coords.latitude, position.coords.longitude); - }); - } - }; - - const handleFeatureChange = (value: any) => { - const { value: features }: { value: Array } = value; - form.setValue("features", features); - }; - - const onSubmit = async (data: FacilityFormValues) => { - setIsLoading(true); - try { - const requestData: FacilityRequest = { - ...data, - phone_number: parsePhoneNumber(data.phone_number), - }; - - const { res, data: responseData } = facilityId - ? await request(routes.updateFacility, { - body: requestData, - pathParams: { id: facilityId }, - }) - : await request(routes.createFacility, { - body: requestData, - }); - - if (res?.ok && responseData) { - toast.success( - facilityId - ? t("facility_updated_success") - : t("facility_added_successfully"), - ); - navigate(`/facility/${responseData.id}`); - } - } catch (error) { - console.error(error); - } finally { - setIsLoading(false); - } - }; - - return ( - - -
-
- -
- ( - - {t("facility_type")} - - - - )} - /> - - ( - - {t("facility_name")} - - - - - - )} - /> -
- - ( - - {t("description")} - -