change role permision

main
حسین معصومی پور 2023-12-12 14:51:25 +03:30
parent 0081650ba6
commit 1258eab3d2
30 changed files with 1092 additions and 292 deletions

View File

@ -14,9 +14,11 @@ const AppHeader = ({
iconName2,
iconHref2,
iconEvent2,
iconName3,
iconEvent3,
userIcon,
userIconData,
userIconHref,
userRole,
}) => {
const icons = [
@ -96,30 +98,30 @@ const AppHeader = ({
},
];
// console.log("title", title);
// console.log("sub", sub);
// ;
return (
<div className=" bg-primary-300 flex justify-between rtl pt-4 px-4 pb-[50px] w-full">
<div className="flex">
{userIcon && (
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px]">
<div className=" rounded-full z-10 ">
<Avatar
size={40}
name={userIconData}
variant="beam"
colors={["#9d9f88", "#83af96", "#b2de93"]}
/>
<Link href={"/acount"}>
<div className="flex">
{userIcon && (
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px]">
<div className=" rounded-full z-10 ">
<Avatar
size={40}
name={userIconData}
variant="beam"
colors={["#9d9f88", "#83af96", "#b2de93"]}
/>
</div>
</div>
)}
<div className="mr-2 mt-1">
<h2 className="mb-0 text-white font-bold text-base">{title}</h2>
<p className="mb-0 text-white text-sm">{sub}</p>
</div>
)}
<div className="mr-2 mt-1">
<h2 className="mb-0 text-white font-bold text-base">{title}</h2>
<p className="mb-0 text-white text-sm">{sub}</p>
</div>
</div>
</Link>
{!userRole ? (
<div className="flex mt-2">
{icon1 ? (
@ -153,7 +155,7 @@ const AppHeader = ({
className="w-fit h-fit bg-white rounded-full mx-1 "
onClick={iconEvent3}
>
<p className="mb-0 p-2 px-4">{userRole && userRole[0]?.roleName}</p>
<p className="mb-0 p-2 px-4">{iconName3}</p>
</div>
)}
</div>

View File

@ -1,16 +1,18 @@
"use client";
import Link from "next/link";
import React, { useContext } from "react";
import React, { useContext, useEffect, useState } from "react";
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";
import HasPermission from "plugins/HasPermission/page";
const NavBAr = (props) => {
const usePath = usePathname();
const CTX = useContext(AppContext);
const [profileFill, setProfileFill] = useState(false);
const permissions = CTX.state.profile?.permissions;
const openBigPlus = () => {
@ -20,13 +22,23 @@ const NavBAr = (props) => {
CTX.setBigPlusOpen(true);
};
useEffect(() => {
setTimeout(() => {
setProfileFill(true);
}, 300);
}, [permissions]);
return (
<div className="fixed w-full z-[110] bottom-0 ">
<div
className={`fixed w-full z-[110] tr03 ${
profileFill ? "bottom-0" : "bottom-[-300px]"
} `}
>
{/* <div className="w-[100px] text-left overflow-hidden">
<Image src={divide} alt="" className=" " />
</div> */}
<div className="bg-white shadow px-4 py-5 flex rounded-t-[30px] ">
{HasPermission("ViewDashboard") && (
{HasPermission("ViewDashboard", permissions) && (
<Link href={"/home"} className="w-full !no-underline mr-5">
<>
{usePath.includes("/home") ? (
@ -69,7 +81,7 @@ const NavBAr = (props) => {
</>
</Link>
)}
{HasPermission("ViewShiftPlans") && (
{HasPermission("ViewShiftPlans", permissions) && (
<Link href={"/shifts"} className="w-full !no-underline mr-10">
<>
{usePath.includes("/shifts") ? (
@ -150,7 +162,7 @@ const NavBAr = (props) => {
</div>
</div>
{HasPermission("ViewComplexSettings") && (
{HasPermission("ViewComplexSettings", permissions) && (
<Link href={"/employees"} className="w-full !no-underline ml-10">
<>
{usePath.includes("/employees") ? (
@ -188,7 +200,7 @@ const NavBAr = (props) => {
</Link>
)}
{HasPermission("ViewActivities") && (
{HasPermission("ViewActivities", permissions) && (
<Link href={"/tasks"} className="w-full !no-underline ml-5">
<>
{usePath.includes("/tasks") ? (

View File

@ -1,10 +1,31 @@
"use client";
import AppContext from "@ctx/AppContext";
import Avatar from "boring-avatars";
import Buttonbriz from "plugins/Buttonbriz/page";
import Input from "plugins/Input/page";
import React, { useState } from "react";
import React, { useContext, useRef, useState } from "react";
import SimpleReactValidator from "simple-react-validator";
const ActivityCard = ({ data }) => {
const CTX = useContext(AppContext);
const ActivityCard = () => {
const [conditionTask, setConditionTask] = useState(0);
const [undoneResone, setUndoneResone] = useState("");
const validator = useRef(
new SimpleReactValidator({
messages: {
required: "پر کردن این فیلد الزامی میباشد",
},
element: (message) => (
<>
<div className="text-right px-1 ">
<small className="text-red-600 t-ig-small ">{message}</small>
</div>
</>
),
})
);
const handleConditionTaskCircle = () => {
if (conditionTask == 3 || conditionTask == 4) {
@ -14,10 +35,26 @@ const ActivityCard = () => {
}
};
const handleUndoneResone = () => {
setConditionTask(4);
CTX.UnDoneActivity(data.id, undoneResone);
};
const handleDone = () => {
setConditionTask(3);
CTX.DoneActivity(data.id);
};
return (
<div
className={`bg-white shadow-sm rounded-xl p-4 mt-4 overflow-hidden ${
conditionTask == 3 || conditionTask == 4 ? "fuck-click opacity-60" : ""
className={`shadow-sm rounded-3xl p-2 mt-4 overflow-hidden ${
conditionTask == 3 ||
conditionTask == 4 ||
data?.status == 4 ||
data?.status == 2 ||
data?.status == 3
? "fuck-click "
: "bg-white "
}`}
>
<div className="flex">
@ -25,15 +62,15 @@ const ActivityCard = () => {
className={`w-[60px] h-[50px] border-2 rounded-full ml-3 tr03 ${
conditionTask == 1
? "animate-spin-slow duration-700 border-gray-700 border-dashed"
: conditionTask == 2 || conditionTask == 4
: conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "border-red-600"
: conditionTask == 3
: conditionTask == 3 || data?.status == 2 || data?.status == 3
? "border-primary-200"
: "border-gray-700 border-dashed"
}`}
onClick={() => handleConditionTaskCircle()}
>
{conditionTask == 2 || conditionTask == 4 ? (
{conditionTask == 2 || conditionTask == 4 || data?.status == 4 ? (
<svg
width="20"
height="20"
@ -47,7 +84,7 @@ const ActivityCard = () => {
fill="red"
/>
</svg>
) : conditionTask == 3 ? (
) : conditionTask == 3 || data?.status == 2 || data?.status == 3 ? (
<svg
width="37"
height="37"
@ -75,19 +112,21 @@ const ActivityCard = () => {
<div className="w-full">
<h3
className={`text-base font-bold tr03 ${
conditionTask == 2 || conditionTask == 4
conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "text-red-600"
: "text-primary-300"
} `}
>
پاک کردن شیشه های روبرویی رستوران
{data?.title}{" "}
</h3>
<p
className={`mb-0 text-[12px] tr03 ${
conditionTask == 2 || conditionTask == 4 ? "text-red-600" : ""
conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "text-red-600"
: ""
}`}
>
لطفا دو شیشه روبرو رستوران را با دقت تمیز کنید و جارو بکشید
{data?.description}{" "}
</p>
</div>
</div>
@ -98,11 +137,35 @@ const ActivityCard = () => {
: " relative top-0 h-fit "
}`}
>
<div className="bg-secondaryLighter-100 w-fit relative px-2 text-[12px] my-2 mx-1 rounded-3xl text-secondary-200">
اهمیت بالا{" "}
<div className="bg-secondaryLighter-100 w-fit relative p-2 text-[12px] my-2 mx-1 rounded-3xl text-secondary-200">
{data?.scheduleType == 0
? "روزانه"
: data?.scheduleType == 1
? "هفتگی"
: data?.scheduleType == 2
? "مخصوص"
: ""}
</div>
<div className="bg-secondaryLighter-100 w-fit relative px-2 text-[12px] my-2 mx-1 rounded-3xl text-secondary-200">
شیفت صبح
<div className="bg-secondaryLighter-100 w-fit relative p-2 text-[12px] my-2 mx-1 rounded-3xl text-secondary-200">
{data?.shiftTitle}{" "}
</div>
<div className="flex bg-gray-100 p-1 rounded-full m-1 justify-start h-fit mt-2">
<div
className="w-[26px] h-[26px] rounded-full bg-gray-400 "
// onClick={() => deleteSearchUser(e)}
>
<Avatar
size={26}
name={data?.userFullName}
variant="beam"
colors={["#9d9f88", "#83af96", "#b2de93"]}
/>
</div>
<div>
<p className="mb-0 px-3 text-sm mt-1">{data?.userFirstName}</p>
</div>
</div>
</div>
@ -138,7 +201,7 @@ const ActivityCard = () => {
{" "}
<div
className="w-[50px] h-[50px] rounded-full bg-primary-200 pt-1 mx-2"
onClick={() => setConditionTask(3)}
onClick={() => handleDone()}
>
<svg
width="37"
@ -190,20 +253,34 @@ const ActivityCard = () => {
: " relative h-0 overflow-hidden "
}`}
>
<Input
lable="چرا انجام نشد ؟؟؟ "
id="birthDate-id"
name="birthDate"
type={"text"}
textarea={true}
theme={1}
/>
<div className="">
<Input
lable="چرا انجام نشد ؟؟؟ "
id="undoneResone-id"
name="undoneResone"
type={"text"}
value={undoneResone}
inputEvent={(e) => {
setUndoneResone(e.target.value);
validator.current.showMessageFor("undoneResone");
}}
style="text-right"
validator={true}
validatorData={validator.current.message(
"undoneResone",
undoneResone,
"required"
)}
textarea={true}
theme={1}
/>
</div>
<Buttonbriz
title="ثبت فعالیت"
color="INFO"
icon="CHECK"
buttonEvent={() => setConditionTask(4)}
buttonEvent={() => handleUndoneResone()}
/>
</div>
</div>

View File

@ -0,0 +1,314 @@
"use client";
import AppContext from "@ctx/AppContext";
import Avatar from "boring-avatars";
import Buttonbriz from "plugins/Buttonbriz/page";
import Input from "plugins/Input/page";
import React, { useContext, useRef, useState } from "react";
import SimpleReactValidator from "simple-react-validator";
const ActivityCardCloseShift = ({ data }) => {
const CTX = useContext(AppContext);
const completeActivities = CTX.state.completeActivities;
const [conditionTask, setConditionTask] = useState(0);
const [undoneResone, setUndoneResone] = useState("");
const validator = useRef(
new SimpleReactValidator({
messages: {
required: "پر کردن این فیلد الزامی میباشد",
},
element: (message) => (
<>
<div className="text-right px-1 ">
<small className="text-red-600 t-ig-small ">{message}</small>
</div>
</>
),
})
);
const handleConditionTaskCircle = () => {
if (conditionTask == 3 || conditionTask == 4) {
return;
} else {
setConditionTask(1);
}
};
const handleUndoneResone = (id) => {
setConditionTask(0);
CTX.setCompleteActivities(
completeActivities?.map((e) => {
// Check if the activityId matches the one you want to update
if (e?.activityId == id) {
// Update the isCompleted property
return {
...e,
isCompleted: false,
performanceDescription: undoneResone,
}; // You can change the condition here
} else {
return e;
}
})
);
};
const handleDone = (id) => {
setConditionTask(0);
CTX.setCompleteActivities(
completeActivities?.map((e) => {
// Check if the activityId matches the one you want to update
if (e?.activityId == id) {
// Update the isCompleted property
return { ...e, isCompleted: true }; // You can change the condition here
} else {
return e;
}
})
);
};
return (
<div
className={`shadow-sm rounded-3xl p-3 mt-4 overflow-hidden tr03 ${
conditionTask == 3 ||
conditionTask == 4 ||
data?.status == 4 ||
data?.status == 2 ||
data?.status == 3
? "fuck-click bg-white "
: "bg-white "
} ${
completeActivities?.find((e) => e.activityId == data?.id)
?.isCompleted != data?.isDone
? "!bg-yellow-100"
: ""
}`}
onClick={() => {
console.log(
"completeActivities?.find((e) => e.activityId == data?.id)?.isCompleted",
completeActivities?.find((e) => e.activityId == data?.id)
?.isCompleted != data?.isDone
);
}}
>
<div className="flex">
<div
className={`w-[60px] h-[50px] border-2 rounded-full ml-3 tr03 ${
conditionTask == 1
? "animate-spin-slow duration-700 border-gray-700 border-dashed"
: conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "border-red-600"
: conditionTask == 3 || data?.status == 2 || data?.status == 3
? "border-primary-200"
: "border-gray-700 border-dashed"
}`}
onClick={() => handleConditionTaskCircle()}
>
{conditionTask == 2 || conditionTask == 4 || data?.status == 4 ? (
<svg
width="20"
height="20"
viewBox="0 0 167 168"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-3 "
>
<path
d="M95.7504 84.0002L164.834 14.9169C166.199 13.3227 166.912 11.2721 166.831 9.1748C166.75 7.0775 165.881 5.08801 164.397 3.60389C162.913 2.11976 160.923 1.25032 158.826 1.16931C156.729 1.0883 154.678 1.80169 153.084 3.16691L84.0004 72.2502L14.9171 3.08358C13.3479 1.51438 11.2196 0.632812 9.00043 0.632812C6.78125 0.632812 4.65296 1.51438 3.08376 3.08358C1.51456 4.65277 0.632996 6.78106 0.632996 9.00024C0.632996 11.2194 1.51456 13.3477 3.08376 14.9169L72.2504 84.0002L3.08376 153.084C2.21141 153.831 1.50291 154.75 1.00272 155.784C0.502522 156.818 0.221437 157.944 0.177108 159.091C0.132779 160.239 0.326158 161.384 0.745113 162.453C1.16407 163.522 1.79955 164.494 2.61168 165.306C3.4238 166.118 4.39503 166.753 5.4644 167.172C6.53378 167.591 7.67821 167.785 8.82587 167.74C9.97353 167.696 11.0996 167.415 12.1335 166.915C13.1674 166.414 14.0867 165.706 14.8338 164.834L84.0004 95.7502L153.084 164.834C154.678 166.199 156.729 166.912 158.826 166.831C160.923 166.75 162.913 165.881 164.397 164.397C165.881 162.912 166.75 160.923 166.831 158.826C166.912 156.728 166.199 154.678 164.834 153.084L95.7504 84.0002Z"
fill="red"
/>
</svg>
) : conditionTask == 3 || data?.status == 2 || data?.status == 3 ? (
<svg
width="37"
height="37"
viewBox="0 0 300 300"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-1 "
>
<path
d="M57.062 155.087C56.2612 154.132 55.2777 153.345 54.1692 152.774C53.0607 152.203 51.8494 151.859 50.6062 151.762C49.363 151.665 48.113 151.817 46.9292 152.209C45.7455 152.6 44.6518 153.225 43.7122 154.044C42.7727 154.864 42.0061 155.863 41.4574 156.983C40.9087 158.103 40.5889 159.321 40.5167 160.566C40.4445 161.811 40.6214 163.057 41.037 164.233C41.4526 165.409 42.0985 166.49 42.937 167.412L57.062 155.087ZM89.287 206.25L82.2245 212.412C83.1045 213.421 84.19 214.228 85.4082 214.782C86.6264 215.336 87.949 215.622 89.287 215.622C90.6251 215.622 91.9477 215.336 93.1658 214.782C94.384 214.228 95.4696 213.421 96.3495 212.412L89.287 206.25ZM194.562 99.9125C195.401 98.9896 196.046 97.9086 196.462 96.7329C196.878 95.5573 197.055 94.3105 196.982 93.0657C196.91 91.8208 196.59 90.6028 196.042 89.4831C195.493 88.3633 194.726 87.3643 193.787 86.5445C192.847 85.7247 191.754 85.1005 190.57 84.7086C189.386 84.3166 188.136 84.1648 186.893 84.2619C185.65 84.359 184.438 84.7032 183.33 85.2742C182.221 85.8452 181.238 86.6317 180.437 87.5875L194.562 99.9125ZM131.325 143.837C129.749 145.718 128.973 148.142 129.164 150.589C129.355 153.035 130.498 155.309 132.347 156.922C134.196 158.536 136.604 159.36 139.053 159.218C141.503 159.076 143.799 157.979 145.45 156.162L131.325 143.837ZM120.9 184.287C121.738 183.365 122.384 182.284 122.8 181.108C123.215 179.932 123.392 178.686 123.32 177.441C123.248 176.196 122.928 174.978 122.379 173.858C121.83 172.738 121.064 171.739 120.124 170.919C119.185 170.1 118.091 169.475 116.907 169.084C115.724 168.692 114.474 168.54 113.23 168.637C111.987 168.734 110.776 169.078 109.667 169.649C108.559 170.22 107.575 171.007 106.775 171.962L120.9 184.287ZM42.937 167.412L82.2245 212.412L96.3495 200.087L57.062 155.087L42.937 167.412ZM96.3495 212.412L120.9 184.287L106.775 171.962L82.2245 200.087L96.3495 212.412ZM145.45 156.162L170.012 128.037L155.887 115.712L131.325 143.837L145.45 156.162ZM170.012 128.037L194.562 99.9125L180.437 87.5875L155.887 115.712L170.012 128.037Z"
fill="green"
/>
<path
d="M250 94.5371L196.425 150.787M137.5 200L142.862 207.037L169.65 178.912"
stroke="green"
stroke-width="18.75"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
) : (
""
)}
</div>
<div className="w-full">
<h3
className={`text-base font-bold tr03 ${
conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "text-red-600"
: "text-primary-300"
} `}
>
{data?.title}{" "}
</h3>
<p
className={`mb-0 text-[12px] tr03 ${
conditionTask == 2 || conditionTask == 4 || data?.status == 4
? "text-red-600"
: ""
}`}
>
{data?.description}{" "}
</p>
</div>
</div>
<div
className={`flex mx-2 mt-3 tr03 ${
conditionTask == 1 || conditionTask == 2
? "relative top-[300px] h-0"
: " relative top-0 h-fit "
}`}
>
<div className="bg-secondaryLighter-100 w-fit relative text-[12px] my-2 mx-1 px-2 rounded-3xl text-secondary-200">
{data?.scheduleType == 0
? "روزانه"
: data?.scheduleType == 1
? "هفتگی"
: data?.scheduleType == 2
? "مخصوص"
: ""}
</div>
<div className="bg-secondaryLighter-100 w-fit relative text-[12px] my-2 mx-1 px-2 rounded-3xl text-secondary-200">
{data?.shiftTitle}{" "}
</div>
<div className="bg-secondaryLighter-100 w-fit relative text-[12px] my-2 mx-1 px-2 rounded-3xl text-secondary-200">
{data?.userFirstName}
</div>
</div>
<div
className={`flex justify-between rtl mt-3 tr03 ${
conditionTask == 1
? "relative top-0 h-fit "
: " relative top-[300px] h-0 "
}`}
>
<div
className="w-[50px] h-[50px] rounded-full bg-sky-600 pt-4"
onClick={() => setConditionTask(0)}
>
<svg
width="18"
height="18"
viewBox="0 0 150 88"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto"
>
<path
d="M137.5 75L75 12.5L12.5 75"
stroke="white"
stroke-width="25"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
<div className="flex ">
{" "}
<div
className="w-[50px] h-[50px] rounded-full bg-primary-200 pt-1 mx-2"
onClick={() => handleDone(data?.id)}
>
<svg
width="37"
height="37"
viewBox="0 0 300 300"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto "
>
<path
d="M57.062 155.087C56.2612 154.132 55.2777 153.345 54.1692 152.774C53.0607 152.203 51.8494 151.859 50.6062 151.762C49.363 151.665 48.113 151.817 46.9292 152.209C45.7455 152.6 44.6518 153.225 43.7122 154.044C42.7727 154.864 42.0061 155.863 41.4574 156.983C40.9087 158.103 40.5889 159.321 40.5167 160.566C40.4445 161.811 40.6214 163.057 41.037 164.233C41.4526 165.409 42.0985 166.49 42.937 167.412L57.062 155.087ZM89.287 206.25L82.2245 212.412C83.1045 213.421 84.19 214.228 85.4082 214.782C86.6264 215.336 87.949 215.622 89.287 215.622C90.6251 215.622 91.9477 215.336 93.1658 214.782C94.384 214.228 95.4696 213.421 96.3495 212.412L89.287 206.25ZM194.562 99.9125C195.401 98.9896 196.046 97.9086 196.462 96.7329C196.878 95.5573 197.055 94.3105 196.982 93.0657C196.91 91.8208 196.59 90.6028 196.042 89.4831C195.493 88.3633 194.726 87.3643 193.787 86.5445C192.847 85.7247 191.754 85.1005 190.57 84.7086C189.386 84.3166 188.136 84.1648 186.893 84.2619C185.65 84.359 184.438 84.7032 183.33 85.2742C182.221 85.8452 181.238 86.6317 180.437 87.5875L194.562 99.9125ZM131.325 143.837C129.749 145.718 128.973 148.142 129.164 150.589C129.355 153.035 130.498 155.309 132.347 156.922C134.196 158.536 136.604 159.36 139.053 159.218C141.503 159.076 143.799 157.979 145.45 156.162L131.325 143.837ZM120.9 184.287C121.738 183.365 122.384 182.284 122.8 181.108C123.215 179.932 123.392 178.686 123.32 177.441C123.248 176.196 122.928 174.978 122.379 173.858C121.83 172.738 121.064 171.739 120.124 170.919C119.185 170.1 118.091 169.475 116.907 169.084C115.724 168.692 114.474 168.54 113.23 168.637C111.987 168.734 110.776 169.078 109.667 169.649C108.559 170.22 107.575 171.007 106.775 171.962L120.9 184.287ZM42.937 167.412L82.2245 212.412L96.3495 200.087L57.062 155.087L42.937 167.412ZM96.3495 212.412L120.9 184.287L106.775 171.962L82.2245 200.087L96.3495 212.412ZM145.45 156.162L170.012 128.037L155.887 115.712L131.325 143.837L145.45 156.162ZM170.012 128.037L194.562 99.9125L180.437 87.5875L155.887 115.712L170.012 128.037Z"
fill="#ffffff"
/>
<path
d="M250 94.5371L196.425 150.787M137.5 200L142.862 207.037L169.65 178.912"
stroke="#ffffff"
stroke-width="18.75"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
<div
className="w-[50px] h-[50px] rounded-full bg-red-600 pt-4"
onClick={() => setConditionTask(2)}
>
<svg
width="15"
height="15"
viewBox="0 0 167 168"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto "
>
<path
d="M95.7504 84.0002L164.834 14.9169C166.199 13.3227 166.912 11.2721 166.831 9.1748C166.75 7.0775 165.881 5.08801 164.397 3.60389C162.913 2.11976 160.923 1.25032 158.826 1.16931C156.729 1.0883 154.678 1.80169 153.084 3.16691L84.0004 72.2502L14.9171 3.08358C13.3479 1.51438 11.2196 0.632812 9.00043 0.632812C6.78125 0.632812 4.65296 1.51438 3.08376 3.08358C1.51456 4.65277 0.632996 6.78106 0.632996 9.00024C0.632996 11.2194 1.51456 13.3477 3.08376 14.9169L72.2504 84.0002L3.08376 153.084C2.21141 153.831 1.50291 154.75 1.00272 155.784C0.502522 156.818 0.221437 157.944 0.177108 159.091C0.132779 160.239 0.326158 161.384 0.745113 162.453C1.16407 163.522 1.79955 164.494 2.61168 165.306C3.4238 166.118 4.39503 166.753 5.4644 167.172C6.53378 167.591 7.67821 167.785 8.82587 167.74C9.97353 167.696 11.0996 167.415 12.1335 166.915C13.1674 166.414 14.0867 165.706 14.8338 164.834L84.0004 95.7502L153.084 164.834C154.678 166.199 156.729 166.912 158.826 166.831C160.923 166.75 162.913 165.881 164.397 164.397C165.881 162.912 166.75 160.923 166.831 158.826C166.912 156.728 166.199 154.678 164.834 153.084L95.7504 84.0002Z"
fill="white"
/>
</svg>
</div>
</div>
</div>
<div className={``}>
<div
className={`tr03 ${
conditionTask == 2
? "relative h-fit "
: " relative h-0 overflow-hidden "
}`}
>
<div className="">
<Input
lable="چرا انجام نشد ؟؟؟ "
id="undoneResone-id"
name="undoneResone"
type={"text"}
value={undoneResone}
inputEvent={(e) => {
setUndoneResone(e.target.value);
validator.current.showMessageFor("undoneResone");
}}
style="text-right"
validator={true}
validatorData={validator.current.message(
"undoneResone",
undoneResone,
"required"
)}
textarea={true}
theme={1}
/>
</div>
<Buttonbriz
title="ثبت فعالیت"
color="INFO"
icon="CHECK"
buttonEvent={() => handleUndoneResone(data?.id)}
/>
</div>
</div>
</div>
);
};
export default ActivityCardCloseShift;

View File

@ -1,19 +1,29 @@
"use client";
import AppContext from "@ctx/AppContext";
import moment from "jalali-moment";
import { useRouter } from "next/navigation";
import HasPermission from "plugins/HasPermission/page";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect, useState } from "react";
import { Swiper, SwiperSlide } from "swiper/react";
const TasksCard = () => {
const TasksCard = ({ tasksData, permissions }) => {
const CTX = useContext(AppContext);
const tasksData = CTX.state.tasksData;
const router = useRouter();
const [showAllTasks, setShowAllTasks] = useState(false);
const [showJust5TasksData, setShowJust5TasksData] = useState(null);
const goToEditTask = (id) => {
if (!!HasPermission("ManageTasks", permissions)) {
CTX.setGoToEditTask(true);
router.push("/tasks/add-task?new=false");
CTX.GetTask(id);
CTX.setIdEditTask(id);
}
};
useEffect(() => {
if (tasksData.length > 5) {
setShowJust5TasksData(tasksData.slice(0, 5));
@ -22,13 +32,6 @@ const TasksCard = () => {
}
}, [tasksData]);
const goToEditTask = (id) => {
CTX.setGoToEditTask(true);
router.push("/tasks/add-task?new=false");
CTX.GetTask(id);
CTX.setIdEditTask(id);
};
return (
<>
{showAllTasks ? (
@ -74,18 +77,16 @@ const TasksCard = () => {
))}
</div>
) : (
<Swiper
spaceBetween={20}
slidesPerView={1.6}
onSlideChange={() => console.log("slide change")}
onSwiper={(swiper) => console.log(swiper)}
>
<Swiper spaceBetween={20} slidesPerView={1.6}>
{showJust5TasksData?.map((e) => (
<SwiperSlide>
<div
className=" bg-white p-1 rounded-3xl overflow-hidden relative mt-5"
onClick={() => goToEditTask(e.id)}
onClick={() => {
goToEditTask(e.id);
}}
>
{HasPermission("ManageTasks") && <div> salam</div>}
<div className="flex mx-2">
<div className="bg-secondaryLighter-100 w-fit relative px-2 text-[12px] my-2 mx-1 rounded-3xl text-secondary-200">
{e?.scheduleType == 0

View File

@ -1,5 +1,4 @@
export const PersianM = (month) => {
console.log("montssh", month);
switch (month) {
case (month = "1"):
return "month";

View File

@ -20,6 +20,7 @@
"jalali-moment": "^3.3.11",
"next": "13.4.19",
"postcss": "8.4.28",
"rc-slider": "^10.5.0",
"react": "18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "18.2.0",

View File

@ -79,8 +79,6 @@ const BottomManageShift = (props) => {
userId: userData.id,
};
console.log(bodyUpdate);
const clear = () => {
setFirstName("");
setLastName("");
@ -140,8 +138,6 @@ const BottomManageShift = (props) => {
}))
);
console.log(idEditUser);
if (e.type == "OPEN") {
CTX.GetRoles();
if (goToEditUser) {
@ -175,7 +171,6 @@ const BottomManageShift = (props) => {
});
// setRoleSelectCurrntData("");
CTX.setRolesChoose(userData.roleIds);
console.log("userData2", userData);
}
}, [userData]);

View File

@ -1,6 +1,6 @@
"use client";
import React, { useContext } from "react";
import React, { useContext, useState } from "react";
import { BottomSheet } from "react-spring-bottom-sheet";
import AppContext from "@ctx/AppContext";
import Buttonbriz from "plugins/Buttonbriz/page";
@ -8,8 +8,18 @@ import Buttonbriz from "plugins/Buttonbriz/page";
const BottomSheetChangeRole = (props) => {
const CTX = useContext(AppContext);
const [roleSelect, setRoleSelect] = useState(-1);
const [roleSelectId, setRoleSelectId] = useState(0);
const roles = CTX.state.profile.roles;
const handleChangeRole = () => {
if (roleSelectId != 0) {
CTX.changeRole(roleSelectId);
}
CTX.setBottomSheetChangeRoleOpen(false);
};
return (
<BottomSheet
open={CTX.state.BottomSheetChangeRoleOpen}
@ -21,8 +31,16 @@ const BottomSheetChangeRole = (props) => {
</div>
<div className="bg-body-100 p-3 ">
{roles?.map((e) => (
<div className="bg-gray-100 rounded-xl border-[1px] border-gray-200 p-5 m-2">
{roles?.map((e, index) => (
<div
className={`rounded-xl border-[1px] border-gray-200 p-5 m-2 tr03 ${
roleSelect == index ? " bg-primary-100" : "bg-gray-100 "
}`}
onClick={() => {
setRoleSelect(index);
setRoleSelectId(e.id);
}}
>
<p className="mb-0 text-right">{e.roleName}</p>
</div>
))}
@ -30,7 +48,7 @@ const BottomSheetChangeRole = (props) => {
title="ثبت نقش"
color="PRIMARY"
icon="CHECK"
// buttonEvent={() => handleCreateRoutine()}
buttonEvent={() => handleChangeRole()}
/>
</div>
</BottomSheet>

View File

@ -86,8 +86,6 @@ const BottomSheetCreateEmployees = (props) => {
// positionId,
};
console.log(bodyUpdate);
const clear = () => {
setFirstName("");
setLastName("");
@ -155,8 +153,6 @@ const BottomSheetCreateEmployees = (props) => {
// }))
// );
console.log(idEditUser);
if (e.type == "OPEN") {
CTX.GetRoles();
if (goToEditUser) {
@ -191,13 +187,9 @@ const BottomSheetCreateEmployees = (props) => {
// setRoleSelectCurrntData("");
CTX.setRolesChoose(userData.roleIds);
// setPositionId(userData.positionId);
console.log("userData2", userData);
}
}, [userData]);
console.log("positionIdSelectData", positionIdSelectData);
return (
<BottomSheet
onSpringStart={(e) => handleBottomSheetCreateEmployeesOpen(e)}

View File

@ -53,8 +53,6 @@ const BottomSheetCreatePosition = (props) => {
id: idEditPosition,
};
console.log(bodyUpdate);
const clear = () => {
setTitle("");
setDescription("");
@ -114,13 +112,9 @@ const BottomSheetCreatePosition = (props) => {
setTitle(positionData.name);
setDescription(positionData.description);
setSectionId(positionData.sectionId);
console.log("Position", positionData);
}
}, [positionData]);
console.log("sectionsData", sectionsData);
console.log("sectionId", sectionId);
return (
<BottomSheet
onSpringStart={(e) => handleBottomSheetCreatePositionOpen(e)}

View File

@ -45,8 +45,6 @@ const BottomSheetCreateRoutine = (props) => {
id: idEditRoutine,
};
console.log(bodyUpdate);
const clear = () => {
setTitle("");
setDescription("");
@ -92,7 +90,6 @@ const BottomSheetCreateRoutine = (props) => {
if (goToEditRoutine) {
setTitle(routineData.name);
setDescription(routineData.description);
console.log("sectionData", routineData);
}
}, [routineData]);

View File

@ -45,8 +45,6 @@ const BottomSheetCreateSection = (props) => {
id: idEditSection,
};
console.log(bodyUpdate);
const clear = () => {
setTitle("");
setDescription("");
@ -92,7 +90,6 @@ const BottomSheetCreateSection = (props) => {
if (goToEditSection) {
setTitle(sectionData.name);
setDescription(sectionData.description);
console.log("sectionData", sectionData);
}
}, [sectionData]);

View File

@ -41,8 +41,6 @@ const BottomSheetCreateShifts = (props) => {
})
);
console.log("dayOfWeeksChoose", dayOfWeeksChoose);
const week = [
{ key: "شنبه", value: 6 },
{ key: "یکشنبه", value: 0 },
@ -104,8 +102,6 @@ const BottomSheetCreateShifts = (props) => {
}
};
console.log(body);
const handleBottomSheetCreateShift = (e) => {
setRoutineIdSelectData(
routinesData.map((item) => ({
@ -127,7 +123,6 @@ const BottomSheetCreateShifts = (props) => {
};
const deleteRole = (value) => {
console.log(value);
CTX.setDayOfWeeksChoose(dayOfWeeksChoose.filter((el) => el !== value));
};
@ -149,7 +144,6 @@ const BottomSheetCreateShifts = (props) => {
}
}, [shiftData]);
console.log("routineId", routineId);
return (
<BottomSheet
onSpringStart={(e) => handleBottomSheetCreateShift(e)}

View File

@ -26,14 +26,16 @@ Chapar.interceptors.response.use(
return response.data;
},
function (error) {
function (error, status) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
// ;
// if (error.response.status === 401) {
// localStorage.removeItem("token");
// window.location.href = "/";
// }
return Promise.reject({ error, status: error?.response?.status });
}
);

View File

@ -22,11 +22,9 @@ const page = ({ title, detail, value }) => {
useEffect(() => {
if (!!permissionsChoose?.find((e) => e == value)) {
setIsChecked(true);
console.log("data");
}
}, [permissionsChoose]);
console.log(permissionsChoose);
return (
<div className="flex rtl mt-4">
<div>

View File

@ -20,8 +20,6 @@ const DatePickerIran = ({
const [selectedDay, setSelectedDay] = useState(null);
const goToEditUser = CTX.state.goToEditUser;
console.log("date", date);
// useEffect(() => {
// if (goToEditUser) {
// setSelectedDay(date);

View File

@ -1,8 +1,5 @@
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);
const HasPermission = (per, permissions) => {
return permissions?.includes(per);
};
export default HasPermission;

View File

@ -1,8 +1,18 @@
export function ParseJwt(token) {
if (!token) {
return;
const ParseJwt = (token) => {
// const router = useRouter();
try {
if (!token) {
return;
}
const base64Url = token.split(".")[1];
const base64 = base64Url.replace("-", "+").replace("_", "/");
return JSON.parse(window.atob(base64));
} catch (error) {
localStorage.removeItem("token");
window.location.reload("/login");
}
const base64Url = token.split(".")[1];
const base64 = base64Url.replace("-", "+").replace("_", "/");
return JSON.parse(window.atob(base64));
}
};
export default ParseJwt;

View File

@ -38,6 +38,9 @@ dependencies:
postcss:
specifier: 8.4.28
version: 8.4.28
rc-slider:
specifier: ^10.5.0
version: 10.5.0(react-dom@18.2.0)(react@18.2.0)
react:
specifier: 18.2.0
version: 18.2.0
@ -681,6 +684,10 @@ packages:
engines: {node: '>=6.0'}
dev: true
/classnames@2.3.2:
resolution: {integrity: sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==}
dev: false
/cli-cursor@3.1.0:
resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==}
engines: {node: '>=8'}
@ -1510,6 +1517,32 @@ packages:
safe-buffer: 5.2.1
dev: true
/rc-slider@10.5.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-xiYght50cvoODZYI43v3Ylsqiw14+D7ELsgzR40boDZaya1HFa1Etnv9MDkQE8X/UrXAffwv2AcNAhslgYuDTw==}
engines: {node: '>=8.x'}
peerDependencies:
react: '>=16.9.0'
react-dom: '>=16.9.0'
dependencies:
'@babel/runtime': 7.23.1
classnames: 2.3.2
rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0)
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false
/rc-util@5.38.1(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-e4ZMs7q9XqwTuhIK7zBIVFltUtMSjphuPPQXHoHlzRzNdOwUxDejo0Zls5HYaJfRKNURcsS/ceKVULlhjBrxng==}
peerDependencies:
react: '>=16.9.0'
react-dom: '>=16.9.0'
dependencies:
'@babel/runtime': 7.23.1
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
react-is: 18.2.0
dev: false
/react-chartjs-2@5.2.0(chart.js@4.4.0)(react@18.2.0):
resolution: {integrity: sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==}
peerDependencies:
@ -1534,6 +1567,10 @@ packages:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
dev: false
/react-is@18.2.0:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: false
/react-modern-calendar-datepicker@3.1.6(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-lnMqEMj9Wn32/sm119tjCl5lOkq4u9vJE7wggi7hdXV4s8rPdKlH56FVVehlBi0dfYeWQVZ9npY384Zprjn4WA==}
peerDependencies:

View File

@ -14,7 +14,7 @@ import moment from "jalali-moment";
const page = () => {
const CTX = useContext(AppContext);
const profile = CTX.state.profile;
const profile = CTX.state.profile.user;
const [fistName, setFistName] = useState("");
const [lastName, setLastName] = useState("");
@ -47,11 +47,10 @@ const page = () => {
// .split("/"));
// }
console.log(profile.birthDateTimeStamp < 0);
setFistName(profile.firstName);
setLastName(profile.lastName);
setPhoneNumber(profile.phoneNumber);
setNationalId(profile.nationalId);
setFistName(profile?.firstName);
setLastName(profile?.lastName);
setPhoneNumber(profile?.phoneNumber);
setNationalId(profile?.nationalId);
// setBirthDateTimeStamp(
// profile.birthDateTimeStamp < 0 ? ["1376", "09", "14"] : ""
@ -62,7 +61,7 @@ const page = () => {
<div className="pb-20">
<AppHeader
title={profile?.firstName + " " + profile?.lastName}
sub={profile.selectedComplexName}
sub={profile?.selectedComplexName}
icon2={true}
iconName2="ARROW"
iconHref2="/home"

View File

@ -17,6 +17,7 @@ import BottomSheetCreateShifts from "plugins/BottomSheet/BottomSheetCreateShifts
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect, useState } from "react";
import ShiftsEmployees from "@comp/EmployeesComponent/Shifts/page";
import ParseJwt from "plugins/ParseJwt/page";
// import second from "@img/test.png";
@ -71,7 +72,7 @@ const Employees = (props) => {
<div className="pb-20">
<AppHeader
title=" مدیریت کارکنان و نقش ها"
sub=" شما 12 نفر همکار در مجموعه دارید"
sub=" هسته اصلی تنظیمات مجموعه"
icon2={true}
iconName2="ARROW"
iconHref2="/home"

View File

@ -6,14 +6,14 @@ import AppContext from "@ctx/AppContext";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { getToken } from "plugins/Chapar";
import { ParseJwt } from "plugins/ParseJwt/page";
import ParseJwt from "plugins/ParseJwt/page";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect } from "react";
// import { Swiper, SwiperSlide } from "swiper/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";
import HasPermission from "plugins/HasPermission/page";
ChartJS.register(ArcElement, Tooltip, Legend);
@ -70,7 +70,7 @@ const Home = (props) => {
// router.replace("/activity");
// return null; // Prevent rendering the rest of the component
// console.log(HasPermission("ViewDashboard"));
// );
// }
// }, [profile]);
@ -78,11 +78,16 @@ const Home = (props) => {
<div className="pb-20">
<AppHeader
title={profile?.user?.firstName + " " + profile?.user?.lastName}
sub={profile?.user?.selectedRoleName}
sub={profile?.user?.selectedComplexName}
userIcon={true}
userIconData={profile?.user?.firstName}
userRole={profile?.roles}
userIconHref="/acount"
iconEvent3={() => CTX.setBottomSheetChangeRoleOpen(true)}
iconName3={
profile?.roles?.find((e) => e.id == profile?.user.selectedRoleId)
?.roleName
}
/>
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl">

View File

@ -18,6 +18,7 @@ import Loading from "plugins/Loading/page";
import Chapar, { getToken } from "plugins/Chapar";
import TimePicker from "plugins/TimePicker/page";
import axios from "axios";
import "rc-slider/assets/index.css";
const inter = Inter({ subsets: ["latin"] });
@ -136,6 +137,9 @@ export default function RootLayout({ children }) {
const [openTimePicker, setOpenTimePicker] = useState(false);
const [TimePickerOrder, setTimePickerOrder] = useState(null);
// closeShift
const [completeActivities, setCompleteActivities] = useState([]);
const pathname = usePathname();
const router = useRouter();
const hiddenUrls = ["/login", "/"];
@ -188,7 +192,7 @@ export default function RootLayout({ children }) {
router.push("/home");
}
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -209,7 +213,6 @@ export default function RootLayout({ children }) {
}
);
console.log("SignUpLogin", SignUpLogin);
setLoading(false);
if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
@ -224,7 +227,7 @@ export default function RootLayout({ children }) {
router.push("/home");
}
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -245,11 +248,10 @@ export default function RootLayout({ children }) {
}
);
console.log(data);
setPermissions(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -278,7 +280,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoles();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -306,7 +308,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoles();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -325,12 +327,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetRoles", data);
setRolesData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -349,12 +349,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetRole ", data);
setRoleData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -378,7 +376,7 @@ export default function RootLayout({ children }) {
GetRoles();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -407,7 +405,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetUsers();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -435,7 +433,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetUsers();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -455,11 +453,10 @@ export default function RootLayout({ children }) {
}
);
console.log("GetUsers", data);
setUsersData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -478,12 +475,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetUsersalam", data);
setUserData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -507,7 +502,7 @@ export default function RootLayout({ children }) {
GetUsers();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -535,7 +530,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -564,37 +559,43 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetShifts = async () => {
const GetShifts = async (date) => {
console.log(
"Date123456789",
`${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
date ? `&selectedDate=${date}` : ""
}`
);
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/shift?page=0`,
`${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
date ? `&selectedDate=${date}` : ""
}`,
{
headers: {
Authorization: getToken(),
},
}
);
console.log("GetShifts", data);
setShiftsData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetShift = async (id) => {
setLoading(true);
try {
@ -607,12 +608,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetShift", data);
setShiftData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -636,7 +635,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -664,7 +663,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -693,7 +692,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -712,12 +711,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetSection", data);
setSectionsData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -736,12 +733,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetShift", data);
setSectionData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -765,7 +760,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -793,7 +788,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -822,7 +817,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -841,16 +836,18 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetRoutines", GetRoutines);
setRoutinesData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
} catch (error) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
// if (error.response.status === 401) {
// localStorage.removeItem("token");
// window.location.href = "/";
// }
}
};
const GetRoutine = async (id) => {
@ -865,12 +862,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetRoutine", GetRoutine);
setRoutineData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -891,12 +886,10 @@ export default function RootLayout({ children }) {
}
);
console.log("GetRoutineShift", data);
setRoutineShiftPlan(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -921,7 +914,7 @@ export default function RootLayout({ children }) {
});
router.push("/shifts");
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -946,7 +939,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -974,7 +967,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1003,7 +996,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1022,12 +1015,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetPositions", data);
setPositionsData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1046,12 +1037,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetPosition", data);
setPositionData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1075,7 +1064,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1106,7 +1095,7 @@ export default function RootLayout({ children }) {
router.push("/tasks");
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1137,7 +1126,7 @@ export default function RootLayout({ children }) {
GetTasks();
router.push("/tasks");
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1156,12 +1145,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetTasks", data);
setTasksData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1180,12 +1167,10 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetPosition", data);
setTaskData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1209,7 +1194,7 @@ export default function RootLayout({ children }) {
GetTasks();
router.push("/tasks");
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1217,11 +1202,13 @@ export default function RootLayout({ children }) {
}
};
const GetActivity = async () => {
const GetActivity = async (date, shift) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/activity?page=0`,
`${process.env.NEXT_PUBLIC_API_URL}/activity?page=0${
date ? `&selectedDate=${date}` : ""
}${shift ? `&selectedShift=${shift}` : ""}`,
{
headers: {
@ -1229,12 +1216,114 @@ export default function RootLayout({ children }) {
},
}
);
console.log("GetActivity", data);
setActivitiesData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DoneActivity = async (id) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/activity/done/${id}`,
{
headers: {
Authorization: getToken(),
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UnDoneActivity = async (id, resone) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/activity/undone/${id}?undoneReason=${resone}`,
{
headers: {
Authorization: getToken(),
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const CloseShift = async (body, id) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}/complete`,
body,
{
headers: {
Authorization: getToken(),
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
// GetTasks();
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const changeRole = async (id) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/user/role/change/${id}`,
{
headers: {
Authorization: getToken(),
},
}
);
setProfile(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1254,13 +1343,11 @@ export default function RootLayout({ children }) {
},
}
);
console.log("CheckUser", data);
setProfile(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error.response.data.message}`, {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@ -1269,6 +1356,28 @@ export default function RootLayout({ children }) {
};
useEffect(() => {
console.log(`
bbbbbbbb
b::::::b iiii
b::::::b i::::i
b::::::b iiii
b:::::b
b:::::bbbbbbbbb rrrrr rrrrrrrrr iiiiiiizzzzzzzzzzzzzzzzz cccccccccccccccc ooooooooooo
b::::::::::::::bb r::::rrr:::::::::ri:::::iz:::::::::::::::z cc:::::::::::::::coo:::::::::::oo
b::::::::::::::::br:::::::::::::::::ri::::iz::::::::::::::z c:::::::::::::::::o:::::::::::::::o
b:::::bbbbb:::::::rr::::::rrrrr::::::i::::izzzzzzzz::::::z c:::::::cccccc:::::o:::::ooooo:::::o
b:::::b b::::::br:::::r r:::::i::::i z::::::z c::::::c cccccco::::o o::::o
b:::::b b:::::br:::::r rrrrrri::::i z::::::z c:::::c o::::o o::::o
b:::::b b:::::br:::::r i::::i z::::::z c:::::c o::::o o::::o
b:::::b b:::::br:::::r i::::i z::::::z c::::::c cccccco::::o o::::o
b:::::bbbbbb::::::br:::::r i::::::i z::::::zzzzzzzc:::::::cccccc:::::o:::::ooooo:::::o
b::::::::::::::::b r:::::r i::::::iz::::::::::::::zc:::::::::::::::::o:::::::::::::::o
b:::::::::::::::b r:::::r i::::::z:::::::::::::::z cc:::::::::::::::coo:::::::::::oo
bbbbbbbbbbbbbbbb rrrrrrr iiiiiiizzzzzzzzzzzzzzzzz cccccccccccccccc ooooooooooo
soli chizi bood bgo hossein__masoomi
`);
if (profile.length <= 0 && localStorage.token) CheckUser();
}, []);
@ -1338,6 +1447,7 @@ export default function RootLayout({ children }) {
BottomSheetAddUserToPositionShiftPlanOpen,
BottomSheetChangeRoleOpen,
activitiesData,
completeActivities,
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
@ -1441,6 +1551,11 @@ export default function RootLayout({ children }) {
setBottomSheetChangeRoleOpen,
setActivitiesData,
GetActivity,
UnDoneActivity,
DoneActivity,
changeRole,
setCompleteActivities,
CloseShift,
}}
>
<html lang="en">
@ -1452,12 +1567,12 @@ export default function RootLayout({ children }) {
{openTimePicker && <TimePicker />}
{BigPlusOpen ? (
<div className="fixed w-full top-0 z-[120]">
<div className="fixed w-full top-0 z-[120] ">
<motion.div
animate={{ opacity: [0, 0.5, 1] }}
transition={{ duration: 0.3 }}
>
<div className="h-screen bg-BigPlus">
<div className="h-screen bg-BigPlus ">
<div className="flex justify-center">
<div className="bg-primary-200 w-[60px] h-[60px] rounded-full fixed bottom-[37px] ">
<div
@ -1483,18 +1598,37 @@ export default function RootLayout({ children }) {
</div>
</div>
</div>
<div className="flex justify-between px-4 fixed bottom-[110px] w-full">
<Link href={"/dsdasd"}>
<div className="w-full p-3 m-2 rounded-full bg-secondaryDark-100">
<p className="mb-0 text-white">افزودن خرید جدیـــــد</p>
<div className="fixed bottom-[110px] w-full px-3 ">
<Link href={"/shifts/complete-shift"}>
<div
className="bg-secondary-200 p-3 my-2 w-full rounded-full"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-center text-white">بستن شیفت</p>
</div>
</Link>
<Link href={"/dsdasd"}>
<div className="w-full p-3 m-2 rounded-full bg-secondaryDark-100">
<p className="mb-0 text-white">افزودن وظیفه جدید</p>
</div>
</Link>
<div className="flex justify-between w-full">
<Link href={"/dsdasd"}>
<div
className="w-full p-3 rounded-full bg-secondaryDark-100 px-4"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-white">
افزودن خرید جدیـــــد
</p>
</div>
</Link>
<Link href={"/tasks/add-task?new=true"}>
<div
className="w-full p-3 rounded-full bg-secondaryDark-100 px-4"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-white">افزودن وظیفه جدید</p>
</div>
</Link>
</div>
</div>
</div>
</motion.div>

View File

@ -14,14 +14,14 @@ const Login = (props) => {
const stepLogin = CTX.state.stepLogin;
const router = useRouter();
// useEffect(() => {
// if (typeof window !== "undefined") {
// const item = localStorage.token;
// if (!!item) {
// router.push("/home");
// }
// }
// }, []);
useEffect(() => {
if (typeof window !== "undefined") {
const item = localStorage.token;
if (!!item) {
router.push("/home");
}
}
}, []);
return (
<div className="pb-5">

View File

@ -1,10 +1,142 @@
"use client";
import AppHeader from "@comp/AppHeader/page";
import TaskCard from "@comp/TaskPage/ActivityCard/page";
import ActivityCard from "@comp/TaskPage/ActivityCard/page";
import ActivityCardCloseShift from "@comp/TaskPage/ActivityCardCloseShift/page";
import AppContext from "@ctx/AppContext";
import moment from "jalali-moment";
import Buttonbriz from "plugins/Buttonbriz/page";
import PersianNumber from "plugins/PersianNumber";
import React from "react";
import Slider from "rc-slider";
import React, { useContext, useEffect, useState } from "react";
import { toast } from "react-toastify";
const CompleteShift = () => {
const data = [1, 2, 3, 4, 5, 8];
const CTX = useContext(AppContext);
const [closeShiftScore, setCloseShiftScore] = useState(70);
const [activeShifPlan, setActiveShifPlan] = useState(-1);
const [selectDayForShift, setSelectDayForShift] = useState(-1);
const currentDate = new Date();
const siftsData = CTX.state.shiftsData;
const activitiesData = CTX.state.activitiesData;
const circularHandleStyle = {
backgroundColor: "green",
border: "2px solid #ffffff",
boxShadow: "0 0 5px #333",
cursor: "pointer",
height: 30, // Adjust the height in pixels
width: 30, // Adjust the width to maintain a circular shape
marginLeft: -15, // Adjust the margin to center the handle
marginTop: -10, // Adjust the margin to center the handle
borderRadius: "50%", // Make the handle circular
};
const railStyle = {
backgroundColor: "red", // Overall track color
height: 10,
};
const trackStyle = {
backgroundColor: "green", // Color between handles
height: 10,
};
const body = {
completeDescription: "",
completeActivities: CTX.state.completeActivities,
completePercent: closeShiftScore,
};
const getTodayPersianDate = () => {
return moment().locale("fa").format("D MMMM YYYY");
};
const getYesterdayPersianDate = () => {
const yesterday = moment().locale("fa").subtract(1, "day");
return yesterday.format("D MMMM YYYY");
};
const getTomorrowPersianDate = () => {
const tomorrow = moment().locale("fa").add(1, "day");
return tomorrow.format("D MMMM YYYY");
};
const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => {
if (isCompleted) {
toast.warning(`شیفت بسته شده است `, {
position: "bottom-right",
closeOnClick: true,
});
} else if (!hasCurrentShiftPlan) {
toast.warning(`شیفت نا مشخص است `, {
position: "bottom-right",
closeOnClick: true,
});
} else {
handleActivityCloseShift(id, index);
}
};
const handleActivityCloseShift = (id, index) => {
CTX.setCompleteActivities([]);
setCloseShiftScore(70);
if (activeShifPlan == index) {
setActiveShifPlan(-1);
} else {
setActiveShifPlan(index);
if (selectDayForShift == 0) {
CTX.GetActivity(
moment().locale("fa").subtract(1, "day").unix() * 1000,
id
);
} else if (selectDayForShift == 1) {
CTX.GetActivity(moment().locale("fa").startOf("day").unix() * 1000, id);
} else if (selectDayForShift == 2) {
CTX.GetActivity(moment().locale("fa").add(1, "day").unix() * 1000, id);
}
}
};
const handleDayCloseShift = (index) => {
setSelectDayForShift(index);
setActiveShifPlan(-1);
if (index == 0) {
CTX.GetShifts(moment().locale("fa").subtract(1, "day").unix() * 1000);
} else if (index == 1) {
CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000);
} else if (index == 2) {
CTX.GetShifts(moment().locale("fa").add(1, "day").unix() * 1000);
}
};
const handleCloseShift = () => {
CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
// ;
// ;
// ;
// ;
};
useEffect(() => {
handleDayCloseShift(1);
}, []);
useEffect(() => {
if (activitiesData.length > 0) {
CTX.setCompleteActivities(
activitiesData.map((activity) => ({
activityId: activity?.id,
isCompleted: activity?.isDone,
performanceDescription: activity?.performanceDescription,
}))
);
}
}, [activitiesData]);
return (
<div className="pb-20">
<AppHeader
@ -16,25 +148,123 @@ const CompleteShift = () => {
/>
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-4 rtl">
{" "}
<div>
<h4 className="text-base font-bold text-primary-200">
فعالیت های انجام شده{" "}
</h4>
<p className="mb-0 text-sm text-gray-500">
در این شیفت
<strong className="mx-1 text-primary-300">
<PersianNumber number={24} />
</strong>
فعالیت از
<strong className="mx-1 text-primary-300">
<PersianNumber number={3} />
</strong>
نفر انجام شده است
</p>
<div className="flex overflow-auto whitespace-nowrap">
<div
className={`mx-1 rtl py-1 px-2 rounded-full font-bold inline-block tr03 ${
selectDayForShift == 0
? "bg-primary-200 text-white"
: " opacity-60 font-normal"
}`}
onClick={() => handleDayCloseShift(0)}
>
<PersianNumber number={getYesterdayPersianDate()} />
</div>
<div
className={`mx-1 rtl py-1 px-2 rounded-full font-bold inline-block tr03 ${
selectDayForShift == 1
? "bg-primary-200 text-white"
: " opacity-60 font-normal"
}`}
onClick={() => handleDayCloseShift(1)}
>
<p className="mb-0">
<PersianNumber number={getTodayPersianDate()} />
<small className="text-sm mx-2"> ( امروز )</small>
</p>
</div>
<div
className={`mx-1 rtl py-1 px-2 rounded-full font-bold inline-block tr03 ${
selectDayForShift == 2
? "bg-primary-200 text-white"
: " opacity-60 font-normal"
}`}
onClick={() => handleDayCloseShift(2)}
>
<PersianNumber number={getTomorrowPersianDate()} />
</div>
</div>
{data.map((e) => (
<TaskCard />
{siftsData?.map((e, index) => (
<div className="mt-3">
<div
className={`bg-gray-200 p-2 rounded-full flex justify-between ${
activeShifPlan == index ? "bg-gray-300 " : "bg-gray-200 "
} `}
onClick={() =>
handleOpenShift(
e?.isCompleted,
e?.id,
index,
e?.hasCurrentShiftPlan
)
}
>
<p className="mb-0">{e?.title} </p>
<div className="flex">
<div className="bg-gray-400 rounded-full mr-1">
<p className="mb-0 text-sm p-1 text-white ">
{" "}
<PersianNumber
number={e?.totalActivitiesCount}
style="mx-1 text-base"
/>
فعالیت
</p>
</div>
{e?.undoneActivitiesCount != 0 && (
<div className="bg-red-700 w-[30px] h-[30px] rounded-full mr-1">
<p className="mb-0 text-sm p-1 text-white text-center mt-[2px]">
{" "}
<PersianNumber
number={e?.undoneActivitiesCount}
style="mx-1 text-base"
/>
</p>
</div>
)}
{e?.isCompleted && (
<div className="bg-yellow-500 w-fit px-2 h-[30px] rounded-full mr-1">
<p className="mb-0 text-sm p-1 text-white text-center mt-[2px]">
{" "}
بسته شده
</p>
</div>
)}
</div>
</div>
{activeShifPlan == index && (
<>
{activitiesData?.map((e) => (
<ActivityCardCloseShift data={e} />
))}
<div className=" mt-5">
<div className=" p-3 relative top-[20px] ">
<Slider
min={0}
max={100}
defaultValue={[70]}
handleStyle={[circularHandleStyle, circularHandleStyle]}
railStyle={railStyle}
trackStyle={[trackStyle, trackStyle]}
onChange={(e) => setCloseShiftScore(e)}
/>
</div>
<Buttonbriz
title={` بستن شیفت با امتیاز ${closeShiftScore}`}
color="PRIMARY"
icon="CHECK"
buttonEvent={() => handleCloseShift()}
/>
</div>
</>
)}
</div>
))}
</div>
</div>

View File

@ -96,7 +96,8 @@ const Calendar = () => {
const body = {
planDate:
daysUntilWeek[selectDay]?.checkDay &&
moment.utc(daysUntilWeek[selectDay].checkDay, "jYYYY-jMM-jDDTHH").unix(),
moment.utc(daysUntilWeek[selectDay].checkDay, "jYYYY-jMM-jDDTHH").unix() *
1000,
shiftId: shiftsPlan && shiftsPlan[selectShift]?.id,
routineId: routinesData && routinesData[selectRoutine]?.id,
userAndPositionIds,
@ -196,8 +197,8 @@ const Calendar = () => {
<Swiper
spaceBetween={10}
slidesPerView={4.3}
onSlideChange={() => console.log("slide change")}
onSwiper={(swiper) => console.log(swiper)}
// onSlideChange={() => }
// onSwiper={(swiper) => }
>
{daysUntilWeek?.map((e, index) => (
<SwiperSlide>
@ -211,7 +212,6 @@ const Calendar = () => {
onClick={() => {
setSelectDay(index);
setShiftPlanSteps(2);
console.log(index);
}}
>
<div className="py-2">
@ -406,7 +406,7 @@ const Calendar = () => {
</>
))
) : (
<div className="flex justify-center ">
<div className="flex justify-center mb-3 ">
<div className="bg-gray-100 w-fit rounded-full p-2 px-4">
چیزی یافت نشد
</div>

View File

@ -8,15 +8,14 @@ import { useRouter } from "next/navigation";
import BottomSheetCreateShifts from "plugins/BottomSheet/BottomSheetCreateShifts";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect } from "react";
import React, { useContext, useEffect, useState } from "react";
import Slider, { Range } from "rc-slider";
import Buttonbriz from "plugins/Buttonbriz/page";
import moment from "jalali-moment";
import ActivityCard from "@comp/TaskPage/ActivityCard/page";
const Shifts = (props) => {
const CTX = useContext(AppContext);
const router = useRouter();
useEffect(() => {
CTX.GetShifts();
}, []);
return (
<>
@ -24,12 +23,12 @@ const Shifts = (props) => {
<AppHeader
title="شیفتــــ های مجموعه"
sub="شما 12 نفر شیفت متفاوت دارید"
icon1={true}
iconName1="PLUS"
iconHref1="#"
iconEvent1={() => {
CTX.setBottomSheetCreateShiftsOpen(true);
}}
// icon1={true}
// iconName1="PLUS"
// iconHref1="#"
// iconEvent1={() => {
// CTX.setBottomSheetCreateShiftsOpen(true);
// }}
icon2={true}
iconName2="ARROW"
iconHref2="/home"

View File

@ -145,20 +145,15 @@ const AddTask = () => {
const handleCreateTask = (update) => {
if (scheduleType == 0) {
console.log("scheduleType == 0");
validator.current.message("shiftsDaysChoose", true, "required");
validator.current.message("birthDateTimeStamp", true, "required");
}
if (scheduleType == 1) {
console.log("scheduleType == 1");
validator.current.message("birthDateTimeStamp", true, "required");
}
if (scheduleType == 2) {
console.log("scheduleType == 2");
validator.current.message("shiftsDaysChoose", true, "required");
}
@ -180,7 +175,6 @@ const AddTask = () => {
});
validator.current.showMessages();
console.log(validator.current);
forceUpdate(1);
}
};
@ -276,7 +270,7 @@ const AddTask = () => {
}, [scheduleType]);
useEffect(() => {
// console.log("ssssssssssssssssssssssssss", taskData.routines);
// ;
if (goToEditTask) {
// const date = moment
@ -304,8 +298,6 @@ const AddTask = () => {
}
}, [taskData]);
console.log("body", body);
return (
<div className="pb-20">
<AppHeader

View File

@ -9,24 +9,27 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import ActivityCard from "@comp/TaskPage/ActivityCard/page";
import TasksCard from "@comp/TaskPage/TasksCard/page";
import moment from "jalali-moment";
import HasPermission from "plugins/HasPermission/page";
const page = () => {
const CTX = useContext(AppContext);
const router = useRouter();
const routinesData = CTX.state.routinesData;
const activities = CTX.state.activitiesData;
const tasksData = CTX.state.tasksData;
const permissions = CTX.state.profile?.permissions;
useEffect(() => {
CTX.GetTasks();
CTX.GetActivity();
CTX.GetActivity(moment().locale("fa").startOf("day").unix() * 1000);
}, []);
return (
<div className="pb-20">
<AppHeader
title=" تسک های مجموعه"
sub=" شما 12 تسک در مجموعه دارید"
icon1={true}
sub=" مدیریت فعالیت ها"
icon1={!!HasPermission("ManageTasks", permissions) ? true : false}
iconName1="PLUS"
iconHref1="/tasks/add-task?new=true"
iconEvent1={() => {
@ -49,7 +52,7 @@ const page = () => {
<p className="mb-0 text-sm">
امروز
<strong className="mx-1 text-primary-300">
<PersianNumber number={24} />
<PersianNumber number={tasksData?.length} />
</strong>
تسک فعال دارید
</p>
@ -71,7 +74,7 @@ const page = () => {
</svg>
</div>
</div>
<TasksCard />
<TasksCard tasksData={tasksData} permissions={permissions} />
<div className="flex justify-between mt-7 sticky top-0">
<div>
@ -103,7 +106,9 @@ const page = () => {
</div>
<div className=" mt-3">
<ActivityCard />
{activities?.map((e) => (
<ActivityCard data={e} />
))}
</div>
</div>