Skip to content

feat(campaigns): structured campaign FAQ and duplicate campaign draft - #324

Merged
JOY (JOY) merged 1 commit into
devfrom
antigravity/give-316-faq-duplicate
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
antigravity/give-316-faq-duplicate

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs #316

Summary

Phase 2 (App) for Give v2 Sprint 5 Wave B / Gói 4a — structured campaign FAQ management, public FAQ accordion, and owner-only campaign draft duplication (backed by merged DB PR DOS/DOS.Me#1882 / 5c847b79b9269e1b4c2d2ba730d9b209552be52f on Beta oyajkbadsykigtfrpdpg):

  1. FAQ Editor in /me/campaigns/[id] (FaqSection.tsx, faq-actions.ts, campaign-faqs.ts):
    • Add, edit, delete, and reorder up to 25 FAQs using authenticated-only RPCs (upsert_campaign_faq, delete_campaign_faq, reorder_campaign_faqs, zero service_role).
    • Allowed for owning organizer and active accepted co-organizer editor (#264) on draft, changes_requested, approved, and live campaigns; read-only on in_review and ended/locked states.
    • Full Vietnamese validation and DB error mapping in errors.ts / validation.ts with zero raw DB errors.
  2. Public FAQ Accordion on /campaigns/[slug] (CampaignFaqAccordion.tsx):
    • Accessible native <details>/<summary> accordion (#hoi-dap) plus Hỏi đáp tab rendered when FAQs exist on live/public, pre-launch, and preview pages.
    • Plain-text React rendering with whitespace-pre-line break-words (zero raw HTML / XSS).
  3. Owner-only Tạo bản sao chiến dịch action on /me/campaigns (page.tsx, duplicateCampaignDraft in actions.ts):
    • Strictly visible and callable only for owning organizer (role === 'owner') on non-suspended campaigns — hidden and refused for co-organizer editors (#264) and suspended campaigns.
    • Calls give.duplicate_campaign_draft via dbAs(session.accessToken), revalidates /me/campaigns, and redirects directly to /me/campaigns/<new_id>.

Verification

  • pnpm format:check — PASS
  • pnpm lint — PASS
  • pnpm typecheck — PASS
  • pnpm test — PASS (190 test files, 2,744 tests including new unit/action/component/page tests for FAQs and campaign duplication)
  • pnpm build — PASS
  • Fresh-context subagent quality pass on a3dfb56c17aeab32ed04b5351e04976d079cebb3 — CLEAN_PASS.

📌 TL;DR

This PR introduces a structured FAQ system for campaigns, allowing organizers to create, edit, and reorder up to 25 FAQs that are displayed on public campaign pages. It also adds a "Duplicate Campaign" feature for owners to clone active campaigns into new drafts.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/lib/campaign-faqs.ts New Core Logic: Defines the CampaignFaq interface, constants (max 25 FAQs, char limits), and helper functions for sorting, moving, and permission checks (canEditFaqs, canDuplicateCampaign). Includes listCampaignFaqs for DB retrieval.
apps/web/src/lib/validation.ts Adds campaignFaqSchema (Zod) to validate question/answer length and non-empty content.
apps/web/src/lib/errors.ts Maps new database error codes (e.g., GIVE_FAQ_LIMIT_EXCEEDED, GIVE_CAMPAIGN_SUSPENDED) to user-friendly Vietnamese messages.
apps/web/src/app/me/campaigns/faq-actions.ts New Server Actions: Implements saveCampaignFaq (create/update), deleteCampaignFaq, and moveCampaignFaq. Enforces RLS/role checks and status restrictions.
apps/web/src/app/me/campaigns/actions.ts Adds duplicateCampaignDraft server action. Validates owner role and non-suspended status, calls duplicate_campaign_draft RPC, and redirects to the new draft.
apps/web/src/app/me/campaigns/[id]/FaqSection.tsx New Component: The admin UI for managing FAQs. Includes add/edit forms, reorder buttons, delete actions, and error states.
apps/web/src/app/me/campaigns/[id]/page.tsx Integrates FaqSection into the campaign editor page. Fetches FAQs and adds a "Câu hỏi thường gặp" tab. Updates co-organizer permission copy.
apps/web/src/app/me/campaigns/page.tsx Adds a "Tạo bản sao chiến dịch" (Duplicate) button to the campaign list for owners on non-suspended campaigns.
apps/web/src/components/campaign/CampaignFaqAccordion.tsx New Component: Public-facing FAQ accordion using native <details>/<summary> for accessibility. Renders plain text to prevent XSS.
apps/web/src/app/campaigns/[slug]/page.tsx Integrates CampaignFaqAccordion into the public campaign page. Fetches FAQs and adds a "Hỏi đáp" tab to the navigation if FAQs exist.
*.test.ts New Tests: Comprehensive unit and integration tests for FAQ logic, server actions, components, and the duplicate campaign feature. Verifies security (XSS escaping, role checks) and edge cases (limits, suspended states).

📊 Architectural Flow

sequenceDiagram
    participant User as Organizer
    participant AdminUI as FaqSection (Admin)
    participant ServerAction as faq-actions.ts
    participant DB as Supabase (RPC)
    participant PublicUI as CampaignFaqAccordion
    participant PublicPage as Campaign Page

    Note over User, DB: FAQ Management Flow
    User->>AdminUI: Add/Edit/Move FAQ
    AdminUI->>ServerAction: Submit Form (saveCampaignFaq)
    ServerAction->>ServerAction: Validate Role & Status
    ServerAction->>DB: RPC: upsert_campaign_faq
    DB-->>ServerAction: Success
    ServerAction-->>AdminUI: Revalidate & Success Message

    Note over User, PublicPage: Public Display Flow
    PublicPage->>DB: Fetch FAQs (listCampaignFaqs)
    DB-->>PublicPage: FAQ Data
    PublicPage->>PublicUI: Render Accordion
    PublicUI-->>User: Display FAQs (Plain Text)

    Note over User, DB: Duplicate Campaign Flow
    User->>AdminUI: Click "Duplicate"
    AdminUI->>ServerAction: duplicateCampaignDraft
    ServerAction->>ServerAction: Check Owner & Status
    ServerAction->>DB: RPC: duplicate_campaign_draft
    DB-->>ServerAction: New Campaign ID
    ServerAction-->>User: Redirect to New Draft
Loading

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 3:14pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84f7ce67-47dd-4e9c-ad6b-108a60f9c25e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (16 eligible files · 59,814 chars · 4 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 4c1b736 / head a3dfb56.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY
JOY (JOY) force-pushed the antigravity/give-316-faq-duplicate branch from a3dfb56 to e349a12 Compare November 22, 2026 15:01
dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (16 eligible files · 59,992 chars · 2 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base d194a8f / head e349a12.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY
JOY (JOY) force-pushed the antigravity/give-316-faq-duplicate branch from e349a12 to 932ab35 Compare November 22, 2026 15:13
dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (16 eligible files · 62,236 chars · 2 model call(s) · 3 PR unit(s))

Whole diff with bounded context at base 56274cf / head 932ab35.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 932ab35

Independent PO flagship review (a4a3a6ce-c4ff-4634-808b-e2578430785b): APPROVE (0 P0/P1/P2).

@JOY
JOY (JOY) merged commit 5ef3bb1 into dev Nov 22, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-316-faq-duplicate branch November 22, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant