bsoc-bitbyte / busify

A centralised bus ticket booking system that will allow the students to book tickets in advance through an online website, saving time and effort.
https://busify.vercel.app
30 stars 67 forks source link

feat(frontend): Add UserProtected Route #54

Closed Pratik2026 closed 12 months ago

Pratik2026 commented 12 months ago

Overview

  1. This PR fixes or fixes part of #49 .
  2. This PR does the following: It adds UserProtectedRoute to a demoPage(open when user clicks on 'Pay now') which redirect the user to a homePage as well as pops a toaster if the user is not logged in otherwise opens the wrapped component .

Essential Checklist

Proof that changes are correct

ProtectedRoutes.webm

Pratik2026 commented 12 months ago

@prajjwalkapoor It seems that when the user directly access the demo page, the user gets redirected to the home page as per the default value of isAuth state which is 'false'. This is due to the time delay in getting a response from checkAuth function. One possible solution would be to introduce a loading state which keeps the loading true until the response has been received from the server and then render the component accordingly. Let me know what you think about it.

prajjwalkapoor commented 12 months ago

@prajjwalkapoor It seems that when the user directly access the demo page, the user gets redirected to the home page as per the default value of isAuth state which is 'false'. This is due to the time delay in getting a response from checkAuth function. One possible solution would be to introduce a loading state which keeps the loading true until the response has been received from the server and then render the component accordingly. Let me know what you think about it.

yeah, we can do this.