import React, { useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { Button } from '../../ui/button';
import { Input } from '../../ui/input';
import { Label } from '../../ui/label';
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
} from '../../ui/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs';
import { Badge } from '../../ui/badge';
import { Alert, AlertDescription, AlertTitle } from '../../ui/alert';
import { Checkbox } from '../../ui/checkbox';
import { RadioGroup, RadioGroupItem } from '../../ui/radio-group';
import { Switch } from '../../ui/switch';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../ui/select';
import { Textarea } from '../../ui/textarea';
import { Progress } from '../../ui/progress';
import { Separator } from '../../ui/separator';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../../ui/table';
import {
Settings,
User,
Mail,
Phone,
Calendar,
Search,
Menu,
ChevronRight,
Home,
Users,
Plus,
Trash2,
Archive,
ArrowRightLeft,
History,
PanelRight,
FileEdit,
Filter,
Clock,
Map,
Bell,
} from 'lucide-react';
import { Slider } from '../../ui/slider';
import { toast } from 'sonner';
import { ThemeToggle } from '../../brand/theme-toggle';
import { LanguageSelector } from '../../brand/language-selector';
import { MapShowcase } from '../../examples/MapShowcase';
import { Header } from '../../layout/header';
import { Sidebar } from '../../layout/sidebar';
import {
Dialog,
DialogTrigger,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
} from '../../ui/dialog';
import {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogAction,
AlertDialogCancel,
} from '../../ui/alert-dialog';
import { PageHeader } from '../../ui/page-header';
import { useOptionalLayout } from '../../../contexts/LayoutContext';
import { useTheme } from '../../../contexts/ThemeContext';
import { useTeamMembers, useDashboardStore } from '../../../features/home';
import { useTranslation } from 'react-i18next';
import { SectionErrorBoundary } from '../../shared/error-boundary';
import { Skeleton } from '../../ui/skeleton';
/**
* Comprehensive Showcase and Template Content component.
*
* @description
* This component serves as a living kitchen-sink demonstration of the Xertica UI
* Design System. It showcases almost every UI primitive (Cards, Tabs, Forms,
* Tables, Dialogs, etc.) and layout variation (Header flexibility, Sidebar
* toggling). It's primarily used for development, testing, and as a starting
* point for new pages.
*
* @ai-rules
* 1. Reference: Use this component as the primary source of truth for "how to compose" complex layouts in this library.
* 2. Layout: Adjusts its own padding based on the `useLayout` context's sidebar state.
* 3. Interaction: All showcase interactive elements (buttons, forms) use simple `toast` feedback or local state toggles.
*/
export function TemplateContent() {
const { t } = useTranslation();
const layout = useOptionalLayout();
const { disableDarkMode } = useTheme();
const [localSidebarExpanded, setLocalSidebarExpanded] = useState(false);
const [localSidebarWidth, setLocalSidebarWidth] = useState(280);
const sidebarExpanded = layout?.sidebarExpanded ?? localSidebarExpanded;
const sidebarWidth = layout?.sidebarWidth ?? localSidebarWidth;
const setSidebarWidth = layout?.setSidebarWidth ?? setLocalSidebarWidth;
const toggleSidebar = layout?.toggleSidebar ?? (() => setLocalSidebarExpanded(value => !value));
const navigate = useNavigate();
// Server state
const { data: teamMembers = [], isLoading: teamLoading } = useTeamMembers();
// Client-side UI state (Zustand)
const progress = useDashboardStore(s => s.progress);
const setProgress = useDashboardStore(s => s.setProgress);
const sliderValue = useDashboardStore(s => s.sliderValue);
const setSliderValue = useDashboardStore(s => s.setSliderValue);
const switchEnabled = useDashboardStore(s => s.switchEnabled);
const toggleSwitch = useDashboardStore(s => s.toggleSwitch);
// Local UI-only toggles (no global relevance)
const [showSidebarUser, setShowSidebarUser] = useState(true);
const [showSidebarSettings, setShowSidebarSettings] = useState(true);
const [showSidebarLogout, setShowSidebarLogout] = useState(true);
// Header State
const [showHeaderActions, setShowHeaderActions] = useState(true);
const [showHeaderBreadcrumbs, setShowHeaderBreadcrumbs] = useState(true);
const handleFormSubmit = (e: React.FormEvent) => {
e.preventDefault();
toast.success(t('templates.formSubmitSuccess'));
};
return (
{/* Sticky Header */}
},
{ label: t('templates.breadcrumb') },
]}
renderLink={(href, props) =>
}
/>
{/* Content area */}
{/* Page header */}
{/* Page Header Example */}
{t('templates.headerWithBreadcrumbs.sectionTitle')}
{t('templates.headerWithBreadcrumbs.cardTitle')}
{t('templates.headerWithBreadcrumbs.cardDescription')}
,
},
{
label: t('templates.headerWithBreadcrumbs.breadcrumbs.settings'),
href: '#',
icon: ,
},
{
label: t('templates.headerWithBreadcrumbs.breadcrumbs.users'),
href: '#',
icon: ,
},
{ label: t('templates.headerWithBreadcrumbs.breadcrumbs.accessProfile') },
]}
showLanguageSelector={true}
showThemeToggle={true}
/>
{t('templates.headerWithBreadcrumbs.exampleContentTitle')}
{t('templates.headerWithBreadcrumbs.exampleContentDescriptionPart1')}
Header
{t('templates.headerWithBreadcrumbs.exampleContentDescriptionPart2')}
{/* Alert Examples */}
{t('templates.sections.alerts')}
{t('templates.alerts.infoTitle')}
{t('templates.alerts.infoDescription')}
{t('templates.alerts.errorTitle')}
{t('templates.alerts.errorDescription')}
{t('templates.alerts.successTitle')}
{t('templates.alerts.successDescription')}
{t('templates.alerts.warningTitle')}
{t('templates.alerts.warningDescription')}
{/* Cards & Tabs */}
{t('templates.sections.cardsAndTabs')}
{t('templates.tabs.overview')}
{t('templates.tabs.forms')}
{t('templates.tabs.data')}
{t('templates.tabs.settings')}
{/* Overview Tab */}
{t('stats.totalUsers')}
{t('stats.last30Days')}
1,234
+12%
{t('stats.totalRevenue')}
{t('stats.currentMonth')}
$ 45.2k
+8%
{t('stats.conversionRate')}
{t('stats.currentWeek')}
3.2%
-2%
{t('templates.overview.progressTitle')}
{t('templates.overview.progressDescription')}
{progress}%
{sliderValue[0]}%
{/* Forms Tab */}
{t('templates.forms.registrationTitle')}
{t('templates.forms.registrationDescription')}
{/* Data Tab */}
{t('templates.data.title')}
{t('templates.data.description')}
{t('team.name')}
{t('team.email')}
{t('team.role')}
{t('team.status')}
{t('team.actions')}
{teamLoading ? (
<>
{Array.from({ length: 5 }).map((_, i) => (
))}
>
) : (
teamMembers.map(member => (
{member.name}
{member.email}
{t(`team.roles.${member.role}`)}
{t(`common.${member.status}`)}
))
)}
{t('team.showing', {
count: teamMembers.length,
total: teamMembers.length,
})}
{/* Settings Tab */}
{t('templates.settings.title')}
{t('templates.settings.description')}
{!disableDarkMode && (
<>
{t('templates.settings.darkModeDescription')}
>
)}
{t('templates.settings.emailNotificationsDescription')}
{t('templates.settings.pushNotificationsDescription')}
{/* Button Variants */}
{t('templates.sections.buttons')}
{t('templates.buttons.title')}
{t('templates.buttons.description')}
{/* Badges */}
{t('templates.sections.badges')}
{t('templates.badges.title')}
{t('templates.badges.description')}
Default
Secondary
Outline
Destructive
Success
Warning
Info
{/* Dialogs */}
{t('templates.sections.dialogs')}
{t('templates.dialogs.dialogTitle')}
{t('templates.dialogs.dialogDescription')}
{t('templates.dialogs.alertDialogTitle')}
{t('templates.dialogs.alertDialogDescription')}
{t('templates.dialogs.areYouSure')}
{t('templates.dialogs.deleteWarning')}
{t('templates.dialogs.cancel')}
{t('templates.dialogs.continue')}
{/* Maps */}
{/* Header Variations */}
{t('templates.headerVariations.sectionTitle')}
{t('templates.headerVariations.cardTitle')}
{t('templates.headerVariations.cardDescription')}
{t('templates.headerVariations.visibleElements')}
{t('templates.headerVariations.preview')}
,
},
{
label: t('templates.headerVariations.breadcrumbSettings'),
href: '#',
},
{ label: t('templates.headerVariations.breadcrumbProfile') },
]
: undefined
}
actions={
showHeaderActions
? [
{
id: 'notify',
icon:
,
onClick: () =>
toast(t('templates.headerVariations.notificationsOpenedToast')),
},
{
id: 'mail',
label: t('templates.headerVariations.messagesLabel'),
icon:
,
onClick: () =>
toast(t('templates.headerVariations.messagesOpenedToast')),
},
]
: undefined
}
/>
{t('templates.headerVariations.contentArea')}
{/* Sidebar Variations */}
{t('templates.sections.sidebarVariations')}
{t('templates.sidebar.title')}
{t('templates.sidebar.description')}
{t('templates.sidebar.assistantMode')}
{t('templates.sidebar.defaultMode')}
{t('templates.sidebarControls.footerSettings')}
{t('templates.sidebarControls.sidebarWidthDesktop')}
{sidebarWidth}px
240px
setSidebarWidth(val[0])}
min={240}
max={450}
step={10}
className="flex-1"
aria-label={t('templates.sidebarControls.sidebarWidthAriaLabel')}
/>
450px
{}}
user={{ email: 'admin@xertica.com' }}
onLogout={() => toast(t('templates.sidebar.logoutToast'))}
location={{ pathname: '/assistant/current' }}
navigate={() => {}}
variant="assistant"
search={{
show: true,
placeholder: t('templates.sidebar.searchTopicsPlaceholder'),
filter: {
show: true,
content: (
{t('templates.sidebarControls.filterByStatus')}
{t('templates.sidebarControls.filterActive')}
{t('templates.sidebarControls.filterArchived')}
{t('templates.sidebarControls.filterPending')}
),
},
}}
fixedArea={{
show: true,
content: (
),
}}
navigationGroups={[
{
id: 'recent',
label: t('templates.sidebar.recent'),
icon: Clock,
items: [
{
path: '/assistant/refatoracao',
label: t('templates.sidebar.items.sidebarRefactor'),
description: t(
'templates.sidebar.items.sidebarRefactorDescription'
),
actions: [
{
label: t('templates.sidebar.actions.rename'),
icon: FileEdit,
onClick: () =>
toast(t('templates.sidebar.actions.renameToast')),
},
{
label: t('templates.sidebar.actions.move'),
icon: ArrowRightLeft,
children: [
{
label: t('templates.sidebar.actions.moveActive'),
onClick: () =>
toast(t('templates.sidebar.actions.moveActiveToast')),
},
{
label: t('templates.sidebar.actions.moveMonitoring'),
onClick: () =>
toast(
t('templates.sidebar.actions.moveMonitoringToast')
),
},
{
label: t('templates.sidebar.actions.moveArchive'),
onClick: () =>
toast(
t('templates.sidebar.actions.moveArchiveToast')
),
},
],
},
{
label: t('templates.sidebar.actions.clear'),
icon: Trash2,
onClick: () =>
toast(t('templates.sidebar.actions.clearToast')),
variant: 'destructive',
},
],
},
],
},
{
id: 'projects',
label: t('templates.sidebar.constructionMonitoring'),
icon: Map,
actions: [
{
label: t('templates.sidebar.actions.newCategory'),
icon: Plus,
onClick: () =>
toast(t('templates.sidebar.actions.newCategoryToast')),
},
{
label: t('templates.sidebar.actions.archiveGroup'),
icon: Archive,
onClick: () =>
toast(t('templates.sidebar.actions.archiveGroupToast')),
},
],
items: [
{
path: '/assistant/br163',
label: t('templates.sidebar.items.br163Restoration'),
icon: () => (
),
description: (
{t('templates.sidebar.items.br163Location')}
67%
),
},
],
},
]}
footer={{
showUser: showSidebarUser,
showSettings: showSidebarSettings,
showLogout: showSidebarLogout,
}}
/>
{t('templates.sidebar.assistantContent')}
{}}
user={{
name: 'Ariel Santos',
email: 'admin@xertica.com',
avatar: 'https://github.com/shadcn.png',
}}
onLogout={() => toast(t('templates.sidebar.logoutToast'))}
onSettingsClick={() =>
toast(t('templates.sidebar.settingsClickedToast'))
}
location={{ pathname: '/home' }}
navigate={() => {}}
variant="default"
routes={[
{
path: '/home',
label: t('templates.sidebar.routes.home'),
icon: Home,
},
{
path: '/dashboard',
label: t('templates.sidebar.routes.dashboard'),
icon: Users,
},
{
path: '/settings',
label: t('templates.sidebar.routes.settings'),
icon: Settings,
},
]}
footer={{
showUser: showSidebarUser,
showSettings: showSidebarSettings,
showLogout: showSidebarLogout,
}}
/>
{t('templates.sidebar.defaultContent')}
{/* Footer Note */}
{t('templates.footer.title')}
{t('templates.footer.subtitle')}
{t('templates.footer.descriptionPart1')}
xertica-ui
{t('templates.footer.descriptionPart2')}
{t('templates.footer.tipTitle')}
{t('templates.footer.tipDescriptionPart1')}
styles/xertica/tokens.css
{t('templates.footer.tipDescriptionPart2')}
);
}