PHP Classes

File: client/src/features/components/Routes/UserRoute.tsx

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Wallet API and Application   client/src/features/components/Routes/UserRoute.tsx   Download  
File: client/src/features/components/Routes/UserRoute.tsx
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Wallet API and Application
Application to manage a wallet by calling an API
Author: By
Last change:
Date: 2 years ago
Size: 507 bytes
 

Contents

Class file image Download
import { Navigate, useLocation } from 'react-router-dom'; import {useStore} from "../../../app/stores/store"; const UserRoute = ({ children }: { children: JSX.Element }) => { let location = useLocation(); const{userStore} = useStore() if (!userStore.isLoggedin) { return <Navigate to="/" state={{ from: location }} />; } else if (userStore.isAdmin) { return <Navigate to="/dashboard" state={{ from: location }} />; } return children; }; export default UserRoute;