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
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
import { CollectionConfig, Field } from 'payload'
|
||||
|
||||
// Consent Log Collection - เก็บ log การยินยอมของ users
|
||||
export const ConsentLog: CollectionConfig = {
|
||||
slug: 'consent-logs',
|
||||
admin: {
|
||||
useAsTitle: 'sessionId',
|
||||
defaultColumns: ['sessionId', 'consentType', 'granted', 'createdAt'],
|
||||
description: 'บันทึกการยินยอมของผู้ใช้ตาม PDPA',
|
||||
},
|
||||
access: {
|
||||
// ทุกคนสามารถสร้าง log ได้ (public)
|
||||
create: () => true,
|
||||
// แต่ดูได้เฉพาะ admin
|
||||
read: ({ req: { user } }) => {
|
||||
if (!user) return false
|
||||
return user.role === 'admin'
|
||||
},
|
||||
// แก้ไขได้เฉพาะ admin
|
||||
update: ({ req: { user } }) => {
|
||||
if (!user) return false
|
||||
return user.role === 'admin'
|
||||
},
|
||||
// ลบได้เฉพาะ admin
|
||||
delete: ({ req: { user } }) => {
|
||||
if (!user) return false
|
||||
return user.role === 'admin'
|
||||
},
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'sessionId',
|
||||
type: 'text',
|
||||
required: true,
|
||||
admin: {
|
||||
description: 'Session ID ของผู้ใช้',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'consentType',
|
||||
type: 'select',
|
||||
required: true,
|
||||
options: [
|
||||
{ label: 'Essential', value: 'essential' },
|
||||
{ label: 'Analytics', value: 'analytics' },
|
||||
{ label: 'Marketing', value: 'marketing' },
|
||||
{ label: 'Functional', value: 'functional' },
|
||||
{ label: 'All Accepted', value: 'accept_all' },
|
||||
{ label: 'All Rejected', value: 'reject_all' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'granted',
|
||||
type: 'checkbox',
|
||||
required: true,
|
||||
defaultValue: false,
|
||||
admin: {
|
||||
description: 'ยินยอมหรือไม่',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ipAddress',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'IP Address ของผู้ใช้',
|
||||
readOnly: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'userAgent',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Browser User Agent',
|
||||
readOnly: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'metadata',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description: 'ข้อมูลเพิ่มเติม',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'createdAt',
|
||||
type: 'date',
|
||||
required: true,
|
||||
admin: {
|
||||
description: 'วันที่และเวลาที่ยินยอม',
|
||||
readOnly: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
hooks: {
|
||||
beforeChange: [
|
||||
({ data }) => {
|
||||
// เพิ่ม timestamp อัตโนมัติ
|
||||
if (!data.createdAt) {
|
||||
data.createdAt = new Date().toISOString()
|
||||
}
|
||||
return data
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
// Consent Settings Collection - เก็บ settings ของ consent banner
|
||||
export const ConsentSettings: CollectionConfig = {
|
||||
slug: 'consent-settings',
|
||||
admin: {
|
||||
useAsTitle: 'title',
|
||||
description: 'ตั้งค่า Cookie Consent Banner',
|
||||
},
|
||||
access: {
|
||||
read: () => true, // Public read
|
||||
create: ({ req: { user } }) => !!user && user.role === 'admin',
|
||||
update: ({ req: { user } }) => !!user && user.role === 'admin',
|
||||
delete: ({ req: { user } }) => !!user && user.role === 'admin',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
required: true,
|
||||
defaultValue: 'นโยบายคุกกี้',
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
type: 'textarea',
|
||||
required: true,
|
||||
defaultValue: 'เราใช้คุกกี้เพื่อปรับปรุงประสบการณ์การใช้งานเว็บไซต์ของคุณ คุณสามารถเลือกได้ว่าจะอนุญาตคุกกี้ประเภทใด',
|
||||
},
|
||||
{
|
||||
name: 'position',
|
||||
type: 'select',
|
||||
defaultValue: 'bottom',
|
||||
options: [
|
||||
{ label: 'ด้านล่าง (Bottom)', value: 'bottom' },
|
||||
{ label: 'ด้านบน (Top)', value: 'top' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'theme',
|
||||
type: 'select',
|
||||
defaultValue: 'light',
|
||||
options: [
|
||||
{ label: 'Light Mode', value: 'light' },
|
||||
{ label: 'Dark Mode', value: 'dark' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'essentialCookies',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description: 'รายชื่อ essential cookies ที่จำเป็นต้องมี',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'analyticsCookies',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description: 'รายชื่อ analytics cookies',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'marketingCookies',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description: 'รายชื่อ marketing cookies',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'functionalCookies',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description: 'รายชื่อ functional cookies',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'isActive',
|
||||
type: 'checkbox',
|
||||
defaultValue: true,
|
||||
admin: {
|
||||
description: 'แสดง consent banner หรือไม่',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user