Files
pitchfast/backlog/tasks/task-5 - Implement-campaign-configuration-and-scheduling-controls.md

62 lines
3.8 KiB
Markdown

---
id: TASK-5
title: Implement campaign configuration and scheduling controls
status: Done
assignee: []
created_date: '2026-06-03 19:12'
updated_date: '2026-06-04 12:44'
labels:
- mvp
- campaigns
- forms
dependencies:
- TASK-4
references:
- PRD.md
priority: high
ordinal: 21000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Build the campaign management UI and backend mutations for reusable local search campaigns. Campaigns are configured with German postal code, radius, category or custom niche, run cadence, lead limits, audit limits, and active/paused state.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Campaign create/edit forms use React Hook Form, Zod, and shadcn form components
- [x] #2 Campaigns support predefined categories plus Anderes with a required custom input
- [x] #3 Campaigns store PLZ, radius, cadence, max new leads, max audits, active/paused state, and Germany-only context
- [x] #4 Each campaign has a Jetzt ausführen action and shows last run, next run, and current run status
- [x] #5 Form validation gives clear German error messages for invalid PLZ, radius, cadence, and limits
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Define campaign Zod schemas and German validation messages.
2. Build campaign list, create, edit, pause, and resume UI.
3. Add Convex mutations/queries for campaign persistence.
4. Add run metadata fields for last run, next run, and current status.
5. Verify campaign forms and dashboard state transitions.
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Started subagent-driven, test-driven implementation with Codex Spark workers. Orchestrator will enforce red-green cycles, spec review, code quality review, and final verification before requesting manual confirmation.
Implemented TASK-5 subagent-driven and test-driven. Backend/domain slice passed spec and quality review after fix loops. Frontend slice passed spec review and quality re-review after accessibility/timer fixes. Verification: pnpm test passed 40/40; pnpm exec tsc -p tsconfig.json passed; pnpm lint passed with only existing generated Convex warnings; pnpm build passed with network allowed for next/font assets. Local route check: /dashboard/campaigns returns 307 to /login without session; /login returns 200. Browser visual flow still needs authenticated manual testing before closing task as Done.
Bugfix after manual testing: campaign create dialog crashed because SelectContent was placed inside FormControl, giving FormControl multiple children and triggering React.Children.only. Fixed category and recurrence Select composition so FormControl wraps only SelectTrigger while SelectContent remains inside Select as a sibling. Verification after fix: pnpm exec tsc -p tsconfig.json passed; pnpm lint passed with only existing generated warnings; pnpm test passed 40/40; pnpm build passed.
Bugfix after manual testing: campaign create dialog emitted controlled/uncontrolled input warning because campaignFormDefaults lacked name/customSearchTerm while RHF rendered controlled inputs. Added empty string defaults and defensive customSearchTerm value fallback. Verification after fix: pnpm exec tsc -p tsconfig.json passed; pnpm test passed 40/40; pnpm lint passed with only existing generated warnings; pnpm build passed.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
TASK-5 shipped campaign configuration and scheduling controls: React Hook Form/Zod/shadcn create/edit forms, predefined categories plus Anderes custom niche, Convex campaign persistence with Germany-only context, run request/status metadata, pause/resume controls, German validation, and post-manual-test bugfixes for Select composition and controlled inputs.
<!-- SECTION:FINAL_SUMMARY:END -->