Conversation
Added isClosed state to Form Editor Added "Form Closed" gate in form responder. Added "Closed" tag to forms in dashboard. Reformatted Form Options into Dropdown Ran Format, Lint, and Typecheck
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a form-closure feature: new Changes
Sequence DiagramsequenceDiagram
participant Admin as Admin (Editor)
participant Server as API Server
participant DB as Database
participant Responder as Form Responder
Admin->>Admin: Open form settings dropdown
Admin->>Admin: Toggle "Form Closed"
Admin->>Server: Save form { isClosed: true }
Server->>DB: Update form.isClosed
DB-->>Server: Confirmation
Server-->>Admin: Return { isClosed: true }
Note over Responder,Server: Later, user attempts to respond
Responder->>Server: Fetch form (includes isClosed)
Server->>DB: Query form by slug/id
DB-->>Server: Return form (isClosed: true)
Server-->>Responder: Return form data
Responder->>Responder: Check isClosed guard
Responder-->>Responder: Render "Form Closed" message, block submit
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 7 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/blade/src/app/_components/forms/form-responder-client.tsx (1)
86-87: Short-circuit closed forms before non-essential query errors.Line 110 adds the closed-state UI, but Line 78 can still return early with an unrelated existing-response error first. For closed forms, skip that query and prioritize a single closed-state render.
♻️ Suggested adjustment
const existingResponseQuery = api.forms.getUserResponse.useQuery( { form: formIdGate }, - { enabled: !!formIdGate }, + { enabled: !!formIdGate && !formQuery.data?.isClosed }, ); @@ - // not found - if (existingResponseQuery.error) - return <div>Error Loading existing response</div>; - const form = formQuery.data.formData as FORMS.FormType; @@ const isClosed = formQuery.data.isClosed; + if (isClosed) { + return ( + <div className="flex min-h-screen items-center justify-center bg-primary/5 p-6"> + <Card className="max-w-md p-8 text-center"> + <XCircle className="mx-auto mb-4 h-16 w-16 text-destructive" /> + <h1 className="mb-2 text-2xl font-bold">Form Closed</h1> + <p className="text-muted-foreground"> + This form is no longer accepting responses. + </p> + </Card> + </div> + ); + } + + if (existingResponseQuery.error) return <div>Error loading form state</div>;Based on learnings: "gating rendering should occur only when all required data fetches succeed... implement a unified loading/state or error handling that surfaces a single, coherent state once all data is ready or failed."
Also applies to: 110-122
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/blade/src/app/_components/forms/form-responder-client.tsx` around lines 86 - 87, The component currently surfaces non-essential query errors (like responseQuery failures) before rendering the closed-form UI; change the flow so you derive isClosed from formQuery (guarding formQuery.data) and short-circuit to render the closed-state block immediately when isClosed is true, and prevent running responseQuery when the form is closed by disabling it (use the query's enabled flag tied to !isClosed); update logic around formQuery, isClosed, responseQuery and the closed-state render block so closed-state rendering takes priority over unrelated query errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/blade/src/app/_components/admin/forms/editor/client.tsx`:
- Around line 579-581: The icon-only Button rendering the CogIcon in client.tsx
(the Button containing <CogIcon className="h-4 w-4" />) needs an accessible
name; add an aria-label (and optional title) such as aria-label="Form settings"
to the Button element so screen readers can identify the control and keep the
visual appearance unchanged.
In `@packages/api/src/routers/forms.ts`:
- Around line 1352-1358: The current toggleFormClosed implementation reads
form.isClosed then writes the inverted value, which can lose toggles under
concurrency; change the update to perform the flip atomically in the database by
issuing a single update on FormsSchemas that sets isClosed = NOT isClosed (or
equivalent DB boolean flip) and use returning() to get the new value instead of
separate read-then-write; apply the same change to the other toggle site
referenced (the block around the FormsSchemas update at 1367-1368) so both
locations use a single UPDATE ... SET isClosed = NOT isClosed RETURNING(*)
pattern and return the updated row.
---
Nitpick comments:
In `@apps/blade/src/app/_components/forms/form-responder-client.tsx`:
- Around line 86-87: The component currently surfaces non-essential query errors
(like responseQuery failures) before rendering the closed-form UI; change the
flow so you derive isClosed from formQuery (guarding formQuery.data) and
short-circuit to render the closed-state block immediately when isClosed is
true, and prevent running responseQuery when the form is closed by disabling it
(use the query's enabled flag tied to !isClosed); update logic around formQuery,
isClosed, responseQuery and the closed-state render block so closed-state
rendering takes priority over unrelated query errors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 61b11d26-3f6e-4857-abe2-7c10ee03b3a7
📒 Files selected for processing (6)
apps/blade/src/app/_components/admin/forms/editor/client.tsxapps/blade/src/app/_components/dashboard/member-dashboard/forms/form-responses.tsxapps/blade/src/app/_components/forms/form-responder-client.tsxapps/blade/src/app/_components/forms/form-view-edit-client.tsxpackages/api/src/routers/forms.tspackages/db/src/schemas/knight-hacks.ts
Ran format, lint, and typecheck
Why
Forms did NOT have the ability to close 🤯. This PR aims to add form closure to blade.
What
Closes: #369
Files Changed
Change Descriptions
Test Plan
Images
Checklist
db:pushbefore mergingSummary by CodeRabbit
New Features
Bug Fixes