role add dashboard , permision in navigation , user login
parent
9cff169537
commit
0081650ba6
12
.env
12
.env
|
@ -1,15 +1,15 @@
|
|||
NODE_ENV="development"
|
||||
|
||||
# NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769
|
||||
# NEXT_PUBLIC_PUBLIC_URL=http://192.168.88.12:32769
|
||||
# NEXT_PUBLIC_API_URL=http://192.168.88.12:32769/api
|
||||
NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769
|
||||
NEXT_PUBLIC_PUBLIC_URL=http://192.168.88.12:32769
|
||||
NEXT_PUBLIC_API_URL=http://192.168.88.12:32769/api
|
||||
# SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99
|
||||
# NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages
|
||||
# NEXT_PUBLIC_API_URL_BackUp=https://192.168.88.12:49154/Files/BackUps
|
||||
|
||||
NEXT_PUBLIC_SERVER_URL=https://j3884z97-32769.euw.devtunnels.ms
|
||||
NEXT_PUBLIC_PUBLIC_URL=https://j3884z97-32769.euw.devtunnels.ms
|
||||
NEXT_PUBLIC_API_URL=https://j3884z97-32769.euw.devtunnels.ms/api
|
||||
# NEXT_PUBLIC_SERVER_URL=https://j3884z97-32769.euw.devtunnels.ms
|
||||
# NEXT_PUBLIC_PUBLIC_URL=https://j3884z97-32769.euw.devtunnels.ms
|
||||
# NEXT_PUBLIC_API_URL=https://j3884z97-32769.euw.devtunnels.ms/api
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,10 +6,12 @@ import { usePathname } from "next/navigation";
|
|||
import Image from "next/image";
|
||||
import logo from "@img/logo.png";
|
||||
import AppContext from "@ctx/AppContext";
|
||||
import { HasPermission } from "plugins/HasPermission/page";
|
||||
|
||||
const NavBAr = (props) => {
|
||||
const usePath = usePathname();
|
||||
const CTX = useContext(AppContext);
|
||||
const permissions = CTX.state.profile?.permissions;
|
||||
|
||||
const openBigPlus = () => {
|
||||
setTimeout(() => {
|
||||
|
@ -24,6 +26,7 @@ const NavBAr = (props) => {
|
|||
<Image src={divide} alt="" className=" " />
|
||||
</div> */}
|
||||
<div className="bg-white shadow px-4 py-5 flex rounded-t-[30px] ">
|
||||
{HasPermission("ViewDashboard") && (
|
||||
<Link href={"/home"} className="w-full !no-underline mr-5">
|
||||
<>
|
||||
{usePath.includes("/home") ? (
|
||||
|
@ -65,7 +68,8 @@ const NavBAr = (props) => {
|
|||
)}
|
||||
</>
|
||||
</Link>
|
||||
|
||||
)}
|
||||
{HasPermission("ViewShiftPlans") && (
|
||||
<Link href={"/shifts"} className="w-full !no-underline mr-10">
|
||||
<>
|
||||
{usePath.includes("/shifts") ? (
|
||||
|
@ -121,6 +125,8 @@ const NavBAr = (props) => {
|
|||
)}
|
||||
</>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<div
|
||||
className="flex justify-center "
|
||||
onClick={() => {
|
||||
|
@ -144,6 +150,7 @@ const NavBAr = (props) => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{HasPermission("ViewComplexSettings") && (
|
||||
<Link href={"/employees"} className="w-full !no-underline ml-10">
|
||||
<>
|
||||
{usePath.includes("/employees") ? (
|
||||
|
@ -179,7 +186,9 @@ const NavBAr = (props) => {
|
|||
)}
|
||||
</>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{HasPermission("ViewActivities") && (
|
||||
<Link href={"/tasks"} className="w-full !no-underline ml-5">
|
||||
<>
|
||||
{usePath.includes("/tasks") ? (
|
||||
|
@ -197,6 +206,7 @@ const NavBAr = (props) => {
|
|||
)}
|
||||
</>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "brizco",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import AppContext from "@ctx/AppContext";
|
||||
import React, { useContext } from "react";
|
||||
|
||||
export const HasPermission = (permission) => {
|
||||
const CTX = useContext(AppContext);
|
||||
const permissions = CTX.state.profile?.permissions;
|
||||
return permissions?.includes(permission);
|
||||
};
|
|
@ -13,6 +13,7 @@ import React, { useContext, useEffect } from "react";
|
|||
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
|
||||
import { Doughnut, Pie } from "react-chartjs-2";
|
||||
import BottomSheetChangeRole from "plugins/BottomSheet/BottomSheetChangeRole";
|
||||
import { HasPermission } from "plugins/HasPermission/page";
|
||||
|
||||
ChartJS.register(ArcElement, Tooltip, Legend);
|
||||
|
||||
|
@ -63,7 +64,15 @@ const Home = (props) => {
|
|||
}
|
||||
}, []);
|
||||
|
||||
console.log(profile);
|
||||
// useEffect(() => {
|
||||
// if (!HasPermission("ViewDashboard")) {
|
||||
// // You can customize the redirect path as needed
|
||||
// router.replace("/activity");
|
||||
// return null; // Prevent rendering the rest of the component
|
||||
|
||||
// console.log(HasPermission("ViewDashboard"));
|
||||
// }
|
||||
// }, [profile]);
|
||||
|
||||
return (
|
||||
<div className="pb-20">
|
||||
|
|
|
@ -179,7 +179,7 @@ export default function RootLayout({ children }) {
|
|||
|
||||
if (data.user.signUpStatus == 1) {
|
||||
setStepLogin(2);
|
||||
} else if (data.user.signUpStatus == 2) {
|
||||
} else if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
|
||||
setProfile(data);
|
||||
toast.success(` ${data.user.firstName} جان خوش اومدی `, {
|
||||
position: "bottom-right",
|
||||
|
|
Loading…
Reference in New Issue