/* App shell — header, navigation, role switcher, device frame */
const CKCtx = React.createContext(null);
const useCK = () => React.useContext(CKCtx);
const NAV = {
dashboard: { th:'ภาพรวม', icon:'LayoutDashboard' },
addjob: { th:'เพิ่มงาน', icon:'CirclePlus' },
queue: { th:'คิวรายวัน', icon:'ClipboardList' },
calendar: { th:'ปฏิทิน', icon:'CalendarDays' },
cover: { th:'ใบปะหน้า', icon:'FileText' },
assign: { th:'มอบหมายช่าง', icon:'Truck' },
mytasks: { th:'งานของฉัน', icon:'Wrench' },
manage: { th:'จัดการระบบ', icon:'Settings' },
};
const ROLE_NAV = {
sales: ['addjob','queue','calendar'],
hq: ['queue','calendar','cover','assign','addjob'],
tech: ['mytasks','calendar'],
admin: ['dashboard','queue','calendar','cover','assign','manage'],
};
function Logo({ light }) {
return (
ChareonKit
ระบบจัดการคิวติดตั้ง
);
}
function RoleSwitcher() {
const { role, setRole } = useCK();
const [open,setOpen] = React.useState(false);
const r = CK.ROLES[role];
return (
{open && (
<>
setOpen(false)} />
สลับมุมมองผู้ใช้ (demo)
{Object.values(CK.ROLES).map(x => (
))}
>
)}
);
}
function DeviceToggle() {
const { device, setDevice, tweaks } = useCK();
const dark = tweaks.headerTheme==='dark';
return (
{['desktop','mobile'].map(d => (
))}
);
}
function TopHeader({ compact }) {
const { tweaks } = useCK();
const dark = tweaks.headerTheme==='dark';
return (
);
}
function Sidebar() {
const { role, route, navigate } = useCK();
const items = ROLE_NAV[role];
return (
);
}
function BottomNav() {
const { role, route, navigate } = useCK();
const all = ROLE_NAV[role];
const [moreOpen,setMoreOpen] = React.useState(false);
const overflow = all.length > 5;
const primary = overflow ? all.slice(0,4) : all;
const extra = overflow ? all.slice(4) : [];
const extraActive = extra.includes(route);
return (
<>
setMoreOpen(false)} title="เมนูเพิ่มเติม">
{extra.map(k => { const n = NAV[k]; const a = route===k;
return (
);
})}
>
);
}
// iPhone 16 status bar — time left, room for Dynamic Island center, indicators right
function PhoneStatusBar({ dark }){
return (
);
}
// Layout: desktop = sidebar; mobile = phone frame
function Layout({ children }) {
const { device, tweaks } = useCK();
if (device === 'mobile') {
const frame = tweaks.deviceFrame !== false; // default on
const dark = tweaks.headerTheme==='dark';
const W = frame ? 480 : 600;
return (
{frame && (
<>
>
)}
{frame &&
}
{frame &&
}
{children}
{frame &&
}
);
}
return (
);
}
Object.assign(window, { CKCtx, useCK, Layout, NAV, ROLE_NAV });