import { SiFacebook, SiX } from '@icons-pack/react-simple-icons' import { useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute, Link, notFound } from '@tanstack/react-router' import { iso31661 } from 'iso-3166' import { ExternalLink, Globe } from 'lucide-react' import { Helmet } from 'react-helmet-async' import { Button } from '~/components/ui/button' import { assetUrl } from '~/lib/directus' import { vendorBySlugQuery } from '~/lib/queries' export const Route = createFileRoute('/vendors/$slug')({ loader: async ({ context: { queryClient }, params: { slug } }) => { const vendor = await queryClient.ensureQueryData(vendorBySlugQuery(slug)) if (!vendor) throw notFound() }, component: VendorDetailPage, }) function countryName(alpha3: string | null | undefined): string { if (!alpha3) return '' return iso31661.find((iso) => iso.alpha3 === alpha3)?.name ?? '' } function VendorDetailPage() { const { slug } = Route.useParams() const { data: vendor } = useSuspenseQuery(vendorBySlugQuery(slug)) if (!vendor) return null const country = countryName(vendor.country) const hasSocial = vendor.website || vendor.facebook || vendor.linkedin || vendor.twitter const hasAddress = vendor.address_line_1 || vendor.address_line_2 || vendor.city || vendor.state || country return (
{vendor.name}

{vendor.name}

{vendor.logo && ( {vendor.name} )}
{vendor.long_description && (
)}
{hasAddress && (

Address

{vendor.address_line_1 && ( <> {vendor.address_line_1}
)} {vendor.address_line_2 && ( <> {vendor.address_line_2}
)} {vendor.city && ( <> {vendor.city}
)} {vendor.state && ( <> {vendor.state}
)} {country && <>{country}}

)} {hasSocial && (

Social

)} {vendor.categories.length > 0 && (

Categories

    {vendor.categories.map((cat) => (
  • ))}
)}
) }