Fonts switched to Montserrat (UI) + Merriweather (landing wordmark). Macro protein standard color updated to #dc2626; primary actions hardcoded red. New globals.css primitives: ai-smoke gradient buttons, seg-btn, sticky cat-bar, editor dock-*, macro shimmer, delivery-timer pulses, liquid-btn, aurora, editable-num. - Public: landing (video bg + red CTA), PublicMenu (segmented toggle + "Preguntar a Claude" + sticky category bar w/ scroll-spy + Order/Waiter/ Split FABs), DishCard flip, MacrosBack shimmer, BrandHeader, SplitPanel, AiConsultant. - Editor: bottom dock navigation, EditorLogin video background, BrandTab, CatalogTab (+SectionTitleEditor), VersionHistory, OrdersTab, ProductEditor. - Admin: AdminLogin, AdminPanel. - Add landing/editor background videos under public/videos. - ES/EN i18n keys added; FRONTEND.md updated; design mockups included. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
120 lines
4.1 KiB
TypeScript
120 lines
4.1 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import { useTranslations } from 'next-intl';
|
|
import type { EditorData, EditorSection } from './types';
|
|
import LanguageSwitch from '@/components/LanguageSwitch';
|
|
import CatalogTab from './CatalogTab';
|
|
import PaletteTab from './PaletteTab';
|
|
import BrandTab from './BrandTab';
|
|
import OrdersTab from './OrdersTab';
|
|
import QrTab from './QrTab';
|
|
import PublishModal from './PublishModal';
|
|
import { ClipboardList, Palette, Store, Bell, QrCode, type LucideIcon } from 'lucide-react';
|
|
|
|
type Tab = 'catalog' | 'palette' | 'brand' | 'orders' | 'qr';
|
|
|
|
export default function Editor({ data, baseUrl }: { data: EditorData; baseUrl: string }) {
|
|
const t = useTranslations('editor');
|
|
const [tab, setTab] = useState<Tab>('catalog');
|
|
const [sections, setSections] = useState<EditorSection[]>(data.sections);
|
|
const [ordersEnabled, setOrdersEnabled] = useState(data.ordersEnabled);
|
|
const [splitEnabled, setSplitEnabled] = useState(data.splitEnabled);
|
|
const [showMacros, setShowMacros] = useState(data.showMacros);
|
|
const [publishOpen, setPublishOpen] = useState(false);
|
|
const [publishedName, setPublishedName] = useState(data.publishedVersionName);
|
|
|
|
const tabs: { id: Tab; label: string; Icon: LucideIcon }[] = [
|
|
{ id: 'catalog', label: t('catalog'), Icon: ClipboardList },
|
|
{ id: 'palette', label: t('palette'), Icon: Palette },
|
|
{ id: 'brand', label: t('brand'), Icon: Store },
|
|
{ id: 'orders', label: t('orders'), Icon: Bell },
|
|
{ id: 'qr', label: t('qr'), Icon: QrCode },
|
|
];
|
|
|
|
return (
|
|
<div className="safe-pt-editor mx-auto min-h-screen max-w-2xl px-4 pb-28">
|
|
<header className="mb-3 flex items-center justify-between gap-2">
|
|
<div>
|
|
<h1 className="display text-xl font-semibold leading-tight">{data.name}</h1>
|
|
<p className="text-xs text-[var(--text)]/55">
|
|
{publishedName ? `${t('publishedVersion')}: ${publishedName}` : t('noVersion')}
|
|
</p>
|
|
</div>
|
|
<LanguageSwitch />
|
|
</header>
|
|
|
|
{tab === 'catalog' && (
|
|
<CatalogTab
|
|
slug={data.slug}
|
|
sections={sections}
|
|
setSections={setSections}
|
|
ordersEnabled={ordersEnabled}
|
|
showMacros={showMacros}
|
|
setShowMacros={setShowMacros}
|
|
onPublish={() => setPublishOpen(true)}
|
|
onRestored={(name) => setPublishedName(name)}
|
|
/>
|
|
)}
|
|
{tab === 'palette' && <PaletteTab slug={data.slug} initialPalette={data.palette} />}
|
|
{tab === 'brand' && (
|
|
<BrandTab
|
|
slug={data.slug}
|
|
initialBanner={data.bannerImage}
|
|
initialProfile={data.profileImage}
|
|
initialSocial={data.socialLinks}
|
|
/>
|
|
)}
|
|
{tab === 'orders' && (
|
|
<OrdersTab
|
|
slug={data.slug}
|
|
ordersEnabled={ordersEnabled}
|
|
setOrdersEnabled={setOrdersEnabled}
|
|
splitEnabled={splitEnabled}
|
|
setSplitEnabled={setSplitEnabled}
|
|
sections={sections}
|
|
/>
|
|
)}
|
|
{tab === 'qr' && (
|
|
<QrTab
|
|
slug={data.slug}
|
|
baseUrl={baseUrl}
|
|
palette={data.palette}
|
|
initialConfig={data.qrConfig}
|
|
/>
|
|
)}
|
|
|
|
{/* Bottom dock navigation */}
|
|
<nav className="safe-pb-tabbar fixed bottom-0 left-1/2 z-30 w-full max-w-md -translate-x-1/2 px-3 pb-3">
|
|
<div className="dock-bar">
|
|
{tabs.map(({ id, label, Icon }) => (
|
|
<button
|
|
key={id}
|
|
onClick={() => setTab(id)}
|
|
className={`dock-btn ${tab === id ? 'is-active' : ''}`}
|
|
aria-label={label}
|
|
>
|
|
<span className="dock-tip">{label}</span>
|
|
<span className="dock-chip">
|
|
<Icon className="h-[26px] w-[26px]" />
|
|
</span>
|
|
<span className="dock-dot" />
|
|
</button>
|
|
))}
|
|
</div>
|
|
</nav>
|
|
|
|
{publishOpen && (
|
|
<PublishModal
|
|
slug={data.slug}
|
|
onClose={() => setPublishOpen(false)}
|
|
onPublished={(name) => {
|
|
setPublishedName(name);
|
|
setPublishOpen(false);
|
|
}}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|