-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
343 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import express from 'express' | ||
import { | ||
getFarmersCount, | ||
getAllFarmers, | ||
} from '../../controllers/Admin/Afarmer' | ||
import { getFarmersCount, getAllFarmers } from '../../controllers/Admin/Afarmer' | ||
|
||
const router = express.Router() | ||
|
||
router.get('/', getAllFarmers) | ||
router.post('/count', getFarmersCount) | ||
|
||
export default router | ||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { Navigate, Outlet } from 'react-router-dom'; | ||
import { Navigate, Outlet } from 'react-router-dom' | ||
|
||
const StaffPrivateRoute = ({ manager }) => { // Destructure manager from props | ||
const StaffPrivateRoute = ({ manager }) => { | ||
// Destructure manager from props | ||
// Check if the user is authenticated by checking for a token in local storage | ||
const staff = localStorage.getItem('staffToken'); // Replace with your actual logic | ||
const staff = localStorage.getItem('staffToken') // Replace with your actual logic | ||
|
||
// Log the user state for debugging | ||
console.log(staff); | ||
console.log(staff) | ||
|
||
// If staff token exists and manager prop is true, redirect to /manager | ||
if (manager) { | ||
return staff ? <Outlet /> : <Navigate to="/manager" replace />; | ||
return staff ? <Outlet /> : <Navigate to="/manager" replace /> | ||
} | ||
|
||
// If staff token exists, render the Outlet, otherwise navigate to /Admin | ||
return staff ? <Outlet /> : <Navigate to="/Admin" replace />; | ||
}; | ||
return staff ? <Outlet /> : <Navigate to="/Admin" replace /> | ||
} | ||
|
||
export default StaffPrivateRoute; | ||
export default StaffPrivateRoute |
Oops, something went wrong.