refactor(actions): modularize auth and website logic, add useFormAction hook - #97
Merged
Conversation
…on hook - Relocate login and logout actions into `src/modules/auth/` - Move `verifyTrackingScript` to `website.actions.ts` and rename to `verifyWebsiteTrackingScript` - Introduce a reusable `useFormAction` hook using React Hook Form and Zod - Simplify `useAction` by switching from `useTransition` to a standard async state wrapper - Clean up unused schema and centralized types under module structures
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.
📝 Description
This PR refactors the project's server actions and custom React hooks to improve code modularity, type-safety, and maintainability. It moves the codebase closer to an independent domain/module layout by breaking down global action definitions and decoupling them from legacy setups.
Key Changes:
login,logout) from global entrypoints into a dedicated@/modules/auth/directory along with a type-safeauth.schema.ts.@/modules/website/website.actions.tsunder the updated nameverifyWebsiteTrackingScript.useActionutility hook by swapping out React's experimental/nativeuseTransitionfor standarduseStateasynchronous flags, minimizing state bloat.useFormActionwrapper that integrates seamlessly with React Hook Form and Zod validation, dropping redundant state rendering inside component structures (likeuseLogIn).Fixes # (issue number)
🧪 Type of Change
🛠️ How Has This Been Tested?
Local development verification of the login flow and page transitions to
/dashboard.Manual tracking validation triggered via the
WebsiteManagerinterface using the modularized edge handler.Type integrity verified against the project build configuration.
Unit/Integration tests added/passed (existing Vitest/Supertest suites verified against module changes)
Local manual edge verification successful
📸 Screenshots / Diffs (if applicable)
File changes outline:
use-form-action.ts(New generic form validation wrapper)auth.actions.ts/auth.schema.ts(Consolidated domain logic)website.actions.ts(Unified verification pipeline script)✅ Checklist