import React, { useState } from 'react'; import { Search, Plus, Download, Upload, Edit, MoreHorizontal, FileText, MapPin, Shield, Bell, Check, X } from 'lucide-react'; import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../ui/table"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "../ui/dialog"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select"; import { Label } from "../ui/label"; import { Switch } from "../ui/switch"; import { Badge } from "../ui/badge"; import { Checkbox } from "../ui/checkbox"; import { ScrollArea } from "../ui/scroll-area"; import { cn } from "../ui/utils"; // --- Mock Data --- const MOCK_LOCATIONS = [ { id: '1', name: 'Downtown Store (101)' }, { id: '2', name: 'Uptown Store (102)' }, { id: '3', name: 'Airport Kiosk (201)' }, { id: '4', name: 'Mall Outlet (305)' }, ]; const MOCK_ROLES = [ { id: 'r1', name: 'Partner Admin', permissions: ['all'], notifications: ['system_updates', 'billing'] }, { id: 'r2', name: 'Group Admin', permissions: ['manage_users', 'manage_products', 'view_reports'], notifications: ['new_users'] }, { id: 'r3', name: 'Manager', permissions: ['manage_store', 'view_reports', 'manage_inventory'], notifications: ['label_expiry', 'low_stock'] }, { id: 'r4', name: 'Team Member', permissions: ['view_tasks', 'print_labels'], notifications: ['task_assignment'] } ]; const MOCK_PARTNERS = [ { id: 'p1', name: 'Global Foods Inc.', status: 'active', contact: 'admin@globalfoods.com' }, { id: 'p2', name: 'Local Eateries Co.', status: 'active', contact: 'support@localeateries.com' }, ]; const MOCK_GROUPS = [ { id: 'g1', name: 'West Coast Region', partner: 'Global Foods Inc.', status: 'active' }, { id: 'g2', name: 'East Coast Region', partner: 'Global Foods Inc.', status: 'inactive' }, ]; const MOCK_MEMBERS = [ { id: 'm1', name: 'Alice Johnson', role: 'Manager', locations: ['Downtown Store (101)', 'Uptown Store (102)'], email: 'alice@example.com', status: 'active' }, { id: 'm2', name: 'Bob Smith', role: 'Team Member', locations: ['Airport Kiosk (201)'], email: 'bob@example.com', status: 'active' }, { id: 'm3', name: 'Charlie Brown', role: 'Team Member', locations: ['Downtown Store (101)'], email: 'charlie@example.com', status: 'inactive' }, ]; // --- Types --- type ViewTab = 'Roles' | 'Partner' | 'Group' | 'Team Member'; export function PeopleView() { const [activeTab, setActiveTab] = useState('Roles'); // Data States const [roles, setRoles] = useState(MOCK_ROLES); const [partners, setPartners] = useState(MOCK_PARTNERS); const [groups, setGroups] = useState(MOCK_GROUPS); const [members, setMembers] = useState(MOCK_MEMBERS); // Dialog States const [isRoleDialogOpen, setIsRoleDialogOpen] = useState(false); const [isPartnerDialogOpen, setIsPartnerDialogOpen] = useState(false); const [isGroupDialogOpen, setIsGroupDialogOpen] = useState(false); const [isMemberDialogOpen, setIsMemberDialogOpen] = useState(false); // Handlers const handleExportPdf = () => { alert(`Exporting ${activeTab} list to PDF...`); }; const openCreateDialog = () => { switch (activeTab) { case 'Roles': setIsRoleDialogOpen(true); break; case 'Partner': setIsPartnerDialogOpen(true); break; case 'Group': setIsGroupDialogOpen(true); break; case 'Team Member': setIsMemberDialogOpen(true); break; } }; const renderToolbar = () => { const canBulkOps = activeTab === 'Team Member'; return (
{canBulkOps && ( <> )}
); }; const renderContent = () => { switch (activeTab) { case 'Roles': return ( Role Name Access Permissions Notifications Actions {roles.map(role => ( {role.name}
{role.permissions.map(p => ( {p} ))}
{role.notifications.map(n => ( {n} ))}
))}
); case 'Partner': return ( Partner Name Contact Status Actions {partners.map(p => ( {p.name} {p.contact} {p.status} ))}
); case 'Group': return ( Group Name Parent Partner Status Actions {groups.map(g => ( {g.name} {g.partner} {g.status} ))}
); case 'Team Member': return ( Name Email Role Assigned Locations Status Actions {members.map(m => ( {m.name} {m.email} {m.role}
{m.locations.map(loc => (
{loc}
))}
{m.status}
))}
); } }; return (
{renderToolbar()}
{/* 标签与表格融合在一个圆角框内 */}
{['Roles', 'Partner', 'Group', 'Team Member'].map((tab) => ( ))}
{renderContent()}
{/* --- Dialogs --- */}
); } // --- Sub-Components (Dialogs) --- function CreateRoleDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) { return ( Create New Role Define permissions and notification settings for this role.
{['Manage Labels', 'Manage Products', 'Manage People', 'View Reports', 'Edit Settings', 'Approve Batches'].map(perm => (
))}
); } function CreatePartnerDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) { return ( Create New Partner
); } function CreateGroupDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) { return ( Create New Group
); } function CreateMemberDialog({ open, onOpenChange, roles }: { open: boolean; onOpenChange: (open: boolean) => void; roles: any[] }) { return ( Add Team Member / Manager Create a user account and assign them to locations.
{MOCK_LOCATIONS.map(loc => (
))}

* Users must be assigned to at least one location.

); }