MCPcopy Index your code
hub / github.com/simstudioai/sim / useRestoreTable

Function useRestoreTable

apps/sim/hooks/queries/tables.ts:1373–1398  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1371 * Restore an archived table.
1372 */
1373export 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
1400interface UploadCsvParams {
1401 workspaceId: string

Callers 2

RecentlyDeletedFunction · 0.90
tables.test.tsFile · 0.90

Calls 3

requestJsonFunction · 0.90
isValidationErrorFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected