https://dev.kronoz.win/r/marzneshin.git
| 1 |
578311c |
Mrdn |
2y ago |
import { createContext, useContext } from "react"; |
| 2 |
4cebd65 |
Mardin |
2y ago |
import { UseFilteringReturn } from "../hooks"; |
| 3 |
578311c |
Mrdn |
2y ago |
import { Table } from "@tanstack/react-table"; |
| 4 |
578311c |
Mrdn |
2y ago |
|
| 5 |
578311c |
Mrdn |
2y ago |
interface EntityTableContextProps<TData> { |
| 6 |
578311c |
Mrdn |
2y ago |
table: Table<TData> |
| 7 |
578311c |
Mrdn |
2y ago |
data: TData[] |
| 8 |
578311c |
Mrdn |
2y ago |
filtering: UseFilteringReturn |
| 9 |
6b38fe9 |
Mrdn |
2y ago |
isLoading: boolean |
| 10 |
578311c |
Mrdn |
2y ago |
} |
| 11 |
578311c |
Mrdn |
2y ago |
|
| 12 |
578311c |
Mrdn |
2y ago |
export const EntityTableContext = createContext<EntityTableContextProps<any> | null>(null); |
| 13 |
578311c |
Mrdn |
2y ago |
|
| 14 |
578311c |
Mrdn |
2y ago |
export const useEntityTableContext = () => { |
| 15 |
578311c |
Mrdn |
2y ago |
const ctx = useContext(EntityTableContext); |
| 16 |
578311c |
Mrdn |
2y ago |
if (!ctx) |
| 17 |
578311c |
Mrdn |
2y ago |
throw new Error('EntityTable.* component must be rendered as child of EntityTable'); |
| 18 |
578311c |
Mrdn |
2y ago |
return ctx; |
| 19 |
578311c |
Mrdn |
2y ago |
} |