diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt index 26f3e2ea2e..f8bccb19cc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingController.kt @@ -52,7 +52,7 @@ class ReportingController( archiveReporting.execute(reportingId) } - @PutMapping(value = ["/{reportingId}/update"], consumes = ["application/json"]) + @PutMapping(value = ["/{reportingId}"], consumes = ["application/json"]) @Operation(summary = "Update a reporting") fun updateReporting( @PathParam("Reporting id") @@ -78,7 +78,7 @@ class ReportingController( archiveReportings.execute(ids) } - @PutMapping(value = ["/{reportingId}/delete"]) + @DeleteMapping(value = ["/{reportingId}"]) @Operation(summary = "Delete a reporting") fun deleteReporting( @PathParam("Reporting id") @@ -88,7 +88,7 @@ class ReportingController( deleteReporting.execute(reportingId) } - @PutMapping(value = ["/delete"]) + @DeleteMapping(value = [""]) @Operation(summary = "Delete multiple reportings") fun deleteReporting( @RequestBody ids: List, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt index 3d385b4f3a..6a6e181b1b 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt @@ -89,7 +89,7 @@ class ReportingControllerITests { @Test fun `Should delete a reporting`() { // When - api.perform(put("/bff/v1/reportings/123/delete")) + api.perform(delete("/bff/v1/reportings/123")) // Then .andExpect(status().isOk) @@ -100,7 +100,7 @@ class ReportingControllerITests { fun `Should delete multiple reportings`() { // When api.perform( - put("/bff/v1/reportings/delete") + delete("/bff/v1/reportings") .content(objectMapper.writeValueAsString(listOf(1, 2, 3))) .contentType(MediaType.APPLICATION_JSON), ) @@ -299,7 +299,7 @@ class ReportingControllerITests { // When api.perform( - put("/bff/v1/reportings/123/update") + put("/bff/v1/reportings/123") .content( objectMapper.writeValueAsString( UpdateReportingDataInput( diff --git a/frontend/src/features/Reporting/reportingApi.ts b/frontend/src/features/Reporting/reportingApi.ts index 6a2022e6dc..fe5a858e48 100644 --- a/frontend/src/features/Reporting/reportingApi.ts +++ b/frontend/src/features/Reporting/reportingApi.ts @@ -49,23 +49,21 @@ export const reportingApi = monitorfishApi.injectEndpoints({ transformErrorResponse: response => new FrontendApiError(CREATE_REPORTING_ERROR_MESSAGE, response) }), - // TODO Replace Backend route with a DELETE instead of a PUT. deleteReporting: builder.mutation({ invalidatesTags: [{ type: RtkCacheTagType.Reportings }], query: reportingId => ({ - method: 'PUT', - url: `/reportings/${reportingId}/delete` + method: 'DELETE', + url: `/reportings/${reportingId}` }), transformErrorResponse: response => new FrontendApiError(DELETE_REPORTING_ERROR_MESSAGE, response) }), - // TODO Replace Backend route with a DELETE instead of a PUT. deleteReportings: builder.mutation({ invalidatesTags: [{ type: RtkCacheTagType.Reportings }], query: reportingIds => ({ body: reportingIds, - method: 'PUT', - url: `/reportings/delete` + method: 'DELETE', + url: `/reportings` }), transformErrorResponse: response => new FrontendApiError(DELETE_REPORTINGS_ERROR_MESSAGE, response) }), @@ -79,13 +77,12 @@ export const reportingApi = monitorfishApi.injectEndpoints({ transformErrorResponse: response => new FrontendApiError(GET_REPORTINGS_ERROR_MESSAGE, response) }), - // TODO Remove the useless "/update" route part in Backend. updateReporting: builder.mutation({ invalidatesTags: [{ type: RtkCacheTagType.Reportings }], query: ({ id, nextReportingFormData }) => ({ body: nextReportingFormData, method: 'PUT', - url: `/reportings/${id}/update` + url: `/reportings/${id}` }), transformErrorResponse: response => new FrontendApiError(UPDATE_REPORTING_ERROR_MESSAGE, response) })