diff --git a/assets/api/service.ts b/assets/api/service.ts index 3b5fb5cd..4bf2eee6 100644 --- a/assets/api/service.ts +++ b/assets/api/service.ts @@ -14,16 +14,13 @@ const getOfferings = (datastoreId: string) => { return jsonFetch(url); }; -/** - * Demande la suppression de l'offering et puis la configuration - */ -const unpublish = (datastoreId: string, offeringId: string) => { - const url = SymfonyRouting.generate("cartesgouvfr_api_service_unpublish", { datastoreId, offeringId }); - return jsonFetch(url, { +const unpublishWfs = (datastoreId: string, offeringId: string) => { + const url = SymfonyRouting.generate("cartesgouvfr_api_service_wfs_unpublish", { datastoreId, offeringId }); + return jsonFetch(url, { method: "DELETE", }); }; -const service = { get, getOfferings, unpublish }; +const service = { get, getOfferings, unpublishWfs }; export default service; diff --git a/assets/api/wfs.ts b/assets/api/wfs.ts index 24a4780e..32c7d900 100644 --- a/assets/api/wfs.ts +++ b/assets/api/wfs.ts @@ -17,6 +17,6 @@ const add = (datastoreId: string, storedDataId: string, formData: FormData | obj ); }; -export default { - add, -}; +const wfs = { add }; + +export default wfs; diff --git a/assets/pages/datasheet/DatasheetView/ServiceListTab/ServicesListItem.tsx b/assets/pages/datasheet/DatasheetView/ServiceListTab/ServicesListItem.tsx index f10fcc95..472d8a53 100644 --- a/assets/pages/datasheet/DatasheetView/ServiceListTab/ServicesListItem.tsx +++ b/assets/pages/datasheet/DatasheetView/ServiceListTab/ServicesListItem.tsx @@ -30,8 +30,16 @@ const ServicesListItem: FC = ({ service, datasheetName, d const queryClient = useQueryClient(); const unpublishServiceMutation = useMutation({ - mutationFn: () => api.service.unpublish(datastoreId, service._id), - onSuccess() { + mutationFn: () => { + switch (service.type) { + case "WFS": + return api.service.unpublishWfs(datastoreId, service._id); + default: + console.warn(`Dépublication de service ${service.type} n'a pas encore été implémentée`); + return Promise.reject(`Dépublication de service ${service.type} n'a pas encore été implémentée`); + } + }, + onSettled() { queryClient.refetchQueries({ queryKey: RQKeys.datastore_datasheet(datastoreId, datasheetName) }); }, }); diff --git a/src/Controller/Api/ServiceController.php b/src/Controller/Api/ServiceController.php index 9b0c7965..50a3282c 100644 --- a/src/Controller/Api/ServiceController.php +++ b/src/Controller/Api/ServiceController.php @@ -49,7 +49,7 @@ public function getOffering(string $datastoreId, string $offeringId): JsonRespon } } - #[Route('/{offeringId}', name: 'unpublish', methods: ['DELETE'])] + #[Route('/{offeringId}', name: 'wfs_unpublish', methods: ['DELETE'])] public function unpublish(string $datastoreId, string $offeringId): Response { try {