feat: add asset QR panel
This commit is contained in:
parent
6cca8610d9
commit
ce025bf6cd
40
app/components/assets/detail/asset-qr-panel.tsx
Normal file
40
app/components/assets/detail/asset-qr-panel.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user