11import React , { lazy , Suspense } from "react"
22import { Loader2 } from "lucide-react"
3- import { useNavigate } from "react-router-dom"
3+ import { Navigate , useLocation } from "react-router-dom"
44import { useIsMobile } from "./hooks/use-mobile"
5- import { useLocation } from "react-router-dom"
65import { useSidebar } from "./components/ui/sidebar"
76import Navbar from "./components/Navbar"
87import { AppSidebar } from "./components/AppSidebar"
@@ -36,6 +35,7 @@ const Chat = lazy(() => import("./components/Chat/Chat"))
3635const Home = lazy ( ( ) => import ( "./components/LandingPage/Home" ) )
3736const PrivacyPolicy = lazy ( ( ) => import ( "./components/LandingPage/PrivacyPolicy" ) )
3837const TermsOfService = lazy ( ( ) => import ( "./components/LandingPage/TermOfService" ) )
38+ const RefundPolicy = lazy ( ( ) => import ( "./components/LandingPage/RefundPolicy" ) )
3939const NotFoundPage = lazy ( ( ) => import ( "./components/NotFound" ) )
4040const Dashboard = lazy ( ( ) => import ( "./components/Posts/Dashboard" ) )
4141const PostDetail = lazy ( ( ) => import ( "./components/Posts/PostDetail" ) )
@@ -82,7 +82,6 @@ export const privateRoutes = [
8282 { path : "/music/my-playlist/:id" , element : < UserPlaylistDetails /> } ,
8383 { path : "/music/history" , element : < HistoryPage /> } ,
8484 { path : "/music/sync" , element : < GroupMusic /> } ,
85- { path : "/plans" , element : < PlansPage /> } ,
8685 { path : "/payments/history" , element : < PaymentHistoryPage /> } ,
8786]
8887
@@ -94,12 +93,13 @@ export const publicRoutes = [
9493 { path : "/passkey-login" , element : < PasskeyLogin /> } ,
9594 { path : "/privacy-policy" , element : < PrivacyPolicy /> } ,
9695 { path : "/terms-of-services" , element : < TermsOfService /> } ,
96+ { path : "/refund-policy" , element : < RefundPolicy /> } ,
97+ { path : "/plans" , element : < PlansPage /> } ,
9798 { path : "*" , element : < NotFoundPage /> } ,
9899]
99100
100101// Protected Routes Component
101102export const ProtectedRoutes = ( ) => {
102- const navigate = useNavigate ( )
103103 const { user, loading } = useContext ( Context )
104104 const { open } = useSidebar ( )
105105 const isMobile = useIsMobile ( )
@@ -111,12 +111,11 @@ export const ProtectedRoutes = () => {
111111 }
112112
113113 if ( ! user ?. email ) {
114- return navigate ( `/login?returnTo=${ location . pathname } ` )
114+ return < Navigate to = { `/login?returnTo=${ location . pathname } ` } replace />
115115 }
116116
117117 if ( ! user ?. verified ) {
118- toast . error ( "Please verify your email first" )
119- return navigate ( "/verify" , { state : { email : user ?. email } } )
118+ return < Navigate to = "/verify" state = { { email : user ?. email } } replace />
120119 }
121120
122121 return (
0 commit comments