()
| 1371 | * Restore an archived table. |
| 1372 | */ |
| 1373 | export function useRestoreTable() { |
| 1374 | const queryClient = useQueryClient() |
| 1375 | |
| 1376 | return useMutation({ |
| 1377 | mutationFn: async (tableId: string) => { |
| 1378 | return requestJson(restoreTableContract, { |
| 1379 | params: { tableId }, |
| 1380 | }) |
| 1381 | }, |
| 1382 | onError: (error) => { |
| 1383 | if (isValidationError(error)) return |
| 1384 | toast.error(error.message, { duration: 5000 }) |
| 1385 | }, |
| 1386 | onSuccess: (response, tableId) => { |
| 1387 | queryClient.setQueryData(tableKeys.detail(tableId), response.data.table) |
| 1388 | queryClient.removeQueries({ queryKey: tableKeys.rowsRoot(tableId) }) |
| 1389 | }, |
| 1390 | onSettled: (_data, _error, tableId) => { |
| 1391 | return Promise.all([ |
| 1392 | queryClient.invalidateQueries({ queryKey: tableKeys.lists() }), |
| 1393 | queryClient.invalidateQueries({ queryKey: tableKeys.detail(tableId) }), |
| 1394 | queryClient.invalidateQueries({ queryKey: tableKeys.rowsRoot(tableId) }), |
| 1395 | ]) |
| 1396 | }, |
| 1397 | }) |
| 1398 | } |
| 1399 | |
| 1400 | interface UploadCsvParams { |
| 1401 | workspaceId: string |
no test coverage detected