CCR มี frontend 2 ตัว
| Project | Audience | หน้าที่ |
|---|
ccr-frontend-user | Customer | หน้า public/customer สำหรับ search car, booking, login, payment, contact/profile |
ccr-frontend-backoffice | Staff/Admin | ระบบหลังบ้านสำหรับ operation, setting, users/roles, report |
Pattern สำคัญ
- ใช้ Next.js App Router
- ใช้ hooks แยกตาม feature สำหรับเรียก API
- Backoffice ใช้ permission จาก menu config เพื่อควบคุมการเห็นเมนู/action
- Shared UI ควรใช้ wrapper components ใน
@/components/common/ ตามกฎโปรเจกต์
- API proxy/auth helper อยู่ใน
lib/* และ app/api/*
API proxy
ทั้ง Backoffice และ Customer Web ใช้ apiClient ที่ baseURL: /api/proxy
| Project | Auth behavior |
|---|
| Backoffice | ใช้ NextAuth/Auth0 token และส่งผ่าน proxy ไป APIM |
| Customer Web | ใช้ Auth0/passwordless/social routes, cookie/session และ proxy refresh token เมื่อจำเป็น |
Environment keys ที่ frontend ใช้
| Key | ใช้เพื่อ |
|---|
BASE_API_URL | backend/APIM base URL ฝั่ง server route |
APIM_SUBSCRIPTION_KEY | subscription key สำหรับเรียก APIM |
AUTH0_DOMAIN | Auth0 tenant |
AUTH0_CLIENT_ID | Auth0 application client id |
AUTH0_CLIENT_SECRET | exchange token / passwordless |
AUTH0_AUDIENCE | audience สำหรับ access token |
AUTH0_REDIRECT_URI | social/callback redirect |
NEXT_PUBLIC_BASE_URL | callback/base URL ฝั่ง browser |
NEXT_PUBLIC_BASE_PATH | base path helper |