refactor: separate hooks and services across all features#4
Open
refactor: separate hooks and services across all features#4
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract Supabase calls for customers into a dedicated service module with fetchCustomers, createCustomer, updateCustomer, and fetchUserCompany. All functions covered by unit tests (7 passing). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y constraint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove manual `as { email: string }[]` cast in validateInvite — the RPC
return type is already inferred from the generated database types.
Remove `.select().single()` from deleteCompany — these caused a PGRST116
error when no row was found; a void delete needs no row returned. Also
update the test chain mock to be thenable so await works without .single().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move useCreateCompany, useUpdateCompany, useDeleteCompany into dedicated hook files; wire useCompanies, useCompany, useCreateInvite through the service layer; update component imports and test mocks accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and SignupForm Extract auth, profile, and invite logic into dedicated service modules under src/features/auth/services/. Update AuthProvider, useAuth, useProfile, and SignupForm to consume the services instead of calling supabase directly. Update AuthProvider.test.tsx to mock the service layer instead of @/lib/supabase. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nupForm - Rewrite useAuth.test.ts to mock ../services/auth instead of @/lib/supabase, aligning with the refactored hook that delegates to the service layer - Add noValidate to SignupForm <form> to prevent browser constraint validation from interfering with react-hook-form/zod validation - Replace broken vi.doMock-based third test in AuthProvider.test.tsx with a straightforward assertion that onAuthStateChange is called once on mount 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
Features refactored
Test plan
🤖 Generated with Claude Code