Multi-tenant digital menu platform (Collina Systems): public QR menu with glassmorphism + 3D macro flip cards, mobile-first editor with draft/publish versioning (5-version history + restore), AI consultant & translation (Claude Haiku), realtime orders via SSE, configurable palette, QR generation, superadmin panel, and Docker/Coolify infra.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
'use client';
|
|
|
|
import { useLocale } from 'next-intl';
|
|
import { useRouter } from 'next/navigation';
|
|
import { useTransition } from 'react';
|
|
import { LOCALE_COOKIE, locales, type Locale } from '@/i18n/config';
|
|
|
|
// Floating ES/EN toggle. Writes a cookie and refreshes server components so the
|
|
// whole interface switches instantly.
|
|
export default function LanguageSwitch({ className = '' }: { className?: string }) {
|
|
const locale = useLocale() as Locale;
|
|
const router = useRouter();
|
|
const [pending, startTransition] = useTransition();
|
|
|
|
function setLocale(next: Locale) {
|
|
if (next === locale) return;
|
|
document.cookie = `${LOCALE_COOKIE}=${next}; path=/; max-age=31536000; samesite=lax`;
|
|
startTransition(() => router.refresh());
|
|
}
|
|
|
|
return (
|
|
<div className={`glass-pill inline-flex rounded-full p-1 text-sm ${className}`}>
|
|
{locales.map((l) => (
|
|
<button
|
|
key={l}
|
|
onClick={() => setLocale(l)}
|
|
disabled={pending}
|
|
className={`rounded-full px-3 py-1 font-medium uppercase transition ${
|
|
l === locale ? 'bg-white/70 text-[var(--text)] shadow' : 'text-[var(--text)]/60'
|
|
}`}
|
|
>
|
|
{l}
|
|
</button>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|