feat: add asset card
This commit is contained in:
parent
dce9e4fd2d
commit
7dea0dace0
41
app/components/assets/list/asset-card.tsx
Normal file
41
app/components/assets/list/asset-card.tsx
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { memo } from 'react';
|
||||||
|
import { Link } from 'react-router';
|
||||||
|
import { Pencil, Trash2 } from 'lucide-react';
|
||||||
|
import { Button } from '~/components/ui/button';
|
||||||
|
import { Card } from '~/components/ui/card';
|
||||||
|
import { TextPair } from '~/components/ui/text-pair';
|
||||||
|
import { AssetQr } from '~/components/assets/asset-qr';
|
||||||
|
import { AssetProjectChip } from '~/components/assets/list/asset-project-chip';
|
||||||
|
import { ROUTES } from '~/data/routes';
|
||||||
|
import { formatDate } from '~/lib/format';
|
||||||
|
import type { ArAsset } from '~/types/asset';
|
||||||
|
|
||||||
|
interface AssetCardProps {
|
||||||
|
asset: ArAsset;
|
||||||
|
showProject: boolean;
|
||||||
|
onEdit: (asset: ArAsset) => void;
|
||||||
|
onDelete: (asset: ArAsset) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AssetCard = memo(function AssetCard({ asset, showProject, onEdit, onDelete }: AssetCardProps) {
|
||||||
|
const name = asset.name || 'Untitled';
|
||||||
|
return (
|
||||||
|
<Card size='sm' interactive className='relative flex flex-col gap-3 p-[13px]'>
|
||||||
|
<AssetQr asset={asset} size='card' />
|
||||||
|
<div className='flex items-start justify-between gap-2'>
|
||||||
|
<Link to={ROUTES.asset(asset.id)} aria-label={`Open ${name}`} className='min-w-0 after:absolute after:inset-0'>
|
||||||
|
<TextPair as='h3' title={name} meta={formatDate(asset.created)} />
|
||||||
|
</Link>
|
||||||
|
<div className='relative z-10 flex shrink-0 gap-0.5'>
|
||||||
|
<Button variant='ghost' size='icon-sm' aria-label={`Edit ${name}`} onClick={() => onEdit(asset)}>
|
||||||
|
<Pencil size={13} />
|
||||||
|
</Button>
|
||||||
|
<Button variant='ghost' size='icon-sm' aria-label={`Delete ${name}`} className='hover:text-danger' onClick={() => onDelete(asset)}>
|
||||||
|
<Trash2 size={13} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{showProject && <AssetProjectChip project={asset.expand?.project} />}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user