feat(customers): Task 11 — customer list and create/edit form#3
Merged
feat(customers): Task 11 — customer list and create/edit form#3
Conversation
Implements Task 11 — customer management feature for customer managers. Adds useCustomers/useCreateCustomer/useUpdateCustomer hooks, CustomerForm with zod validation and error display, CustomerList with inline edit, and wires /customers route. Also adds docs/WORKFLOW.md for the one-task-per-branch workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code review fixes: - feat(customers): disable New Customer button until companyId resolves - feat(customers): use TablesInsert/TablesUpdate in useCustomers mutations - feat(customers): remove unused CustomerFormValues from types.ts - feat(customers): add noValidate to CustomerForm (prevents browser constraint validation from blocking zodResolver in tests) RLS fixes: - fix(db): add WITH CHECK to customers_update_cm policy (migration 00010) Signup bug fix: - fix(db): normalize invite email to lowercase in create_invite (migration 00009) - fix(db): make handle_new_user trigger compare emails case-insensitively Root cause: Supabase Auth normalizes emails to lowercase in auth.users but invites stored the email exactly as typed by the admin (e.g. testCM0@test.com vs testcm0@test.com), causing the trigger lookup to fail every time. Tests: - test(customers): add useCustomers.test.tsx (hooks — fetch, create, update, error) - test(customers): add CustomerForm.test.tsx (validation, submit, cancel, edit mode) - test(customers): add CustomerList.test.tsx (loading/error/empty/populated states, button guard, form toggle) - test(customers): add tests/e2e/customers.spec.ts (full CM CRUD flow + access control) Docs: - docs: add required-tests-per-feature table to CLAUDE.md testing section - docs: add userEvent.setup() and noValidate conventions to CLAUDE.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Added rule to CLAUDE.md: always run npx supabase db reset immediately after writing a new migration, without waiting for the user to ask - Applied migrations 00009 and 00010 to local Supabase (db reset done) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useCustomers,useCreateCustomer,useUpdateCustomerhooks insrc/features/customers/hooks/useCustomers.tsCustomerFormwith zod validation, error display, and try/catch aroundmutateAsyncCustomerListwith inline create/edit, loading and error states/customersroute (scoped tocustomer_managerrole viaRoleGuard)docs/WORKFLOW.mddocumenting the one-task-per-branch PR workflowDeviations from plan
import { z } from "zod/v4"→import { z } from "zod"(per CLAUDE.md convention)z.email()→z.string().email()(zod v3 API)mutateAsynccalls (per CLAUDE.md error handling rules)isError/errorrender state toCustomerListqueryFnthrows whenuseris null instead of returningnullTest plan
/customersroute is accessibleRoleGuard🤖 Generated with Claude Code