-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
Description
Improve the authentication logic in the frontend by standardizing error handling and updating import paths for consistency and maintainability.
Current Behavior
- The
useAuthhook currently handles errors with a verbose and inconsistent pattern:err instanceof AxiosError ? err.message : 'body' in err && typeof err.body === 'object' && err.body ? String(err.body.detail) || ... : ...
- The
handleErrorutility inutils.tsis not reused inuseAuth, leading to duplicated error handling logic. - Import paths for shared components (e.g.,
PasswordInput) inlogin.tsxandsignup.tsxuse relative imports instead of the@alias (e.g.,import PasswordInput from '@/components/commonUI/PasswordInput'). - The
useAuthContext.tsxfile is located in thehooksfolder, but it represents a context provider and hook, which would be more appropriately placed in acontextdirectory.
Expected Behavior
- Refactor error handling in
useAuthto use a shared utility (e.g., refactor and reusehandleErrorfromutils.ts), ensuring consistent and clear error messages for authentication flows. - Update all relevant imports in
login.tsxandsignup.tsxto use the@alias for shared components, following the project's import conventions. - Move
useAuthContext.tsxfrom thehooksfolder to a new or existingcontextfolder, and update all imports accordingly. - Consolidate the
utilsfolder andutils.tsfile into a single, well-organized location to avoid confusion and duplication. All utility functions should be imported from this unified module. - Ensure that error messages are user-friendly, translated, and displayed via toast notifications or inline feedback as appropriate.
References