Skip to content

2way-meeting-backoffice — Repository Map

บทนี้เป็นแผนที่ไฟล์ของ 2way-meeting-backoffice (branch: prod, 521 tracked files, ~368 ไฟล์ .ts/.tsx/.js ใต้ src/)

ชื่อ package: reportmonitor@5.0.0 (package.json:2-3)


แผนที่โฟลเดอร์ระดับ repo

2way-meeting-backoffice/                 (branch: prod)
├── package.json                         # name=reportmonitor, scripts port 8002
├── next.config.js                       # basePath /2way-backoffice, env map, Sentry wrap COMMENT OUT
├── next-i18next.config.js               # locales th/en, defaultLocale th
├── sentry.client.config.js              # Sentry.init browser + hardcoded DSN fallback
├── sentry.server.config.js              # Sentry.init server + hardcoded DSN fallback
├── Dockerfile                           # node:18 multi-stage → next start :8002
├── docker-compose.yml
├── bitbucket-pipelines.yml              # yarn build → GCP docker → terraform
├── .env / .env.example / .env.production / .env.uat
├── jest.config.js / jest.setup.ts
├── __test__/                            # enzyme + jest (React 17 era)
├── public/
│   ├── css/, sass/, fonts/, images/
│   ├── locales/{th,en,de}/
│   └── mockDatas/
│       ├── navbar2WayBackoffice.json    # menu แอดมินหลัก
│       └── navbar2WayBackofficeNonEmp.json
└── src/
    ├── pages/                           # Next.js Pages Router (~50 page files)
    ├── features/
    │   ├── 2way/                        # LIFF employee features
    │   ├── BackOffice/                  # Admin features
    │   └── Satisfaction/                # Chat-center satisfaction report UI
    ├── services/                        # axios wrappers → 2way-api (+ incidents)
    ├── utils/                           # auth, fetchAPI*, chatCenterApi
    ├── HOC/                             # withAuth*, withAuthVerify, withAuthSuperAdmin
    ├── layouts/                         # Layout3 (active), Layout2Way*, styled
    ├── components/                      # navbar, sideMenu, form, table, ...
    ├── hooks/                           # useChatCenter*
    ├── stores/atoms/                    # loginTypeAtom, tokenAtom (Recoil)
    ├── context/                         # StoreProvider
    ├── types/
    └── styles/

Scripts และ build artifacts

Scriptพฤติกรรมอ้างอิง
yarn / yarn installติดตั้ง deps (Docker ใช้ --frozen-lockfile)Dockerfile:7, Readme.md
yarn devENV_STAGE=development next dev -p 8002package.json:7
yarn buildnext build → ผลิตโฟลเดอร์ .next/ (ไม่ commit)package.json:8, Dockerfile:19
yarn startnext start -p 8002package.json:9
yarn out / yarn exportnext build && next export → static out/package.json:9,14
yarn testjest + enzyme watchpackage.json:13
yarn lintnext lint — CI มี step แต่ build ignore ESLint errorspackage.json:12, next.config.js:25-28

Build artifact ที่สำคัญ:

  • .next/ — output ของ next build; Docker runner copy เข้า image (Dockerfile:31)
  • out/ — ถ้าใช้ next export (script มี แต่ pipeline หลักใช้ yarn build + next start ไม่ใช่ static host)
  • Docker image ฝัง .env.production เข้า image โดยตรง (Dockerfile:27) — ค่า hostname ปลายทางอยู่ใน image

สิ่งที่ Next ปิดระหว่าง build (อันตรายต่อคุณภาพ):

js
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },

(next.config.js:25-36)


Pages Router — แผนที่ route ทั้งหมด

basePath = /2way-backoffice ดังนั้น path ด้านล่างคือ path ของ Next pages; URL จริง = /2way-backoffice + path

Layout convention

แต่ละ page ตั้ง Component.layout เป็น string:

layoutความหมายผลใน Layout3Auth guard
L2Backoffice แอดมินแสดง Navbar + SideMenu (layouts/Layout3.tsx:13-16)withAuthVerify ตรวจ token เมื่อ layout == "L2" (HOC/withAuthVerify.tsx:11,58-60)
L1LIFF content / Feedback publicไม่มี navbar/sidemenuไม่ verify
L3Login / entry / loadingไม่มี navbar/sidemenuไม่ verify

A) Auth / entry (layout L3)

Page fileRoute (หลัง basePath)Featurelayout
src/pages/index.tsx/features/BackOffice/LoginL3 (index.tsx:11)
src/pages/2wayfrontend/index.tsx/2wayfrontendLogin (ซ้ำ entry)L3
src/pages/2wayfrontend/Forgot/index.tsx/2wayfrontend/ForgotForgot password OTP flowL3
src/pages/2wayfrontend/bypassLogin/[token].tsx/2wayfrontend/bypassLogin/{token}SSO/bypass จาก VTRC backofficeL3 (:101)

B) Backoffice แอดมิน (layout L2)

Page fileRouteFeature module
.../2waybackoffice/Backoffice/index.tsx/2wayfrontend/2waybackoffice/Backofficelanding แอดมิน
.../ChatCenter/index.tsx.../ChatCenterfeatures/BackOffice/ChatCenter
.../ChatCenter/admin.tsx.../ChatCenter/adminChatCenter/adminทีมแอดมิน (teamAdmin)
.../Announce/Dashboard/index.tsx.../Announce/DashboardAnnounce list
.../Announce/Create/index.tsx.../Announce/Createสร้างประกาศ
.../Announce/Edit/[id].tsx.../Announce/Edit/{id}แก้ไข
.../Announce/View/[id].tsx.../Announce/View/{id}ดู
.../Survey/Dashboard|Create|Edit|View.../Survey/...Survey CRUD + approve/reject
.../Question/Dashboard|Create|Edit.../Question/...FAQ CRUD → 2way-vtrc-api
.../Feedback/Dashboard|Edit/[id].../Feedback/...Complaints workflow (layout L2)
.../Feedback/[uuid].tsx.../Feedback/{uuid}layout L1 — หน้า public/share
.../Satisfaction/index.tsx.../Satisfactionfeatures/Satisfaction report

Navbar mock ที่ SideMenu อ่าน (public/mockDatas/navbar2WayBackoffice.json:1-34):

Chat Center
จัดการแบบสำรวจ          → Survey/Dashboard
จัดการแบบสำรวจความพึงพอใจ → Satisfaction
จัดการข้อเสนอแนะ/คำแนะนำ → Feedback/Dashboard
จัดการประกาศที่ต้องรับทราบ → Announce/Dashboard

หมายเหตุ: หน้า Question/* มีอยู่และทำงาน แต่ ไม่อยู่ใน navbar JSON ชุดหลัก — เข้าได้ด้วย URL โดยตรงหรือลิงก์ภายใน

C) LINE LIFF — Red Cross OA (/line/..., layout L1 / L3)

PageRouteFeature
pages/line/index.tsx/lineloading shell (L3)
line/Announce/List|ListNew|ListKnow|Detail/[id]/line/Announce/...ประกาศ
line/Survey/index.tsx/line/Surveyแบบสำรวจ
line/Complaint/{index,List,Detail/[id]}/line/Complaint/...ร้องเรียน
line/Incident/{index,List,Detail/[id]}/line/Incident/...แจ้งปัญหาการใช้งาน
line/Problem/{index,List,Detail/[id]}/line/Problem/...FAQ / ถามตอบ
line/Register/index.tsx/line/Registerลงทะเบียน LINE user
line/Satisfaction/{index,Form,Step/[step]}/line/Satisfaction/...แบบประเมินความพึงพอใจ (ฝั่งพนักงาน)

D) LINE LIFF — CU OA (/line-cu/...)

PageRouteFeature
pages/line-cu/index.tsx/line-culoading shell (L3)
line-cu/Register/index.tsx/line-cu/Registerfeatures/2way/RegisterCu

LIFF ID แยก RC / CU และแยก prod / non-prod ใน _app.tsx:70-87


Feature module breakdown

features/2way/ — พนักงาน (LIFF)

Folderหน้าที่Backend หลัก
Announce/{List,ListNew,ListKnow,Detail}อ่าน/รับทราบประกาศappConnectChatAPI /getProfile + 2way-api announces (บางจุด)
SurveyทำแบบสำรวจgetProfile + surveys API
Complaint/{List,Detail}ยื่น/ติดตามเรื่องร้องเรียนgetProfile + complaints
Incident/{List,Detail}แจ้งปัญหาการใช้งานgetProfile + appConnectIncidentAPI
Problem/{List,Detail}FAQ / ส่งคำถาม/getListFAQs, /createQuestion, /sendMessageLineFAQsStepYes
Registerลงทะเบียน RC/verifyUserLine, /verifyOTPUserLine, /createUserLine
RegisterCuลงทะเบียน CUpath เดียวกันต่อท้าย /cu

features/BackOffice/ — แอดมิน

Folderหน้าที่Backend หลัก
Login, Forgotlogin / ลืมรหัสผ่าน2way-api /api/v1/auth*
Announce/{Dashboard,Create,Edit,View}CRUD ประกาศ + contentAssigns (ผู้รับ)services/announces.tsx2way-api
Survey/{Dashboard,Create,Edit,View}CRUD + adminApprove / adminRejectservices/surveys.tsx
Question/{Dashboard,Create,Edit}FAQ adminappConnectChatAPI /getListFAQs, /addNewFAQs, /updateFAQs
Feedback/{Dashboard,Edit}complaint workflow (assign / secretary / superAdmin)api/v1/complaints/* inline ใน Form
ChatCenterrealtime chat UI + notes + appointmentchat-center-api + websocket
ChatCenter/adminจัดการทีมแอดมิน (teamAdmin) + tags + membersteamAdmin/*, tags/list
ChatCenter2สำเนา/ทดลอง (มีใน tree — ไม่ใช่ route หลัก)

features/Satisfaction/

หน้า report คะแนนความพึงพอใจของ Chat Center — เรียก getSatisfactionSurvey / postSatisfactionSurveyGenSurvey จาก utils/chatCenterApi.tsx (features/Satisfaction/index.tsx:13-15,58)


Layouts และ shell UI

_app.tsx
  └── appWithTranslation(withAuthVerify(MyApp))     (_app.tsx:152)
        └── RecoilRoot → StoreProvider → ThemeProvider
              └── Layout3(level=Component.layout)   (_app.tsx:137-139)
                    ├── Navbar     (ถ้า L2)
                    ├── SideMenu   (ถ้า L2)
                    └── children (page)

ไฟล์ layout อื่นที่มีอยู่แต่ไม่ใช่ shell หลักของ _app:

  • layouts/Layout2Way.tsx, Layout2WayBackoffice.tsx — legacy / feature-specific
  • layouts/styled.tsx, type.tsx

Utils / services / HOC — ชั้นเรียก API

ไฟล์บทบาท
utils/auth.tsxsetToken / getToken / setProfile / getProfile / getUserInfo / clearAllStorage — เก็บใน localStorage
utils/fetchApiWithAxios.tsxfetchAPI${appConnectAPI}/{url} + Bearer; fetchRedCrossAPI${appConnectRedCross}/{url}
utils/fetchApiWithAxiosCustom.tsxfetchAPICustom — caller ส่ง absolute URL เอง
utils/fetchApiWithAxiosByFixed.tsxvariant เพิ่มเติม
utils/chatCenterApi.tsxtyped wrappers สำหรับ chat-center (teamAdmin, rooms, tags, satisfaction, noti)
services/announces.tsxannounces CRUD → 2way-api
services/surveys.tsxsurveys CRUD + approve/reject
services/employee.tsxorg/divi/dept/position/group/admin dropdowns
services/chat-center.tsxgetChatDetail (hardcoded roomEmpCode)
services/line/incidents.tsxincident-management-api
services/feedback.tsxไฟล์ว่าง — Feedback เรียก fetchAPI inline ใน component
HOC/withAuthVerify.tsxactive ใน _app — guard L2
HOC/withAuth.tsxมีอยู่แต่ comment ออก จาก _app (_app.tsx:148)
HOC/withAuthSuperAdmin.tsxเช็คแค่มี accessToken — ชื่อหลอก (ไม่มีเช็ค level)
HOC/withAuth copy*.tsxbackup — ตามกฎ workspace อย่าลบโดยไม่ตรวจ

Env mapping (next.config.js)

next.config.js:49-74 inject ค่าเข้า process.env ของ client:

Client keySource env
appConnectAPIAPP_CONNECT_API
appConnectChatCenterAPIAPP_CONNECT_API_CHAT
appConnectIncidentAPIAPP_CONNECT_API_INCIDENT
appConnectChatAPIAPP_CONNECT_API_BASIC
appConnectRedCrossAPP_PATH
appConnectWebSocketAPP_WEBSOCKET
chatCenterPathhardcode "chat-center-api/api/v1" (next.config.js:73)
assetPrefixhardcode "/2way-backoffice"
customKey / apiKeyhardcode "my-value" (placeholder)

ค่า DB/SMTP ใน env (APP_CONNECT_DB_*, APP_CONNECT_SMTP_*) ถูก map ด้วย แต่ frontend นี้ ไม่มี DB driver — ค่าเหล่าน่าจะเป็น remnant จาก scaffold reportmonitor


Docker และ CI

Dockerfile (3 stages)

  1. depsnode:18, yarn install --frozen-lockfile (Dockerfile:2-7)
  2. builderNODE_ENV=production, yarn build (:13-19)
  3. runner — copy .env.production, next.config.js, public, .next, node_modules; EXPOSE 8002; CMD next start (:22-37)

bitbucket-pipelines.yml

  • image: node:18 (bitbucket-pipelines.yml:6)
  • steps: build-test (yarn + yarn build), linting, build-docker-image (push GCP registry พร้อม tag commit short), terraform apply
  • branches ที่เห็นในไฟล์: cicd (+ อ่านต่อท้ายไฟล์สำหรับ prod / อื่น ๆ)

Test surface

__test__/ ครอบคลุม component ย่อย (InputText, buttons, Layout) ด้วย enzyme — ไม่พบ integration test ที่ยิง backend จริงหรือ e2e ของ ChatCenter/LIFF ใน tree ที่ตรวจ


สรุปตำแหน่งที่ต้องอ่านก่อนแก้โค้ด

  1. next.config.js — basePath + env map + build ignore flags
  2. src/pages/_app.tsx — LIFF init + layout shell + HOC ห่อแอป
  3. src/HOC/withAuthVerify.tsx — guard จริงของ L2
  4. src/utils/auth.tsx + fetchApiWithAxios.tsx + chatCenterApi.tsx — token และ API
  5. src/features/BackOffice/ChatCenter/ — พื้นที่ใหญ่สุดและซับซ้อนสุดของ repo
  6. public/mockDatas/navbar2WayBackoffice.json — เมนูที่ผู้ใช้เห็น