Skip to content

feat(start): quick-start Vietnamese campaign templates (Refs #338) - #343

Merged
JOY (JOY) merged 2 commits into
devfrom
antigravity/give-338-start-templates
Nov 23, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
antigravity/give-338-start-templates

Conversation

@JOY

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

Copy link
Copy Markdown
Contributor

Refs #338

Summary

  • Added apps/web/src/lib/campaign-templates.ts (+ campaign-templates.test.ts) with 5 curated Vietnamese templates (blank, medical_emergency, education_community, relief_environment, creative_product) and strict allowlist lookup getCampaignTemplate(id).
  • Added accessible StartCampaignForm (apps/web/src/app/start/StartCampaignForm.tsx + StartCampaignForm.test.ts) wired into /start (apps/web/src/app/start/page.tsx + page.test.ts):
    • Renders template cards in a keyboard-navigable radiogroup using DESIGN.md semantic tokens, spacing, and focus rings (noscript:hidden for zero-JS safety).
    • Pre-fills type, formatted goal_amount, title placeholder/hint, and hidden template_id while preserving user-entered titles, manual overrides on re-click, pre-hydration edits, and zero-JS baseline submission.
  • Updated createCampaign (apps/web/src/app/start/actions.ts + actions.test.ts):
    • Keeps omitted / null / "blank" behavior 100% identical to baseline with zero extra queries.
    • For non-blank templates, best-effort resolves matching active category (categoriesFor(categories, type) so manual type overrides never mismatch DB constraints), inserts category_id, summary, and Markdown story, and sequentially inserts 3 starter FAQs via upsert_campaign_faq best-effort without blocking draft creation or redirect.

Verification

  • pnpm format:check — PASS
  • pnpm --filter @give/web typecheck — PASS
  • pnpm --filter @give/web lint — PASS
  • pnpm --filter @give/web exec vitest run --maxWorkers=2 --fileParallelism=false — PASS (218 files, 2993 tests)
  • pnpm --filter @give/web build — PASS

📌 TL;DR

Introduces a "Quick Start" template selection feature to the campaign creation form, allowing users to pre-fill campaign type, goal amount, category, summary, story, and starter FAQs from five curated Vietnamese templates. The implementation ensures robust client-side state management (preserving user edits and supporting keyboard navigation) and server-side fault tolerance (non-blocking category/FAQ lookups) to streamline the onboarding experience.

🎯 Type of Change

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

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/lib/campaign-templates.ts New. Defines the CampaignTemplate interface and exports the 5 curated templates (blank, medical, education, relief, creative). Includes a safe lookup function getCampaignTemplate and a VND goal formatter.
apps/web/src/lib/campaign-templates.test.ts New. Unit tests validating template data integrity, schema limits (summary/story/FAQ lengths), and the safety of the getCampaignTemplate lookup against prototype pollution and invalid inputs.
apps/web/src/app/start/StartCampaignForm.tsx New. Extracts the campaign form into a dedicated client component. Adds a role="radiogroup" template picker with roving tabindex keyboard navigation. Implements logic to pre-fill form fields (type, goal, title placeholder) while preserving user-entered values (title, custom goal) and handling hydration.
apps/web/src/app/start/StartCampaignForm.test.ts New. Comprehensive integration tests for the form component, covering default states, template selection side-effects, preservation of user edits, hydration behavior, and keyboard accessibility (Arrow/Home/End).
apps/web/src/app/start/actions.ts Modified. Updates the createCampaign server action to accept template_id. If a non-blank template is selected, it attempts to resolve the category_id and insert starter FAQs via rpc. These operations are wrapped in try/catch blocks to ensure that template enrichment failures never block the core campaign draft creation.
apps/web/src/app/start/actions.test.ts Modified. Adds tests for the new template logic in the server action, verifying correct DB payloads (category, summary, story, FAQs), handling of type/category mismatches, and resilience against DB errors during template enrichment.
apps/web/src/app/start/page.tsx Modified. Refactors the page to use the new StartCampaignForm component, removing the inline form markup. Updates the page description to mention the new template options.
apps/web/src/app/start/page.test.ts Modified. Updates existing page tests to assert the presence of the new template radiogroup and hidden input.

📊 Architectural Flow

sequenceDiagram
    participant User
    participant Form as StartCampaignForm (Client)
    participant Action as createCampaign (Server)
    participant DB as Supabase DB

    User->>Form: Selects Template (e.g., "medical_emergency")
    Form->>Form: Updates UI State (type, goal, placeholders)
    Note right of Form: Preserves user-entered Title/Goal<br/>if not matching template defaults

    User->>Form: Submits Form
    Form->>Action: POST FormData (includes template_id)
    
    Action->>Action: Validate & Parse Form
    Action->>Action: Resolve Template (getCampaignTemplate)
    
    alt Template is "blank" or invalid
        Action->>DB: Insert Campaign (Base Fields)
    else Template is active
        Action->>DB: List Categories
        DB-->>Action: Categories
        Action->>Action: Match Category Slug (non-blocking)
        
        Action->>DB: Insert Campaign (Base + Category + Summary + Story)
        DB-->>Action: Campaign ID
        
        loop For each Starter FAQ
            Action->>DB: RPC upsert_campaign_faq
            Note right of DB: Errors are caught & logged<br/>but do not fail the request
        end
    end
    
    Action->>Action: Revalidate & Redirect
    Action-->>User: Redirect to /me/campaigns/{id}
Loading

@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 23, 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 23, 2026 1:04pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 23, 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: 06ac856c-a96e-4096-8fd2-906cf53f5495

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 23, 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 (8 eligible files · 54,521 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 5b6e52a / head 13fc78b.

✅ 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 13fc78b

@JOY
JOY (JOY) merged commit 0adb99e into dev Nov 23, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-338-start-templates branch November 23, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant