forked from rajun/ar-test
feat: add asset list
This commit is contained in:
parent
ade61e299a
commit
f76a442367
37
app/components/assets/list/asset-list.tsx
Normal file
37
app/components/assets/list/asset-list.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { useCallback } from 'react';
|
||||
import { EmptyState } from '~/components/ui/empty-state';
|
||||
import { AssetCard } from '~/components/assets/list/asset-card';
|
||||
import { AssetPagination } from '~/components/assets/list/asset-pagination';
|
||||
import { useAdminDialogs } from '~/hooks/admin/use-admin-dialogs';
|
||||
import type { ArAsset, AssetPage } from '~/types/asset';
|
||||
|
||||
interface AssetListProps {
|
||||
assets: AssetPage;
|
||||
showProject: boolean;
|
||||
emptyTitle: string;
|
||||
emptyMessage?: string;
|
||||
}
|
||||
|
||||
export function AssetList({ assets, showProject, emptyTitle, emptyMessage }: AssetListProps) {
|
||||
const { openAsset, confirmDeleteAsset } = useAdminDialogs();
|
||||
const editAsset = useCallback((asset: ArAsset) => openAsset({ asset }), [openAsset]);
|
||||
|
||||
if (assets.items.length === 0) return <EmptyState title={emptyTitle} message={emptyMessage} />;
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-6'>
|
||||
<div className='grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3.5'>
|
||||
{assets.items.map((asset) => (
|
||||
<AssetCard
|
||||
key={asset.id}
|
||||
asset={asset}
|
||||
showProject={showProject}
|
||||
onEdit={editAsset}
|
||||
onDelete={confirmDeleteAsset}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<AssetPagination page={assets.page} totalPages={assets.totalPages} totalItems={assets.totalItems} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user