nguyenhoaikhang37 / df-frontend-2023

0 stars 0 forks source link

Submission for assignment 6 #6

Open nguyenhoaikhang37 opened 11 months ago

nguyenhoaikhang37 commented 11 months ago

// Demo link https://df-frontend-2023-ass6.vercel.app/

// Any notes for reviewers If the code lacks clarify or if there are any issue with the application, please don't hesitate to provide feedback. I'm open to suggestions and eager to improve. Thanks a lot <3

ngolapnguyen commented 11 months ago

Requirements

Result: ✅

Feedbacks

  1. How do I sign up...?

  2. Users should not be able to access private routes without login:

image

The logic in RouteGuard should probably run when pathname changes.

  1. Centralizing utils & hooks in one place is fine, but you should consider the scope of the logic & decide whether a method (e.g. getInitialColorMode) should be put in the centralized place (e.g. src/utils/functions/*) or a local place (e.g. src/components/dark-mode-toggle/utils/*).

If the utility method is only used with a particular component and not reused anywhere else, it should probably stay local in the same place as the component. It'll help when your project grows bigger & you need to read into a flow.

If you still want to keep it centralized, I'd suggest breaking down the files in src/utils/functions to be smaller & feature/entity-based. E.g. src/utils/functions/theme.ts, src/utils/functions/pagination.ts).

Either way, there's no absolute answer to this. The important thing is to keep them consistent & sensible for you & your team.

  1. I think the way you are building useAuthSWR, useBookSWR, etc. will be very hard to scale. Pausing & firing requests conditionally based on props is a very clunky way to manage... My recommendation would be just calling useSWR directly where you need it.

You can also write a wrapper for it (e.g. useSWRWithCustomErrorHandlingAndStuff) if you want to have some default error handling (toasting, logging, etc.), or put the toast in the axios-client level.

  1. ...