forked from rajun/ar-test
feat: add asset preview header
This commit is contained in:
parent
30126d9280
commit
238431d801
46
app/components/assets/detail/asset-preview-header.tsx
Normal file
46
app/components/assets/detail/asset-preview-header.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { Link } from 'react-router';
|
||||
import { Button } from '~/components/ui/button';
|
||||
import { ClientLogo } from '~/components/ui/client-logo';
|
||||
import { PageBreadcrumb } from '~/components/ui/page-breadcrumb';
|
||||
import { Text } from '~/components/ui/text';
|
||||
import { ASSET_FILTER } from '~/data/assets/constants';
|
||||
import { ROUTES } from '~/data/routes';
|
||||
import { formatDate } from '~/lib/format';
|
||||
import { toBrand } from '~/services/asset-media';
|
||||
import type { ArAsset } from '~/types/asset';
|
||||
|
||||
interface AssetPreviewHeaderProps {
|
||||
asset: ArAsset;
|
||||
onEdit: () => void;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
export function AssetPreviewHeader({ asset, onEdit, onDelete }: AssetPreviewHeaderProps) {
|
||||
const project = asset.expand?.project;
|
||||
const parent = project
|
||||
? { label: project.name, to: ROUTES.project(project.id) }
|
||||
: { label: 'Unassigned', to: ROUTES.assetsFiltered(ASSET_FILTER.unassigned) };
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageBreadcrumb trail={[{ label: 'Projects', to: ROUTES.projects }, parent]} current={asset.name} />
|
||||
<div className='flex flex-wrap items-end justify-between gap-4'>
|
||||
<div className='flex min-w-0 flex-col gap-2.5'>
|
||||
<Text as='h1' variant='display'>{asset.name}</Text>
|
||||
<div className='flex flex-wrap items-center gap-2.5'>
|
||||
{project && <ClientLogo brand={toBrand(project)} variant='chip' size='sm' />}
|
||||
<Link to={parent.to} className='text-text-emphasis transition-colors hover:text-primary'>
|
||||
<Text as='span' tone='inherit'>{parent.label}</Text>
|
||||
</Link>
|
||||
<Text as='span' tone='faint'>·</Text>
|
||||
<Text as='span' tone='muted'>Created {formatDate(asset.created)}</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex gap-2.5'>
|
||||
<Button variant='secondary' onClick={onEdit}>Edit asset</Button>
|
||||
<Button variant='destructive' onClick={onDelete}>Delete</Button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user