diff --git a/.cursor/rules/000-core-setup.mdc b/.cursor/rules/000-core-setup.mdc index 49c8acf8..ac14f8a1 100644 --- a/.cursor/rules/000-core-setup.mdc +++ b/.cursor/rules/000-core-setup.mdc @@ -13,8 +13,8 @@ Tôi cần AI làm tự động nhiều nhất có thể, ít phải động tay - **Runtime**: Node.js v22, PowerShell 7 (Windows 11) - **Frontend**: Next.js, React, TypeScript - **Backend**: Strapi CMS v5.15+, Node.js APIs -- **Database**: PostgreSQL v17+ chạy trong docker container tên DB -- **DevOps**: Docker, Docker Compose +- **Database**: shared DOS Supabase, schema `give`; DDL and pgTAP tests live in DOS/DOS.Me and run in its GitHub CI +- **Local Docker / local Supabase**: forbidden for Give work (owner decision 2026-11-21); read `AGENTS.md`, which overrides this file - **Future**: Flutter (mobile development) ## 🤖 AI AUTOMATION PRINCIPLES @@ -36,7 +36,6 @@ Tôi cần AI làm tự động nhiều nhất có thể, ít phải động tay ### Project Structure - Tạo file structure hoàn chỉnh cho new projects - Include package.json với correct dependencies -- Setup Docker files khi cần - Tạo environment files (.env.example) ## 📁 WORKSPACE PATTERNS diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..a0a40a92 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,36 @@ +# Agent instructions for Give + +These rules apply to every coding agent working on Give (Claude Code, Codex, +Qwen Code, Gemini, Antigravity, Cursor and others). `QWEN.md`, `GEMINI.md` and +`.cursor/rules` point here. + +## No local Docker, no local Supabase + +Local Docker and local Supabase are forbidden for Give work (owner decision +2026-11-21). Do not run `supabase start`, `supabase db start`, +`supabase db reset`, `supabase test db`, `docker run`, `docker build`, +`docker compose up`, or anything else that creates containers or databases on +the developer's machine. Forgotten local test databases filled the machine +before; this rule exists so that never happens again. + +- **Database tests (pgTAP) and migration replay run in GitHub CI on the + DOS/DOS.Me PR.** All `give` schema DDL and its pgTAP suites live in + DOS/DOS.Me (`supabase/migrations`, `supabase/tests/database/give_*.test.sql`). + Push the DOS.Me branch, open the PR and read the CI result: the + `Supabase migration replay ()` check replays every migration in a fresh + database, and the `Give pgTAP tests ()` check runs the Give suites and + logs each suite's test count. +- **App checks run without Docker:** `pnpm format:check`, `pnpm lint`, + `pnpm typecheck`, `pnpm test` (Vitest) and `pnpm build`, the same checks the + `Lint` and `Build all apps` CI jobs run. +- **If you think you need a local database, ask the Product Owner (PO) + instead.** Do not work around this rule. + +## Other rules + +- This repository never changes the database schema; DDL goes through a + DOS/DOS.Me PR and follows DOS.Me's `AGENTS.md`. +- How the PO runs this repository (board, branches, gates, required checks) is + in [docs/product-owner-config.md](docs/product-owner-config.md); the product + and money design is in + [docs/Give-Technical-Design.md](docs/Give-Technical-Design.md). diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d93949..f280c182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,175 @@ they reach Production with a separate, approved promotion of DOS.Me `main`. ### Design system and screens +- Co-organizers (campaign editors), single-use invites, workspace guards and + public team block: `/me/campaigns/[id]?tab=team` (`TeamTab`, + `CreateInviteForm`, `member-actions.ts`) lets the owning organizer create + single-use expiring invite links (raw 64-char hex token shown once on + creation, never logged or re-displayed), revoke pending invites and remove + accepted editors, while explicitly keeping money, receiving accounts, + statements, refunds, fulfillment, monthly plans, analytics, lifecycle + transitions and team management owner-only (`notFound()` for editors/staff). + `/invites/[token]` sets `Referrer-Policy: no-referrer`, + `Cache-Control: private, no-store` and `X-Robots-Tag: noindex, nofollow`, + prompts guests to sign in without leaking draft titles or touching + `dbService()`, and previews/accepts pending invites via `dbAs(token)` with + already-member shortcuts. `/me/campaigns` lists both owned and accepted + editor campaigns (badged `"Đồng tổ chức"`), `/me/campaigns/[id]` lets + accepted editors manage content, cover, YouTube pitch video, milestones, + reward tiers and own updates under strict server guards, and public + `/campaigns/[slug]` pages render `CampaignTeam` (`"Đội ngũ tổ chức"`) when + a campaign has accepted editors, backed by `DOS/Give#264` (`DOS/DOS.Me#1856`) + with Vitest suites (#253 / #298). +- Public organizer profile page and `/me` handle/bio editor: `/u/[handle]` + renders public organizer profiles (`handle`, `bio`, `OrganizerAvatar` with + safe `https://` validation and 4px-radius initials fallback, verification + badge and public campaigns with ledger totals) strictly through anonymous + `dbAs()` calls to `give.public_organizer_profile` and + `give.list_organizer_public_campaigns`. `/me` (`PublicProfileForm`, + `actions.ts`, wired into `MePage` and `SiteHeader`) lets signed-in organizers + edit only `(handle, bio)` with live `give.vn/u/` URL preview, + 3–40-char regex and 96-word reserved-handle validation matching + `DOS/Give#261` (`DOS/DOS.Me#1851`), Vietnamese error mappings and preserved + `verification_status`, while `/campaigns/[slug]` and `CampaignCard` link the + organizer name to `/u/` when set, with Vitest suites (#251 / #297). +- Campaign comments with one reply level, moderation and comment reports queue: + public `/campaigns/[slug]` pages add the `#binh-luan` tab and + `CampaignComments` (plain-text comments and 1-level replies with newest roots + first and oldest replies first, `"Người tổ chức"` badge, `"(đã chỉnh sửa)"` + indicator, deleted-account neutral fallback, `?comments_page=` pagination, + authenticated post/reply/edit/delete/report, organizer hide, and staff + `?show_hidden=1` inline moderation with self-review guards via `dbAs(token)`). + `/admin/reports` gains a `TabNav` (`"Báo cáo chiến dịch"` / `"Báo cáo bình +luận"`) leading to `/admin/reports/comments` with status/campaign filters, + `list_comment_moderation_history` audit disclosure and deleted-comment + snapshot handling, backed by `DOS/Give#262` (`DOS/DOS.Me#1853`) with Vitest + suites (#250 / #296). +- Organizer campaign analytics and `Thống kê` tab: `POST /api/analytics/event` + (excluded from `proxy.ts` session rotation) validates same-origin / + `Sec-Fetch-Site`, enforces JSON/size bounds, silently filters bot User-Agents + while allowing Zalo/Facebook in-app browsers and Cốc Cốc, applies ephemeral + HMAC-hashed rate limiting, strips referrer paths/queries and normalizes + same-origin hosts to `null`, and calls `dbService().rpc("record_campaign_event")`. + `CampaignViewBeacon` deduplicates views to once per campaign per Vietnam + calendar day per browser (`sendBeacon` with `keepalive` `fetch` fallback, + suppressed on previews/prerenders) and `ShareButtons` records `share_click` + events. `/me/campaigns/[id]?tab=analytics` (`AnalyticsTab`, `TabNav` and + 7/30/90-day `SegmentedNav`) reads `give.get_campaign_analytics` via + `dbAs(token)` to render KPIs, daily views trend, responsive breakdown and + referrer bars, backed by `DOS/Give#263` (`DOS/DOS.Me#1852`) with Vitest + suites (#252 / #295). +- Organizer campaign status and review history: `/me/campaigns/[id]` loads + `listStatusEventsByCampaign(db, [campaign.id])` inside `Promise.all` with + `.catch(() => new Map())` resilience and renders `` inside + `#status` (`"Trạng thái"`), replacing `"Không có thao tác nào ở trạng thái +này."` on non-actionable statuses while sitting cleanly above `"Gửi duyệt"` + and `"Hủy chiến dịch"` when status actions are available, with RSC Vitest + coverage for rendered transitions and failed `campaign_status_events` reads + (#287 / #288). +- Organizer draft campaign updates workflow: `/me/campaigns/[id]` extends + `postUpdate` with `intent = "draft" | "publish"` (preserving immediate + publish when `intent` is omitted, inserting `published_at: null` across all + `canPostUpdate` statuses, and gating immediate publish to approved and + public statuses) and adds `updateDraftUpdate`, `publishDraftUpdate` and + `deleteDraftUpdate` strictly scoped to `.is("published_at", null)` with + organizer and public route revalidations. `#updates` lets organizers prepare, + inline-edit (`
` `"Sửa bản nháp"`) and delete drafts before + approval, places secondary `"Lưu bản nháp"` ahead of primary `"Đăng công +khai"` once publishable, badges unpublished rows (`Bản nháp`) separately + from permanent published dates (`Đã đăng`), and guards publish and delete + actions with `confirm` dialogs, with Vitest suites (#281 / #286). +- Campaign `BreadcrumbList` JSON-LD structured data: public non-preview, + non-halted `/campaigns/[slug]` views emit a `schema.org` `BreadcrumbList` + `` or `