Skip to content

Add admin control for member dues payment availability - #505

Merged
DVidal1205 merged 1 commit into
mainfrom
blade/lock-reforge-dues-until-august-31
Aug 12, 2026
Merged

Add admin control for member dues payment availability#505
DVidal1205 merged 1 commit into
mainfrom
blade/lock-reforge-dues-until-august-31

Conversation

@cataladev

@cataladev cataladev commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Why

Member dues payments need to remain paused while the constitution is being reworked. A hardcoded reopening date would require another deployment and could become outdated, so payment availability should be controlled by administrators instead.

What

  • Removed the hardcoded August 31 reopening date.
  • Added a persisted global setting for enabling or pausing dues payments.
  • Added a Member payments switch to the /admin/members page.
  • Limited the switch to admins with EDIT_MEMBERS; read-only admins can still see the current status.
  • Defaulted payments to paused.
  • Enforced the setting server-side before creating a Stripe PaymentIntent.
  • Added audit logging whenever an admin changes payment availability.
  • Added and committed database migration 0040_gigantic_blockbuster.sql.
  • Preserved existing paid statuses, pricing, payment history, and academic-year behavior.

Test Plan

  • Ran pnpm db:generate.
  • Ran pnpm db:migrate.
  • Ran pnpm format.
  • Ran pnpm lint.
  • Ran pnpm typecheck.
  • Ran pnpm analyze:react:changed.
  • Ran the complete DB test suite: 97 passed.
  • Ran the complete validators test suite: 255 passed.
  • Ran the complete API test suite: 577 passed.
  • Ran the complete Blade test suite: 703 passed.
  • Ran the focused dues Playwright suite: 6 scenarios passed.
  • Verified enabling and pausing payments through the admin switch.
  • Reviewed the control at desktop and mobile widths.
  • Verified Stripe payment setup is rejected while payments are paused.

Checklist

  • Database: I ran pnpm db:generate and committed the generated files in packages/db/drizzle/.
  • Environment Variables: No environment variables changed.

Summary by CodeRabbit

  • New Features

    • Added an admin control to enable or pause member dues payments.
    • Authorized editors can change payment availability; read-only admins can view the setting.
    • Paused payments display clear messaging and remove checkout actions for members.
    • Enabling payments restores the existing dues payment flow.
  • Bug Fixes

    • Prevented payment setup from starting while dues payments are paused.
    • Preserved paid status and academic-year dues behavior during pauses.
  • Tests

    • Added coverage for admin permissions, paused-payment experiences, and payment restoration.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alexanderpaolini, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6667b136-9a0d-4e6b-a6e6-425d39797b96

📥 Commits

Reviewing files that changed from the base of the PR and between 530a963 and f367d12.

📒 Files selected for processing (2)
  • .forge/features/admin-member-dashboard/test-cases.md
  • apps/blade/src/tests/e2e/admin-member-dashboard.spec.ts
📝 Walkthrough

Walkthrough

The change replaces the fixed dues-payment cutoff with persisted admin-controlled availability. Authorized administrators can pause or enable payments. Paused members cannot start checkout and see paused messaging. Paid status remains unchanged.

Changes

Dues payment availability

Layer / File(s) Summary
Configuration storage and admin API
.forge/features/*, packages/db/..., packages/validators/..., packages/api/src/routers/member-admin.ts, packages/api/src/utils/dues/configuration.ts
Adds the singleton DuesConfiguration, migration 0040, strict boolean validation, authorized read/update procedures, transactional upserts, audit logging, and database-backup sanitization.
Dues enforcement and member UI
packages/api/src/routers/dues.ts, apps/blade/src/app/member/dues/page.tsx, apps/blade/src/app/_components/member/*, apps/blade/src/tests/member/*, apps/blade/src/tests/e2e/*
Exposes paymentsLocked, rejects paused PaymentIntent creation before Stripe, and renders paused dashboard and dues-page states.
Admin dashboard control
apps/blade/src/app/admin/members/page.tsx, apps/blade/src/app/_components/admin/members/member-admin-dashboard.tsx, apps/blade/src/tests/admin/*
Adds an editor-only payment availability switch, read-only status for other administrators, mutation feedback, and refresh behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant AdminDashboard
  participant memberAdminRouter
  participant DuesConfiguration
  participant Member
  participant duesRouter
  Admin->>AdminDashboard: Enable or pause payments
  AdminDashboard->>memberAdminRouter: Update availability
  memberAdminRouter->>DuesConfiguration: Persist global setting
  Member->>duesRouter: Request dues status or checkout
  duesRouter->>DuesConfiguration: Read availability
  duesRouter-->>Member: Return paused state or create payment flow
Loading

Possibly related PRs

  • KnightHacks/forge#415: Introduced the dues checkout and createPaymentIntent flow enforced by this change.

Suggested labels: Feature, Major, Blade, API, Database

Suggested reviewers: dvidal1205

🚥 Pre-merge checks | ✅ 6 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title clearly describes the main change but does not start with the required issue number format, such as "[#505]". Prefix the title with the issue number in brackets, for example: "[#505] Add admin control for member dues payment availability".
Docstring Coverage ⚠️ Warning Docstring coverage is 4.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No Hardcoded Secrets ✅ Passed Diff scans found no newly added API-key, password, token, or private-key literals; the existing pi_test_secret_secret fixture predates this pull request.
Validated Env Access ✅ Passed The PR diff adds no process.env lines, and none of its 36 changed paths contain process.env; existing repository hits are outside this change.
No Typescript Escape Hatches ✅ Passed The actual parent-to-HEAD diff adds no any types, @ts-ignore, @ts-expect-error, or non-null assertions; added ! uses are boolean negation only.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch blade/lock-reforge-dues-until-august-31

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

Comment @coderabbitai help to get the list of available commands.

@alexanderpaolini alexanderpaolini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a few concerns about how its done. I think either it should be full hacky or full implementation, not a mix of both. Best to standardize in database as global option, or env, or something stable. Approving because code LGTM and I know its urgent, but if theres time, I vote to formalize it as an option

Maybe in the admin page "Disable Club Dues" check box. Or "Disable Club Dues Until". Codex got that for sure. Tell it to just amend and --force-with-lease and prolly will figure it out

@alexanderpaolini

Copy link
Copy Markdown
Contributor

What
lcok dusc

Closes: #ISSUE_NUMBER

Test Plan
Checklist
Database: No schema changes, OR I ran pnpm db:generate and committed the generated files in packages/db/drizzle/
Environment Variables: No environment variables changed, OR I have contacted the Development Lead to modify them on Coolify BEFORE merging.

Just delete the format if you're not going to use it. If you're lazy just tell codex to make the PR for you. You might need to install a CLI but it'll figure it out

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.forge/features/member-dues-payment/test-cases.md:
- Line 397: Update the read-only member admin test case to directly invoke
memberAdmin.setDuesPaymentsEnabled, assert the API returns FORBIDDEN, then read
the dues-payment configuration and verify its value remains unchanged.

In `@packages/db/scripts/dev-db-backup-sanitizer.ts`:
- Line 26: Update teamDataSanitizerSql() to include an UPDATE for
knight_hacks_dues_configuration that sets payments_enabled to FALSE in sanitized
backups. Add a regression test verifying that an input value of true becomes
false.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a57cd4d-b133-4f0b-8341-b95bb0404950

📥 Commits

Reviewing files that changed from the base of the PR and between 8168e2b and aeb7530.

⛔ Files ignored due to path filters (1)
  • packages/api/src/tests/root/__snapshots__/api-surface.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (32)
  • .forge/features/admin-member-dashboard/spec.md
  • .forge/features/admin-member-dashboard/srd.md
  • .forge/features/admin-member-dashboard/status.md
  • .forge/features/admin-member-dashboard/test-cases.md
  • .forge/features/member-dues-payment/spec.md
  • .forge/features/member-dues-payment/srd.md
  • .forge/features/member-dues-payment/status.md
  • .forge/features/member-dues-payment/test-cases.md
  • apps/blade/src/app/_components/admin/members/member-admin-dashboard.tsx
  • apps/blade/src/app/admin/members/page.tsx
  • apps/blade/src/tests/admin/member-admin-dashboard.test.tsx
  • apps/blade/src/tests/e2e/member-dues-payment.spec.ts
  • apps/blade/src/tests/member/member-dashboard.test.tsx
  • apps/blade/src/tests/member/member-dues-page.test.tsx
  • docs/DATABASE-USAGE.md
  • packages/api/src/routers/dues.ts
  • packages/api/src/routers/member-admin.ts
  • packages/api/src/tests/admin/dues-configuration.test.ts
  • packages/api/src/tests/dues/router.test.ts
  • packages/api/src/tests/root/api-surface.test.ts
  • packages/api/src/utils/audit/coverage.ts
  • packages/api/src/utils/dues/configuration.ts
  • packages/db/drizzle/0040_gigantic_blockbuster.sql
  • packages/db/drizzle/meta/0040_snapshot.json
  • packages/db/drizzle/meta/_journal.json
  • packages/db/scripts/dev-db-backup-sanitizer.ts
  • packages/db/src/schemas/knight-hacks.ts
  • packages/db/src/tests/dev-db-backup-sanitizer.test.ts
  • packages/db/src/tests/migration-lineage.test.ts
  • packages/validators/src/admin-member.ts
  • packages/validators/src/audit.ts
  • packages/validators/src/tests/admin-member.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/blade/src/tests/member/member-dues-page.test.tsx
  • apps/blade/src/tests/member/member-dashboard.test.tsx
  • packages/api/src/routers/dues.ts
  • .forge/features/member-dues-payment/spec.md
  • packages/api/src/tests/dues/router.test.ts

Comment thread .forge/features/member-dues-payment/test-cases.md Outdated
Comment thread packages/db/scripts/dev-db-backup-sanitizer.ts

@alexanderpaolini alexanderpaolini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Def some open comments, but LGTM

Would appreciate if you can do 2 part PR. We can ship these RQ then fix tm

Comment thread .forge/features/member-dues-payment/srd.md
Comment thread .forge/features/member-dues-payment/status.md
Comment thread .forge/features/member-dues-payment/status.md
Comment thread apps/blade/src/app/_components/member/member-dashboard.tsx
Comment thread apps/blade/src/app/_components/member/member-dues-payment.tsx
Comment thread apps/blade/src/app/_components/member/member-dues-payment.tsx
Comment thread packages/api/src/utils/dues/configuration.ts Outdated
@alexanderpaolini alexanderpaolini changed the title feat(blade): pause dues payments until august 31 Add admin control for member dues payment availability Aug 12, 2026
@alexanderpaolini
alexanderpaolini force-pushed the blade/lock-reforge-dues-until-august-31 branch from aeb7530 to 530a963 Compare August 12, 2026 04:56

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.forge/features/admin-member-dashboard/test-cases.md:
- Around line 266-282: Extend TC-014 with executable checks that reload
/admin/members after each toggle and verify the persisted payment state, then
have a member attempt checkout while payments are paused and assert the dues API
rejects the request before Stripe setup or PaymentIntent creation. Preserve the
existing assertions for read-only visibility and unchanged dues rows and paid
statuses.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 94fdac13-e6a7-4823-bdc5-46f5030f47bf

📥 Commits

Reviewing files that changed from the base of the PR and between aeb7530 and 530a963.

📒 Files selected for processing (12)
  • .forge/features/admin-member-dashboard/srd.md
  • .forge/features/admin-member-dashboard/status.md
  • .forge/features/admin-member-dashboard/test-cases.md
  • .forge/features/member-dues-payment/srd.md
  • .forge/features/member-dues-payment/status.md
  • .forge/features/member-dues-payment/test-cases.md
  • packages/api/src/routers/dues.ts
  • packages/api/src/routers/member-admin.ts
  • packages/api/src/tests/admin/dues-configuration.test.ts
  • packages/api/src/utils/dues/configuration.ts
  • packages/db/scripts/dev-db-backup-sanitizer.ts
  • packages/db/src/tests/dev-db-backup-sanitizer.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/api/src/routers/dues.ts
  • .forge/features/member-dues-payment/test-cases.md
  • .forge/features/admin-member-dashboard/srd.md
  • packages/api/src/tests/admin/dues-configuration.test.ts
  • .forge/features/admin-member-dashboard/status.md
  • packages/api/src/routers/member-admin.ts
  • .forge/features/member-dues-payment/srd.md

Comment thread .forge/features/admin-member-dashboard/test-cases.md
@alexanderpaolini
alexanderpaolini force-pushed the blade/lock-reforge-dues-until-august-31 branch from 530a963 to f367d12 Compare August 12, 2026 05:16

@DVidal1205 DVidal1205 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@DVidal1205
DVidal1205 added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit cb53e69 Aug 12, 2026
21 of 23 checks passed
@DVidal1205
DVidal1205 deleted the blade/lock-reforge-dues-until-august-31 branch August 12, 2026 15:11
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.

3 participants