Files
opencode-skill/skills/website-creator/templates/consent
Kunthawat Greethong b26c8199a5 Update skills: add website-creator, mql-developer, ecommerce-astro
Changes:
- Add FAL_KEY and GEMINI_API_KEY to .env.example
- Update picture-it to use ~/.config/opencode/.env (unified creds)
- Remove shodh-memory skill (no longer used)
- Remove alphaear-* skills (deprecated)
- Remove thai-frontend-dev skill (replaced by website-creator)
- Remove theme-factory skill
- Add mql-developer skill (MQL5 trading)
- Add ecommerce-astro skill (Astro e-commerce)
- Add website-creator skill (Next.js + Payload CMS)
- Update install script for new skills
2026-04-16 17:40:27 +07:00
..

PDPA Consent Logging Template

Template สำหรับเพิ่ม PDPA consent logging ใน Next.js + Payload CMS (MongoDB)

Files

consent/
├── collections/
│   └── ConsentLogs.ts     # Payload collection สำหรับ consent logs
├── api/
│   └── route.ts           # API endpoint สำหรับบันทึก consent
├── cookie-banner.tsx       # CookieBanner component
└── README.md

วิธีใช้

1. เพิ่ม ConsentLogs Collection

Copy collections/ConsentLogs.ts ไปที่ src/collections/ ของ project

2. สร้าง API Endpoint

Copy api/route.ts ไปที่ src/app/api/consent/route.ts

3. เพิ่ม CookieBanner Component

Copy cookie-banner.tsx ไปที่ src/components/

4. เพิ่มใน Layout

เพิ่ม <CookieBanner /> ใน src/app/(frontend)/layout.tsx:

import { CookieBanner } from '@/components/cookie-banner'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <CookieBanner />
      </body>
    </html>
  )
}

5. เพิ่ม Collection ใน payload.config.ts

import ConsentLogs from './collections/ConsentLogs'

export default buildConfig({
  collections: [Users, Media, Snacks, Orders, ConsentLogs],
  // ...
})

API

POST /api/consent

บันทึก consent action

Request:

{
  "action": "accept",
  "purpose": "all",
  "analytics": true,
  "marketing": false,
  "functional": true
}

Response:

{
  "success": true,
  "doc": {
    "id": "...",
    "action": "accept",
    "purpose": "all",
    "analytics": true,
    "marketing": false,
    "functional": true,
    "userAgent": "Mozilla/5.0...",
    "ip": "127.0.0.1",
    "timestamp": "2026-04-10T00:00:00.000Z"
  }
}

⚠️ Pitfalls สำคัญ

  1. ใช้ mongooseAdapter ไม่ใช่ mongodbAdapter
  2. ConsentLogs ต้องใช้ export default ไม่ใช่ named export