gitscope
← marzneshin / v0.5.5 / dashboard/src/features/entity-table/hooks/use-entity-query.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/entity-table/hooks/use-entity-query.ts · TypeScript
Blame Raw
 1
 2interface PaginatedEntityQueryProps {
 3    page: number;
 4    size: number;
 5}
 6
 7export type FilteredEntityType = {
 8    [key: string]: string | undefined;
 9}
10
11export interface SortedEntityQueryProps {
12    sortBy: string
13    desc: boolean
14}
15
16interface FiltersEntityQueryProps {
17    filters: FilteredEntityType;
18}
19
20export type UseEntityQueryProps = Partial<FiltersEntityQueryProps> & PaginatedEntityQueryProps & Partial<SortedEntityQueryProps>
21
22export type EntityName = string;
23export type EntityId = number | string | undefined;
24export type PrimaryFilter = string;
25
26export type QueryKey =
27    [EntityName, PaginatedEntityQueryProps, PrimaryFilter, SortedEntityQueryProps, FiltersEntityQueryProps]
28
29export type SidebarQueryKey =
30    [EntityName, EntityId, EntityName, PaginatedEntityQueryProps, PrimaryFilter, SortedEntityQueryProps, FiltersEntityQueryProps]
31
32export interface QueryKeyType<QT> {
33    queryKey: QT
34}
35
36export type EntityQueryKeyType = QueryKeyType<QueryKey>
37export type EntitySidebarQueryKeyType = QueryKeyType<SidebarQueryKey>
38
39interface FetchEntityResult<T> {
40    pageCount: number
41    entity: T[]
42}
43
44export type FetchEntityReturn<T> = Promise<FetchEntityResult<T>>