ပန်းတိုင်
ERP sidebar / admin shell မပါဘဲ ဖွင့်နိုင်သော မျက်နှာပြင်များ — kitchen board၊ QR menu၊ customer portal စသည် — ကို ပေးပို့ရန် ဖြစ်ပါသည်။
- Blank layout — AppRegistry.rootRoute.add()
- Path ကို /${metadata.name} ဖြင့် prefix လုပ်ရပါမည်
- Multi-page — /* shell + nested Routes + React.lazy
- အများသုံး ဖောက်သည် ≠ Quan ERP admin — အတည်ပြုခြင်းကို ခွဲခြားထားရပါမည်
1. လိုအပ်ချက်များ
frontend register() ရှိသော plugin နှင့် လည်ပတ်နေသော base stack လိုအပ်ပါသည်။
- plugins/<name>/frontend/src/index.tsx ရှိရပါမည်
- metadata.name နှင့် folder အမည် တူညီရပါမည်
- Build/watch နှင့် Install ပြီး register() လည်ပတ်နေရပါမည်
- တစ်ခုတည်းသော screen လိုအပ်သလား / multi-page portal လိုအပ်သလား သိရှိထားရပါမည်
2. တစ်ခုတည်းသော public page မှတ်ပုံတင်ခြင်း
တစ်ခုတည်းသော screen အတွက် register() ထဲတွင် rootRoute.add() ကို အသုံးပြုရပါသည်။ Blank layout အတွက် route.add() မသုံးရပါ။
- path — `/${metadata.name}/…` သို့မဟုတ် `/${metadata.name}/:id`
- element — page component (@quan-erp/shared-ui ကို အသုံးပြုနိုင်ပါသည်)
- Public page အတွက် menu.add() မလုပ်ရပါ
1import type { AppRegistryState, PluginModule } from "@quan-erp/shared-types";
2import metadata from "../module.metadata.json" with { type: "json" };
3import { FoodKitchenBoard } from "./page/kitchen/kitchen.page";
4import { FoodPublicMenu } from "./page/public-menu/public-menu.page";
5
6const Plugin: PluginModule = {
7 register(AppRegistry: AppRegistryState) {
8 AppRegistry.rootRoute.add({
9 path: `/${metadata.name}/kitchen`,
10 element: <FoodKitchenBoard />,
11 });
12
13 // Dynamic segment
14 AppRegistry.rootRoute.add({
15 path: `/${metadata.name}/:id`,
16 element: <FoodPublicMenu />,
17 });
18 },
19};
20
21export default Plugin;3. Nested public portal (multi-page)
Login / home / signup အတွက် `/${metadata.name}/*` shell တစ်ခုကို မှတ်ပုံတင်ပြီး၊ အတွင်းတွင် Routes ထားရှိရပါသည်။ Nested page တိုင်းကို React.lazy ဖြင့် load လုပ်ရပါမည်။
- Portal တစ်ခုလုံးအတွက် rootRoute entry တစ်ခုသာ
- React.lazy + Suspense + LoadingState
- Nested path များသည် splat နှင့် relative ဖြစ်ပါသည် (login → /${metadata.name}/login)
AppRegistry.rootRoute.add({
path: `/${metadata.name}/*`,
element: <PublicShellPage />,
});1import { LoadingState } from "@quan-erp/shared-ui";
2import { lazy, Suspense } from "react";
3import { Navigate, Route, Routes } from "react-router-dom";
4
5const LoginPage = lazy(() =>
6 import("./login/login.page").then((m) => ({ default: m.LoginPage })),
7);
8const SignupPage = lazy(() =>
9 import("./signup/signup.page").then((m) => ({ default: m.SignupPage })),
10);
11const HomePage = lazy(() =>
12 import("./home/home.page").then((m) => ({ default: m.HomePage })),
13);
14
15const HOME_PATH = "home";
16
17export function PublicShellPage() {
18 return (
19 <Suspense fallback={<LoadingState />}>
20 <Routes>
21 <Route index element={<Navigate replace to={HOME_PATH} />} />
22 <Route path="login" element={<LoginPage />} />
23 <Route path="register" element={<SignupPage />} />
24 <Route path="home" element={<HomePage />} />
25 <Route path="*" element={<Navigate replace to={HOME_PATH} />} />
26 </Routes>
27 </Suspense>
28 );
29}4. အများသုံး ဖောက်သည် ≠ admin auth
ပြင်ပ ဖောက်သည်များသည် Quan ERP အသုံးပြုသူ မဟုတ်ပါ။ Core admin login၊ base axios သို့မဟုတ် localStorage token ကို ပြန်လည် မသုံးရပါ။
- Public axios + withCredentials: true
- Backend — ${metadata.name}-prefixed httpOnly cookies
- Auth gate = cookie-authenticated API အောင်မြင်မှု (401 → login)
- Zustand profile (memory) — token မသိမ်းရပါ
5. စစ်ဆေးခြင်း
Watch နှင့် Install ပြီးနောက် public URL ကို browser တွင် ဖွင့်၍ စစ်ဆေးရပါမည်။
- Single — /${metadata.name}/kitchen; ERP sidebar မရှိရပါ
- Portal — /${metadata.name}/login → home; nested route များ အလုပ်လုပ်ရပါမည်
- register() ပြောင်းလဲပြီးသား ဖြစ်ပါက hard-refresh လုပ်ပါ
- Network — public API သည် plugin cookie ကို အသုံးပြုရပါမည်
အဖြစ်များသော အမှားများ
- route.add() သုံးမိခြင်း — ERP chrome ပေါ်နေပါသည်
- /${metadata.name} prefix မပါခြင်း
- Shell တွင် /* မပါခြင်း — nested 404
- Portal page များကို eager import လုပ်ခြင်း — login chunk ကြီးလာခြင်း
- Public page တွင် admin login ရှိသည်ဟု ယူဆခြင်း