({ workspaceId, tableId }: RowMutationContext)
| 1018 | * Delete a single row from a table. |
| 1019 | */ |
| 1020 | export function useDeleteTableRow({ workspaceId, tableId }: RowMutationContext) { |
| 1021 | const queryClient = useQueryClient() |
| 1022 | |
| 1023 | return useMutation({ |
| 1024 | mutationFn: async (rowId: string) => { |
| 1025 | return requestJson(deleteTableRowContract, { |
| 1026 | params: { tableId, rowId }, |
| 1027 | body: { workspaceId }, |
| 1028 | }) |
| 1029 | }, |
| 1030 | onError: (error) => { |
| 1031 | if (isValidationError(error)) return |
| 1032 | toast.error(error.message, { duration: 5000 }) |
| 1033 | }, |
| 1034 | onSettled: () => { |
| 1035 | invalidateRowCount(queryClient, tableId) |
| 1036 | }, |
| 1037 | }) |
| 1038 | } |
| 1039 | |
| 1040 | /** |
| 1041 | * Delete multiple rows from a table. |
no test coverage detected