41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
import { Download } from 'lucide-react';
|
|
import { Button } from '~/components/ui/button';
|
|
import { Card } from '~/components/ui/card';
|
|
import { CopyField } from '~/components/ui/copy-field';
|
|
import { AssetQr } from '~/components/assets/asset-qr';
|
|
import { AssetDetailList } from '~/components/assets/detail/asset-detail-list';
|
|
import { UnassignedNote } from '~/components/assets/detail/unassigned-note';
|
|
import { getArUrl } from '~/lib/assets/qr';
|
|
import { downloadQr } from '~/lib/assets/qr-export';
|
|
import { toFileName } from '~/lib/format';
|
|
import { isBrandedQr, toBrand } from '~/services/asset-media';
|
|
import type { ArAsset } from '~/types/asset';
|
|
|
|
export function AssetQrPanel({ asset }: { asset: ArAsset }) {
|
|
const arUrl = getArUrl(asset.id);
|
|
const project = asset.expand?.project;
|
|
const brand = project && isBrandedQr(asset) ? toBrand(project) : undefined;
|
|
const fileName = `${toFileName(asset.name)}_qr`;
|
|
const formats = [
|
|
{ format: 'png', label: 'QR · PNG', variant: 'default' },
|
|
{ format: 'svg', label: 'QR · SVG', variant: 'secondary' },
|
|
] as const;
|
|
|
|
return (
|
|
<Card size='lg' className='flex flex-col gap-[18px] p-5'>
|
|
<AssetQr asset={asset} size='panel' className='self-center' />
|
|
<CopyField value={arUrl} label='AR link' />
|
|
<div className='grid grid-cols-2 gap-2.5'>
|
|
{formats.map(({ format, label, variant }) => (
|
|
<Button key={format} variant={variant} onClick={() => downloadQr(format, arUrl, fileName, brand)}>
|
|
<Download size={13} />
|
|
{label}
|
|
</Button>
|
|
))}
|
|
</div>
|
|
<AssetDetailList asset={asset} />
|
|
{!project && <UnassignedNote />}
|
|
</Card>
|
|
);
|
|
}
|