teableio/teable

View on GitHub
packages/sdk/src/hooks/use-table-permission.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { useContext, useMemo } from 'react';
import { TablePermissionContext } from '../context/table-permission';

export type IUseTablePermissionAction = keyof ReturnType<typeof useTablePermission>;

// check table, view, record exclude field
export const useTablePermission = () => {
  const { table, view, record, field } = useContext(TablePermissionContext);
  return useMemo(() => {
    return { ...table, ...view, ...record, ['field|create']: field?.create };
  }, [table, view, record, field?.create]);
};