Login-text, Context menu QoL enhancements
This commit is contained in:
@@ -15,6 +15,7 @@ interface PaginatedTableProps<TData> extends Omit<SortableTableProps<TData>, "da
|
||||
showEditButton?: boolean;
|
||||
searchFields?: string[];
|
||||
include?: Record<string, boolean>;
|
||||
strictQuery?: boolean;
|
||||
leftOfSearch?: React.ReactNode;
|
||||
rightOfSearch?: React.ReactNode;
|
||||
leftOfPagination?: React.ReactNode;
|
||||
@@ -30,6 +31,7 @@ export function PaginatedTable<TData>({
|
||||
filter,
|
||||
include,
|
||||
ref,
|
||||
strictQuery = false,
|
||||
leftOfSearch,
|
||||
rightOfSearch,
|
||||
leftOfPagination,
|
||||
@@ -63,6 +65,15 @@ export function PaginatedTable<TData>({
|
||||
filter,
|
||||
include,
|
||||
orderBy,
|
||||
strictQuery
|
||||
? restProps.columns
|
||||
.filter((col: any) => "accessorKey" in col)
|
||||
.map((col: any) => col.accessorKey)
|
||||
.reduce((acc: Record<string, any>, key: string) => {
|
||||
acc[key] = true;
|
||||
return acc;
|
||||
}, {})
|
||||
: undefined,
|
||||
).then((result) => {
|
||||
if (result) {
|
||||
setData(result.data);
|
||||
|
||||
@@ -11,6 +11,7 @@ export async function getData(
|
||||
filter?: Record<string, any>,
|
||||
include?: Record<string, boolean>,
|
||||
orderBy?: Record<string, "asc" | "desc">,
|
||||
select?: Record<string, any>,
|
||||
) {
|
||||
if (!model || !prisma[model]) {
|
||||
return { data: [], total: 0 };
|
||||
@@ -33,13 +34,13 @@ export async function getData(
|
||||
if (!prisma[model]) {
|
||||
return { data: [], total: 0 };
|
||||
}
|
||||
|
||||
const data = await (prisma[model] as any).findMany({
|
||||
where,
|
||||
orderBy,
|
||||
take: limit,
|
||||
skip: offset,
|
||||
include,
|
||||
select,
|
||||
});
|
||||
|
||||
const total = await (prisma[model] as any).count({ where });
|
||||
|
||||
Reference in New Issue
Block a user