From c9f46e3753ad83ebee9691f8ba89ef5384e72a64 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Wed, 8 May 2024 06:24:54 +0530 Subject: [PATCH] fixed create --- src/Components/Facility/FacilityCreate.tsx | 69 +++++++++++----------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 9fe5bc548ee..67810bbc56c 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -873,40 +873,43 @@ export const FacilityCreate = (props: FacilityProps) => { required types={["mobile", "landline"]} /> - f.id !== facilityId) || - [] - } - optionLabel={(o) => o.name} - optionValue={(o) => o.id} - value={hubFacilities} - onChange={async (event) => { - if (event.value.length > hubFacilities.length) { - await createHub( - event.value[event.value.length - 1] || "", - ); - } else if (event.value.length < hubFacilities.length) { - console.log( - hubFacilities.find((x) => !event.value.includes(x)), - ); - await deleteHub( - hubsQuery.data?.results.find( - (r) => - r.hub.id === - (hubFacilities.find( - (x) => !event.value.includes(x), - ) || ""), - )?.external_id || "", - ); + {facilityId && ( + f.id !== facilityId, + ) || [] } - setHubFacilities(event.value as string[]); - }} - /> + optionLabel={(o) => o.name} + optionValue={(o) => o.id} + value={hubFacilities} + onChange={async (event) => { + if (event.value.length > hubFacilities.length) { + await createHub( + event.value[event.value.length - 1] || "", + ); + } else if (event.value.length < hubFacilities.length) { + console.log( + hubFacilities.find((x) => !event.value.includes(x)), + ); + await deleteHub( + hubsQuery.data?.results.find( + (r) => + r.hub.id === + (hubFacilities.find( + (x) => !event.value.includes(x), + ) || ""), + )?.external_id || "", + ); + } + setHubFacilities(event.value as string[]); + }} + /> + )}