Open nguyenhoaikhang37 opened 11 months ago
Result: ✅
How do I sign up...?
Users should not be able to access private routes without login:
The logic in RouteGuard
should probably run when pathname changes.
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.
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.
// 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