import { useEffect, useState } from 'react'; import { Link, useParams, useSearchParams } from 'react-router-dom'; import { api, assetUrl, CardDesign, StoreDetail } from '../api'; import { Poster, PosterFormat } from '../components/Poster'; /** Page d'impression de l'affichette, sans la mise en page de l'admin. */ export function PosterPage({ merchant = false }: { merchant?: boolean }) { const { id } = useParams<{ id: string }>(); const storePath = merchant ? '/api/staff/store' : `/api/admin/stores/${id}`; const designPath = merchant ? '/api/staff/card-design' : `/api/admin/stores/${id}/card-design`; const [params, setParams] = useSearchParams(); const format: PosterFormat = params.get('format') === 'A6' ? 'A6' : 'A5'; const [store, setStore] = useState(null); const [design, setDesign] = useState(null); const [error, setError] = useState(null); useEffect(() => { Promise.all([api.get(storePath), api.get(designPath)]) .then(([s, d]) => { setStore(s); setDesign(d); }) .catch((e) => setError(e.message)); }, [storePath, designPath]); if (error) return
{error}
; if (!store) return

Chargement…

; if (!design) return
Concevez d'abord la carte de fidélité.
; return (
← Retour à la carte
{(['A5', 'A6'] as const).map((f) => ( ))}
{store.status !== 'ACTIVE' && (
Le magasin n'est pas actif : le QR mène pour l'instant à une page « introuvable » ou « indisponible ».
)}

{store.enrollUrl}

); }