feat: add customer view preview
This commit is contained in:
parent
ce025bf6cd
commit
907170a152
36
app/components/assets/detail/customer-view.tsx
Normal file
36
app/components/assets/detail/customer-view.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { ArPagePreview } from '~/components/ui/ar-page-preview';
|
||||||
|
import { Card } from '~/components/ui/card';
|
||||||
|
import { ModelViewer } from '~/components/ui/model-viewer';
|
||||||
|
import { Text } from '~/components/ui/text';
|
||||||
|
import { useAdminData } from '~/hooks/admin/use-admin-data';
|
||||||
|
import { useModelViewerReady } from '~/hooks/use-model-viewer-ready';
|
||||||
|
import { getArPageLayout, getButtonStyle, getGlbUrl, getUsdzUrl, toBrand } from '~/services/asset-media';
|
||||||
|
import type { ArAsset } from '~/types/asset';
|
||||||
|
|
||||||
|
// What a customer sees after scanning the QR, with the real 3D model
|
||||||
|
export function CustomerView({ asset }: { asset: ArAsset }) {
|
||||||
|
const { settings } = useAdminData();
|
||||||
|
const ready = useModelViewerReady();
|
||||||
|
const project = asset.expand?.project;
|
||||||
|
const glbUrl = getGlbUrl(asset);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card surface='well' size='lg' className='flex flex-col items-center gap-3.5 px-5 pt-6 pb-7'>
|
||||||
|
<div className='flex items-baseline justify-between gap-3 self-stretch'>
|
||||||
|
<Text as='h2' variant='body-strong'>Customer view</Text>
|
||||||
|
<Text variant='caption'>After scanning the QR</Text>
|
||||||
|
</div>
|
||||||
|
<ArPagePreview
|
||||||
|
brand={project ? toBrand(project) : undefined}
|
||||||
|
modelName={asset.name}
|
||||||
|
button={getButtonStyle(project, settings)}
|
||||||
|
layout={getArPageLayout(project)}
|
||||||
|
className='h-[620px] w-[300px] max-w-full'
|
||||||
|
>
|
||||||
|
{ready && glbUrl ? (
|
||||||
|
<ModelViewer src={glbUrl} ios-src={getUsdzUrl(asset)} auto-rotate exposure='1' alt={asset.name} className='absolute inset-0' />
|
||||||
|
) : undefined}
|
||||||
|
</ArPagePreview>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user