'use client' import { useState } from 'react' import { useTranslations } from 'next-intl' import { ArrowUpRight, Building2, Loader2 } from 'lucide-react' import { performCompanySwitch } from '@/lib/company/switch-client' import { useToast } from '@/components/ui/use-toast' /** * The home-domain signpost (WL-01): shown instead of the dashboard when the * active company is homed on another domain. Never a silent redirect: * sessions are per domain, so the user must log in again over there, and the * signpost explains why. Companies homed HERE are offered as one-click * switches; companies homed elsewhere link to their home domain. */ export default function HomeDomainSignpost({ activeCompanyName, homedCompanies, foreignCompanies, }: { activeCompanyName: string homedCompanies: Array<{ id: string; name: string }> foreignCompanies: Array<{ id: string; name: string; domain: string }> }) { const t = useTranslations('signpost') const { toast } = useToast() const [pendingId, setPendingId] = useState(null) const handleSwitch = async (companyId: string) => { setPendingId(companyId) const result = await performCompanySwitch(companyId, { destination: '/' }) if (result?.error) { setPendingId(null) toast({ title: t('switch_failed'), variant: 'destructive' }) } } return (

{t('title')}

{t('body', { company: activeCompanyName })}

{foreignCompanies.length > 0 && (

{t('login_hint')}

)} {homedCompanies.length > 0 && (

{t('homed_here')}

    {homedCompanies.map((entry) => (
  • ))}
)}
) }