commit
This commit is contained in:
42
src/types/data-table.ts
Normal file
42
src/types/data-table.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { DataTableConfig } from '@/config/data-table';
|
||||
import type { FilterItemSchema } from '@/lib/parsers';
|
||||
import type { ColumnSort, Row, RowData } from '@tanstack/react-table';
|
||||
|
||||
declare module '@tanstack/react-table' {
|
||||
// biome-ignore lint/correctness/noUnusedVariables: Interface type parameters required by @tanstack/react-table
|
||||
interface ColumnMeta<TData extends RowData, TValue> {
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
variant?: FilterVariant;
|
||||
options?: Option[];
|
||||
range?: [number, number];
|
||||
unit?: string;
|
||||
icon?: React.FC<React.SVGProps<SVGSVGElement>>;
|
||||
headerClassName?: string;
|
||||
cellClassName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Option {
|
||||
label: string;
|
||||
value: string;
|
||||
count?: number;
|
||||
icon?: React.FC<React.SVGProps<SVGSVGElement>>;
|
||||
}
|
||||
|
||||
export type FilterOperator = DataTableConfig['operators'][number];
|
||||
export type FilterVariant = DataTableConfig['filterVariants'][number];
|
||||
export type JoinOperator = DataTableConfig['joinOperators'][number];
|
||||
|
||||
export interface ExtendedColumnSort<TData> extends Omit<ColumnSort, 'id'> {
|
||||
id: Extract<keyof TData, string>;
|
||||
}
|
||||
|
||||
export interface ExtendedColumnFilter<TData> extends FilterItemSchema {
|
||||
id: Extract<keyof TData, string>;
|
||||
}
|
||||
|
||||
export interface DataTableRowAction<TData> {
|
||||
row: Row<TData>;
|
||||
variant: 'update' | 'delete';
|
||||
}
|
||||
56
src/types/index.ts
Normal file
56
src/types/index.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Icons } from '@/components/icons';
|
||||
import type { Permission } from '@/lib/auth/permissions';
|
||||
import type { BusinessRole } from '@/lib/auth/roles';
|
||||
|
||||
export interface PermissionCheck {
|
||||
permission?: Permission;
|
||||
anyPermissions?: Permission[];
|
||||
allPermissions?: Permission[];
|
||||
plan?: string;
|
||||
feature?: string;
|
||||
role?: string;
|
||||
businessRole?: BusinessRole;
|
||||
businessRoles?: BusinessRole[];
|
||||
systemRole?: string;
|
||||
requireOrg?: boolean;
|
||||
}
|
||||
|
||||
export interface NavItem {
|
||||
title: string;
|
||||
url: string;
|
||||
disabled?: boolean;
|
||||
external?: boolean;
|
||||
shortcut?: [string, string];
|
||||
icon?: keyof typeof Icons;
|
||||
label?: string;
|
||||
description?: string;
|
||||
isActive?: boolean;
|
||||
items?: NavItem[];
|
||||
access?: PermissionCheck;
|
||||
}
|
||||
|
||||
export interface NavGroup {
|
||||
label: string;
|
||||
items: NavItem[];
|
||||
}
|
||||
|
||||
export interface NavItemWithChildren extends NavItem {
|
||||
items: NavItemWithChildren[];
|
||||
}
|
||||
|
||||
export interface NavItemWithOptionalChildren extends NavItem {
|
||||
items?: NavItemWithChildren[];
|
||||
}
|
||||
|
||||
export interface FooterItem {
|
||||
title: string;
|
||||
items: {
|
||||
title: string;
|
||||
href: string;
|
||||
external?: boolean;
|
||||
}[];
|
||||
}
|
||||
|
||||
export type MainNavItem = NavItemWithOptionalChildren;
|
||||
|
||||
export type SidebarNavItem = NavItemWithChildren;
|
||||
48
src/types/next-auth.d.ts
vendored
Normal file
48
src/types/next-auth.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { DefaultSession } from 'next-auth';
|
||||
import type { Permission } from '@/lib/auth/permissions';
|
||||
|
||||
declare module 'next-auth' {
|
||||
interface Session {
|
||||
user: DefaultSession['user'] & {
|
||||
id: string;
|
||||
systemRole: string;
|
||||
activeOrganizationId: string | null;
|
||||
activeOrganizationName: string | null;
|
||||
activeOrganizationPlan: string | null;
|
||||
membershipRole: string | null;
|
||||
role: string | null;
|
||||
employeeCode: string | null;
|
||||
employeeId: number | null;
|
||||
provider: string | null;
|
||||
businessRole: 'IT' | 'HRD' | 'EMPLOYEE' | null;
|
||||
permissions: Permission[];
|
||||
effectivePermissions: Permission[];
|
||||
permissionTemplateIds: number[];
|
||||
organizations: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
membershipRole: string;
|
||||
role: string;
|
||||
plan: string;
|
||||
imageUrl: string | null;
|
||||
permissionTemplateIds: number[];
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
systemRole?: string;
|
||||
activeOrganizationId?: string | null;
|
||||
employeeCode?: string | null;
|
||||
employeeId?: number | null;
|
||||
provider?: string | null;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'next-auth/jwt' {
|
||||
interface JWT {
|
||||
sub?: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user