Skip to content

Editor account section and submit guard for back campaigns (#85) - #90

Merged
JOY (JOY) merged 2 commits into
devfrom
claude/85-back-require-account
Nov 3, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
claude/85-back-require-account

Conversation

@JOY

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

Copy link
Copy Markdown
Contributor

Refs #85

Why

A back campaign's backers pay the creator's own bank account by VietQR once the campaign succeeds, so a back campaign must not be submitted, approved or go live without a usable receiving account. The database rule is DOS/DOS.Me#1549 (migration 20261106100000); this PR is the app side.

What

Tests

  • Vitest: 895 passed (new: back submit refused without an account / allowed with one / money-history wording; editor loads back accounts, no swap reads for back; back release allowed in changes_requested).
  • turbo typecheck lint green, Prettier clean.
  • Not checked in a running app (no local Supabase session).

Merge after (or with) DOS/DOS.Me#1549.

🤖 Generated with Claude Code


📌 TL;DR

Extends the receiving account validation and release logic to support "back" (reward-based) campaigns, ensuring they require a verified account before review and allowing account releases when changes are requested. Updates UI copy and error messages to distinguish between charity and reward-based campaigns, directing the latter to contact support for account swaps.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 📚 Documentation

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/app/admin/page.tsx Updates admin dashboard copy to include "back" campaigns in the "waiting for account" section and adds a TypeBadge to distinguish campaign types.
apps/web/src/app/me/accounts/actions.test.ts Updates tests to verify that releaseAccount now succeeds for "back" campaigns in changes_requested status.
apps/web/src/app/me/accounts/page.tsx Generalizes UI copy for account binding/release rules to apply to all campaign types, not just charity.
apps/web/src/app/me/campaigns/[id]/page.tsx Refactors the campaign editor to load account data for both "give" and "back" types. Updates error messages to direct "back" campaign organizers to contact support instead of using the swap feature.
apps/web/src/app/me/campaigns/actions.test.ts Adds tests to ensure submitForReview blocks "back" campaigns without a valid account and handles unusable accounts correctly.
apps/web/src/app/me/campaigns/actions.ts Modifies submitForReview to enforce account validation for all campaign types, passing the campaign type to the validation logic.
apps/web/src/lib/campaign-account.test.ts Updates tests for loadEditorAccounts and submitAccountProblem to cover "back" campaign scenarios, including the absence of swap requests.
apps/web/src/lib/campaign-account.ts Extends loadEditorAccounts, checkSubmitAccount, and submitAccountProblem to accept a type parameter. Logic now prevents swap requests for "back" campaigns and generates appropriate error messages.
apps/web/src/lib/campaigns.ts Updates documentation comments to reflect that "back" campaigns are now included in the "waiting for account" logic.
apps/web/src/lib/errors.ts Updates error message constants to provide specific guidance for "back" campaigns (contact support) vs. "give" campaigns (request swap).
apps/web/src/lib/receiving-accounts.test.ts Updates test to confirm canAskRelease returns true for "back" campaigns in changes_requested status.
apps/web/src/lib/receiving-accounts.ts Modifies canAskRelease to allow account releases for any campaign type (including "back") when the status is changes_requested.

📊 Architectural Flow

flowchart TD
    A[Organizer Submits Campaign] --> B{Check Campaign Type}
    B -->|Give| C[Validate Account & Check Swap Eligibility]
    B -->|Back| D[Validate Account & Disable Swap]
    C --> E{Account Usable?}
    D --> E
    E -->|No| F[Block Submission]
    F --> G{Has Transactions?}
    G -->|Yes & Give| H[Direct to Swap Request]
    G -->|Yes & Back| I[Direct to Contact Support]
    G -->|No| J[Direct to Release & Rebind]
    E -->|Yes| K[Allow Submission to Review]
    
    L[Organizer Requests Release] --> M{Status is changes_requested?}
    M -->|Yes| N{Type is defined?}
    N -->|Yes| O[Allow Release]
    N -->|No| P[Refuse Release]
    M -->|No| Q[Check Standard Release Rules]
Loading

Back campaigns now need a usable receiving account before review,
approval and live (DOS/DOS.Me#1549), because their backers pay into it once
the campaign succeeds. The editor shows the receiving account section and
blocks "Gửi duyệt" for back campaigns as for give ones, and submitForReview
checks the account for both types.

Back campaigns have no account swap, so a blocked back campaign whose
account already recorded money is told to contact Give instead; swap
requests are read for give campaigns only. A back campaign sent back for
changes may release an account that saw no transaction, matching the
database. Wording no longer limits these rules to charity campaigns, and
the moderators' waiting queue shows each campaign's type.

Refs #85

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 3, 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: 45b8a673-ccb5-48a7-94f7-8a0bc152d517

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

dos[bot]
dos Bot approved these changes Nov 3, 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 (12 eligible files · 37,182 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base ffa6bb0 / head 614878f.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

…ive (#85)

Back campaigns have no account swap yet (#92), so the editor says to
contact Give instead of leaving the organizer without a next step.

Refs #85

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dos[bot]
dos Bot approved these changes Nov 3, 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 (12 eligible files · 37,727 chars · 3 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base ffa6bb0 / head 573b41c.

✅ 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 573b41c. CI green, DOS Code Review CLEAN_PASS, Vitest 895. DB part DOS/DOS.Me#1549 merged.

@JOY
JOY (JOY) merged commit c9d4a44 into dev Nov 3, 2026
4 checks passed
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