Repository navigation
feat(campaigns): structured campaign FAQ and duplicate campaign draft - #324
Conversation
There was a problem hiding this comment.
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
a3dfb56 to
e349a12
Compare
…d duplicate campaign draft (#316)
e349a12 to
932ab35
Compare
|
PO acceptance: merge at 932ab35 Independent PO flagship review (a4a3a6ce-c4ff-4634-808b-e2578430785b): APPROVE (0 P0/P1/P2).
|
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/5c847b79b9269e1b4c2d2ba730d9b209552be52fon Betaoyajkbadsykigtfrpdpg):/me/campaigns/[id](FaqSection.tsx,faq-actions.ts,campaign-faqs.ts):upsert_campaign_faq,delete_campaign_faq,reorder_campaign_faqs, zeroservice_role).#264) ondraft,changes_requested,approved, andlivecampaigns; read-only onin_reviewand ended/locked states.errors.ts/validation.tswith zero raw DB errors./campaigns/[slug](CampaignFaqAccordion.tsx):<details>/<summary>accordion (#hoi-dap) plusHỏi đáptab rendered when FAQs exist on live/public, pre-launch, and preview pages.whitespace-pre-line break-words(zero raw HTML / XSS).Tạo bản sao chiến dịchaction on/me/campaigns(page.tsx,duplicateCampaignDraftinactions.ts):role === 'owner') on non-suspendedcampaigns — hidden and refused for co-organizer editors (#264) andsuspendedcampaigns.give.duplicate_campaign_draftviadbAs(session.accessToken), revalidates/me/campaigns, and redirects directly to/me/campaigns/<new_id>.Verification
pnpm format:check— PASSpnpm lint— PASSpnpm typecheck— PASSpnpm test— PASS (190 test files, 2,744 tests including new unit/action/component/page tests for FAQs and campaign duplication)pnpm build— PASSa3dfb56c17aeab32ed04b5351e04976d079cebb3—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
🔍 Changes Walkthrough
apps/web/src/lib/campaign-faqs.tsCampaignFaqinterface, constants (max 25 FAQs, char limits), and helper functions for sorting, moving, and permission checks (canEditFaqs,canDuplicateCampaign). IncludeslistCampaignFaqsfor DB retrieval.apps/web/src/lib/validation.tscampaignFaqSchema(Zod) to validate question/answer length and non-empty content.apps/web/src/lib/errors.tsGIVE_FAQ_LIMIT_EXCEEDED,GIVE_CAMPAIGN_SUSPENDED) to user-friendly Vietnamese messages.apps/web/src/app/me/campaigns/faq-actions.tssaveCampaignFaq(create/update),deleteCampaignFaq, andmoveCampaignFaq. Enforces RLS/role checks and status restrictions.apps/web/src/app/me/campaigns/actions.tsduplicateCampaignDraftserver action. Validates owner role and non-suspended status, callsduplicate_campaign_draftRPC, and redirects to the new draft.apps/web/src/app/me/campaigns/[id]/FaqSection.tsxapps/web/src/app/me/campaigns/[id]/page.tsxFaqSectioninto 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.tsxapps/web/src/components/campaign/CampaignFaqAccordion.tsx<details>/<summary>for accessibility. Renders plain text to prevent XSS.apps/web/src/app/campaigns/[slug]/page.tsxCampaignFaqAccordioninto the public campaign page. Fetches FAQs and adds a "Hỏi đáp" tab to the navigation if FAQs exist.*.test.ts📊 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