# BF Customer Frontend Structure

## เป้าหมาย
- โหลดเร็ว: ไม่ใส่ jQuery เป็น global ทุกหน้า
- ปลอดภัยขึ้น: API ใช้ session cookie ผ่าน `xhrFields.withCredentials`
- แก้ง่าย: config/API/UI แยกชัดเจน

## ไฟล์ใหม่
- `js/core/config.js` แก้ `BASE_URL` จุดเดียว
- `js/core/vendor-loader.js` โหลด jQuery/SweetAlert2 เฉพาะตอนจำเป็น
- `js/core/api.js` helper สำหรับ `GET/POST` ไป `backend/api.php?action=...`
- `js/core/ui.js` helper Vanilla JS สำหรับ dashboard
- `js/pages/login.js` ยิง `customer_login`
- `js/pages/register.js` ยิง `customer_register`
- `js/pages/dashboard.js` ตรวจ login ด้วย `customer_me`, โหลด balance, logout

## หลักการโหลด
- `login.html`: ไม่โหลด jQuery ตอนเปิดหน้า แต่โหลดเมื่อตอน submit login
- `register.html`: ไม่โหลด jQuery ตอนเปิดหน้า แต่โหลดตอน submit register
- `dashboard.html`: ใช้ Vanilla JS สำหรับ tab/menu และโหลด jQuery เฉพาะตอนยิง `customer_me`, `customer_balance`, `customer_logout`
- tab อื่น ๆ เช่น promotion/static ไม่ยิง API จึงไม่โหลดเพิ่ม

## ต้องแก้ตอนขึ้น production
เปิด `js/core/config.js` แล้วเปลี่ยน:
```js
BASE_URL: '/backend/api.php'
```
เป็น URL backend จริง เช่น:
```js
BASE_URL: 'https://yourdomain.com/backend/api.php'
```

## API ที่ผูกแล้ว
- `customer_login`
- `customer_register`
- `customer_me`
- `customer_balance`
- `customer_logout`

## API ที่วางโครงไว้ แต่ยังไม่ bind UI เต็ม
- `public_categories`
- `public_providers`
- `public_games`
- `customer_lobbygame`
- `customer_playgame`
