NORY-15: add data-table fallback component
This component can be used as suspense fallback for data tables
This commit is contained in:
parent
cf96a98f91
commit
1b7e1c2cca
1 changed files with 53 additions and 0 deletions
53
dashboard/src/components/ui/data-table-fallback.tsx
Normal file
53
dashboard/src/components/ui/data-table-fallback.tsx
Normal file
|
@ -0,0 +1,53 @@
|
|||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
|
||||
interface DataTableFallbackProps {
|
||||
columnCount: number,
|
||||
rowCount: number,
|
||||
}
|
||||
|
||||
export async function DataTableFallback({ columnCount, rowCount }: DataTableFallbackProps) {
|
||||
|
||||
const columns: string[] = [];
|
||||
for (let i = 0; i < columnCount; i++) {
|
||||
columns.push('');
|
||||
}
|
||||
|
||||
const rows: string[] = [];
|
||||
for (let i = 0; i < rowCount; i++) {
|
||||
rows.push('');
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rounded-md border">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
{
|
||||
columns.map((_, index) => {
|
||||
return (
|
||||
<TableHead key={index}>
|
||||
<Skeleton className="w-20 h-6"/>
|
||||
</TableHead>
|
||||
);
|
||||
})
|
||||
}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{
|
||||
rows.map((_, index) =>
|
||||
<TableRow key={index} className="h-4">
|
||||
{
|
||||
columns.map((_, index) =>
|
||||
<TableCell key={index} className="h-4">
|
||||
<Skeleton className="w-full h-4"/>
|
||||
</TableCell>,
|
||||
)
|
||||
}
|
||||
</TableRow>,
|
||||
)
|
||||
}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Reference in a new issue