Repository navigation
feat(money): Early Bird reward tiers editor, public display, and pledge expiry handling - #325
Conversation
…ge expiry handling Refs #317
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
|
|
PO acceptance: merge at 098e13b Independent PO flagship money-domain review (b5b1b2e2-2317-4f09-94a8-55ce55b730ed): APPROVE (0 P0/P1/P2 findings).
|
Refs #317
Summary
Phase 2 (App) for Back conversion — Early Bird reward tiers (paired with merged Phase 1 DB migration
DOS/DOS.Me#1885,20261202110000_give_early_bird_reward_tiers.sql, live on Betaoyajkbadsykigtfrpdpgat6b593617144fe4a4f77007238ef8775f00b0db43):/me/campaigns/[id]):is_early_bird) and Vietnam-time (Asia/Ho_Chi_Minh)datetime-localdeadline picker (available_until, bounded by campaignstarts_at/ends_at) inRewardTiersSection.tsx.rewardTierSchemaandsaveRewardTierserver action to the 13-arggive.save_reward_tierRPC (p_is_early_bird,p_available_until), validating Early Bird scarcity limit (slot cap and/or deadline) and schedule bounds while preserving#264owner/editor parity."Ưu đãi Early Bird"(Badge tone="warning"), Vietnam-time deadline, and expired status (Badge tone="danger") in tier summaries./campaigns/[slug],/campaigns/[slug]/pledge):give.public_reward_tiers/give.reward_tiersqueries and types (PublicRewardTier,RewardTier) to select and normalizeis_early_birdandavailable_until."Ưu đãi Early Bird"badge, remaining slots, and Vietnam-time deadline on/campaigns/[slug](RewardTiers.tsx) and/campaigns/[slug]/pledge(PledgeForm.tsx), cleanly disabling selection afteravailable_untilpasses (now() >= available_until)."Xem cam kết"and"Hủy cam kết", see"Mức hiện tại của bạn"on their expired tier (disabled from re-submitting a failingchange_pledge), and can cleanly switch to another active tier or"Ủng hộ không nhận quà".savePledgeplus Vietnamese error mapping forGIVE_REWARD_EXPIREDandGIVE_REWARD_TIER_DATES_INVALIDinlib/errors.tsandlib/pledges.ts(zero raw Postgres error leaks).DESIGN.mdtokens (Badge,rounded,text-smminimum for non-badge copy,tabular-nums, calm Vietnamese copy, noaccentmisuse, no nested boxes).pnpm format:check: PASSpnpm lint: PASSpnpm typecheck: PASSpnpm test: 201/201 test files, 2,830/2,830 tests PASSpnpm build: PASS361e342c-f3df-4016-bbfb-dba1c09e64cb):CLEAN_PASS.📌 TL;DR
This PR introduces "Early Bird" reward tiers, allowing campaign organizers to set time-limited deadlines for specific tiers. It implements full-stack validation (ensuring deadlines fall within the campaign window), UI updates to display badges and disable expired tiers, and safeguards to ensure existing pledges on expired tiers remain valid while preventing new pledges.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/lib/pledges.tsis_early_birdandavailable_untiltoPublicRewardTier. ImplementedisTierExpiredandisTierUnavailablehelper functions. AddedGIVE_REWARD_EXPIREDerror message.apps/web/src/lib/reward-tiers.tsRewardTierinterface andTIER_COLUMNSconstant to include the new Early Bird fields.apps/web/src/lib/validation.tsrewardTierSchemato parseis_early_birdandavailable_until. Added logic to clear the deadline if Early Bird is disabled and a refinement to ensure Early Bird tiers have either a quantity limit or a deadline.apps/web/src/lib/errors.tsGIVE_REWARD_EXPIREDandGIVE_REWARD_TIER_DATES_INVALID.apps/web/src/server/pledges/index.tstoTiermapper to include the new Early Bird fields from database rows.apps/web/src/app/campaigns/[slug]/pledge/PledgeForm.tsxcurrentTierIdandnowIso. Renders "Early Bird" badges, displays deadlines, and disables radio buttons for expired or sold-out tiers.apps/web/src/app/campaigns/[slug]/pledge/actions.tssavePledgeto reject pledges if the selected tier is expired (isTierExpired).apps/web/src/app/campaigns/[slug]/pledge/page.tsxcurrentTierIdandnowIsoto the form. Displays a reassurance message that existing pledges remain valid despite tier expiry.apps/web/src/components/RewardTiers.tsxapps/web/src/app/me/campaigns/[id]/RewardTiersSection.tsxdatetime-localdeadline. Displays badges and deadline info in the tier summary.apps/web/src/app/me/campaigns/reward-actions.tssaveRewardTierto ensure Early Bird deadlines are in the future and within the campaign's start/end dates. Passes new fields to the database RPC.apps/web/src/app/me/campaigns/[id]/page.tsxstartsAtandendsAttoRewardTiersSectionto enable deadline validation bounds.*.test.ts📊 Architectural Flow
flowchart TD subgraph Organizer_UI [Organizer UI] A[RewardTiersSection] -->|is_early_bird, available_until| B[saveRewardTier Action] end subgraph Server_Validation [Server Validation] B --> C{Validate Deadline} C -->|Past Date| D[Error: Must be future] C -->|Outside Campaign Window| E[Error: Must be within campaign dates] C -->|Valid| F[RPC: save_reward_tier] end subgraph Database [Database] F --> G[(Reward Tiers Table)] end subgraph Backer_UI [Backer UI] H[RewardTiers Component] -->|Click Tier| I[Pledge Page] I --> J{Check Tier Status} J -->|Expired/Sold Out| K[Disable Selection] J -->|Active| L[PledgeForm] L -->|Submit| M[savePledge Action] end subgraph Pledge_Validation [Pledge Validation] M --> N{isTierExpired?} N -->|Yes| O[Error: GIVE_REWARD_EXPIRED] N -->|No| P[Create/Update Pledge] end G -.->|Read Tiers| H G -.->|Read Tiers| I