dashboard , go complete shift
parent
cc02701fd9
commit
39510a41fe
12
.env
12
.env
|
@ -1,8 +1,8 @@
|
|||
NODE_ENV="development"
|
||||
|
||||
# NEXT_PUBLIC_SERVER_URL=http://192.168.88.251:32769
|
||||
# NEXT_PUBLIC_PUBLIC_URL=http://192.168.88.251:32769
|
||||
# NEXT_PUBLIC_API_URL=http://192.168.88.251:32769/api
|
||||
NEXT_PUBLIC_SERVER_URL=http://192.168.117.123:32769
|
||||
NEXT_PUBLIC_PUBLIC_URL=http://192.168.117.123:32769
|
||||
NEXT_PUBLIC_API_URL=http://192.168.117.123:32769/api
|
||||
|
||||
# SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99
|
||||
# NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages
|
||||
|
@ -14,8 +14,8 @@ NODE_ENV="development"
|
|||
|
||||
|
||||
|
||||
NEXT_PUBLIC_SERVER_URL=https://api.brizco.io
|
||||
NEXT_PUBLIC_PUBLIC_URL=https://api.brizco.io
|
||||
NEXT_PUBLIC_API_URL=https://api.brizco.io/api
|
||||
# NEXT_PUBLIC_SERVER_URL=https://api.brizco.io
|
||||
# NEXT_PUBLIC_PUBLIC_URL=https://api.brizco.io
|
||||
# NEXT_PUBLIC_API_URL=https://api.brizco.io/api
|
||||
# NEXT_PUBLIC_API_URL_IMAGE=https://api.macsonline.ir/Files/ReportImages
|
||||
# NEXT_PUBLIC_API_URL_BackUp=https://api.macsonline.ir/Files/BackUps
|
|
@ -1,3 +1,4 @@
|
|||
import React from "react";
|
||||
const PersianNumber = ({ number, isCost, size, bold, style }) => {
|
||||
if (number || number === 0) {
|
||||
const persianMap = "۰۱۲۳۴۵۶۷۸۹".split("");
|
||||
|
@ -16,4 +17,8 @@ const PersianNumber = ({ number, isCost, size, bold, style }) => {
|
|||
} else return null;
|
||||
};
|
||||
|
||||
export default PersianNumber;
|
||||
const PersianNumberMemo = React.memo(PersianNumber, (perv, next) => {
|
||||
return perv.number === next.number;
|
||||
});
|
||||
|
||||
export default PersianNumberMemo;
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useRouter } from "next/navigation";
|
|||
import { getToken } from "plugins/Chapar";
|
||||
import ParseJwt from "plugins/ParseJwt/page";
|
||||
import PersianNumber from "plugins/PersianNumber";
|
||||
import React, { useContext, useEffect } from "react";
|
||||
import React, { useContext, useEffect, useMemo } 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";
|
||||
|
@ -18,21 +18,10 @@ import Avatar from "boring-avatars";
|
|||
|
||||
ChartJS.register(ArcElement, Tooltip, Legend);
|
||||
|
||||
export const data = {
|
||||
datasets: [
|
||||
{
|
||||
label: ["", " "],
|
||||
data: [350, 200],
|
||||
backgroundColor: ["rgba(203, 203, 203, 0.38)", "rgba(222, 193, 72, 1)"],
|
||||
borderColor: ["transparent"],
|
||||
cutout: 35,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const Home = (props) => {
|
||||
const CTX = useContext(AppContext);
|
||||
const router = useRouter();
|
||||
const homePageData = CTX.state.homePageData;
|
||||
|
||||
const profile = CTX.state.profile;
|
||||
|
||||
|
@ -48,6 +37,50 @@ const Home = (props) => {
|
|||
|
||||
console.log(profile);
|
||||
|
||||
useEffect(() => {
|
||||
CTX.GetHomePageData();
|
||||
}, []);
|
||||
|
||||
const dataChart = useMemo(() => {
|
||||
const data = {
|
||||
datasets: [
|
||||
{
|
||||
label: ["", " "],
|
||||
data: [
|
||||
homePageData?.totalActivitiesToday,
|
||||
homePageData?.doneActivitiesToday,
|
||||
],
|
||||
backgroundColor: [
|
||||
"rgba(203, 203, 203, 0.38)",
|
||||
"rgba(222, 193, 72, 1)",
|
||||
],
|
||||
borderColor: ["transparent"],
|
||||
cutout: 35,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
console.log("datasets", data);
|
||||
return data;
|
||||
}, [homePageData]);
|
||||
|
||||
const percentage = useMemo(() => {
|
||||
return (
|
||||
(homePageData?.doneActivitiesToday / homePageData?.totalActivitiesToday) *
|
||||
100
|
||||
);
|
||||
}, [homePageData?.doneActivitiesToday, homePageData?.totalActivitiesToday]);
|
||||
console.log(CTX.state.homePageData);
|
||||
|
||||
const handleGoToReport = () => {
|
||||
CTX.setReportDetail({
|
||||
title: "فعالیت های مجموعه",
|
||||
shiftId: "",
|
||||
typeReport: "TASK",
|
||||
});
|
||||
CTX.setBottomSheetReportOpen(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="pb-20">
|
||||
<AppHeader
|
||||
|
@ -65,108 +98,106 @@ const Home = (props) => {
|
|||
/>
|
||||
|
||||
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl">
|
||||
<div>
|
||||
<div className="bg-white p-3 rounded-full shadow">
|
||||
<div className="flex justify-between">
|
||||
<div className="flex">
|
||||
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px]">
|
||||
<div className=" rounded-full z-10 ">
|
||||
<Avatar
|
||||
size={40}
|
||||
name={"حسین"}
|
||||
variant="beam"
|
||||
colors={["#9d9f88", "#83af96", "#b2de93"]}
|
||||
/>
|
||||
</div>
|
||||
{1 > 0 && (
|
||||
<div>
|
||||
<div className="bg-white p-5 rounded-full shadow">
|
||||
<div className="flex justify-between">
|
||||
<div className="flex mt-[-3px]">
|
||||
{homePageData?.todayStaffNames
|
||||
?.slice(0, 4)
|
||||
.map((e, index) => (
|
||||
<div
|
||||
className={`w-[50px] h-[50px] rounded-full bg-white border-[5px] absolute mr-[${
|
||||
index * 30
|
||||
}px]`}
|
||||
>
|
||||
<div className=" rounded-full z-10 ">
|
||||
<Avatar
|
||||
size={40}
|
||||
name={e}
|
||||
variant="beam"
|
||||
colors={["#9d9f88", "#83af96", "#b2de93"]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px] absolute mr-[30px]">
|
||||
<div className=" rounded-full z-10 ">
|
||||
<Avatar
|
||||
size={40}
|
||||
name={"skasd"}
|
||||
variant="beam"
|
||||
colors={["#9d9f88", "#83af96", "#b2de93"]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px] absolute mr-[60px]">
|
||||
<div className=" rounded-full z-10 ">
|
||||
<Avatar
|
||||
size={40}
|
||||
name={"daerfgf"}
|
||||
variant="beam"
|
||||
colors={["#9d9f88", "#83af96", "#b2de93"]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-[50px] h-[50px] rounded-full bg-white border-[5px] absolute mr-[90px]">
|
||||
<div className=" rounded-full z-10 ">
|
||||
<Avatar
|
||||
size={40}
|
||||
name={"wwwe"}
|
||||
variant="beam"
|
||||
colors={["#9d9f88", "#83af96", "#b2de93"]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 ml-[40px]">
|
||||
<h2 className="font-bold text-gray-600">
|
||||
<PersianNumber
|
||||
number={12}
|
||||
style={"!text-[25px] font-bold ml-1"}
|
||||
/>
|
||||
در شیفت عصر
|
||||
</h2>
|
||||
<div className="mt-3 ml-[20px]">
|
||||
<h2 className="font-bold text-gray-600">
|
||||
<PersianNumber
|
||||
number={homePageData?.totalStaffToday}
|
||||
style={"!text-[25px] font-bold ml-1"}
|
||||
/>
|
||||
کارمند در مجموعه
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-5">
|
||||
<h3 className="text-right p-3 font-medium">شنبه 20 فروردین 1403</h3>
|
||||
<div className="grid xs:grid-cols-2 gap-4 rtl">
|
||||
<div>
|
||||
<div className="bg-dahs-chart rounded-2xl p-2 h-[195px]">
|
||||
<div className="flex justify-center ">
|
||||
<div className="absolute mt-[40px]">
|
||||
<h2 className="text-lg text-white">
|
||||
<PersianNumber number={10} />
|
||||
<small className="text-white text-[11px] ml-1">%</small>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-center">
|
||||
<div className="w-[100px]">
|
||||
<Doughnut data={data} />
|
||||
</div>
|
||||
</div>
|
||||
{homePageData?.totalActivitiesToday > 0 ? (
|
||||
<>
|
||||
<div className="flex justify-center ">
|
||||
<div className="absolute mt-[40px]">
|
||||
<h2 className="text-lg text-white">
|
||||
<PersianNumber number={percentage} />
|
||||
<small className="text-white text-[11px] ml-1">
|
||||
%
|
||||
</small>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-center">
|
||||
<div className="w-[100px]">
|
||||
<Doughnut data={dataChart} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-3">
|
||||
<p className="mb-0 text-gray-300 text-[10px] text-center">
|
||||
مجموعه شما امروز
|
||||
<PersianNumber number={25} style="!text-[10px] mx-[3px]" />
|
||||
فعالیت فعال دارد
|
||||
<div className="mt-3">
|
||||
<p className="mb-0 text-gray-200 text-[12px] text-center">
|
||||
مجموعه شما امروز
|
||||
<PersianNumber
|
||||
number={homePageData?.unDoneActivitiesToday}
|
||||
style="!text-[10px] mx-[3px]"
|
||||
/>
|
||||
فعالیت فعال دارد
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="mt-20">
|
||||
<p className="mb-0 text-gray-200 text-[12px] text-center">
|
||||
شما شیفت بازی ندارید
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Link href={"/shifts/complete-shift"}>
|
||||
<div className="bg-[#d4818138] p-4 rounded-2xl mt-4">
|
||||
<p className="mb-0 text-center text-[#c20000] text-sm font-medium">
|
||||
بستن شیفت
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[#d4818138] p-4 rounded-2xl mt-4">
|
||||
<p className="mb-0 text-center text-[#c20000] text-sm">
|
||||
بستن شیفت
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="">
|
||||
<div className="bg-[#d19751] p-3 rounded-2xl">
|
||||
<div>
|
||||
<div className="flex justify-end ml-2">
|
||||
<svg
|
||||
width="30"
|
||||
height="36"
|
||||
viewBox="0 0 250 226"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="opacity-50"
|
||||
>
|
||||
<path
|
||||
d="M246.5 100.625L196.375 13.1249C194.231 9.27721 191.093 6.0758 187.289 3.85501C183.485 1.63421 179.155 0.475501 174.75 0.499889H75C70.5953 0.475501 66.2649 1.63421 62.461 3.85501C58.657 6.0758 55.5191 9.27721 53.375 13.1249L34.25 46.4999L24.25 63.8749L3.25002 100.625C1.129 104.405 0.010209 108.665 2.51422e-05 113C-0.00611845 117.337 1.11374 121.601 3.25002 125.375L24.25 162.125L34.25 179.5L53.375 212.875C55.5191 216.723 58.657 219.924 62.461 222.145C66.2649 224.366 70.5953 225.524 75 225.5H174.75C179.155 225.524 183.485 224.366 187.289 222.145C191.093 219.924 194.231 216.723 196.375 212.875L246.5 125.375C248.636 121.601 249.756 117.337 249.75 113C249.784 108.66 248.663 104.388 246.5 100.625ZM191.7 175.3L191.775 175.25L191.725 175.337L191.7 175.3ZM228.5 113L191.813 175.175C190.338 175.3 188.888 175.5 187.375 175.5C171.025 175.49 155.331 169.065 143.668 157.607C132.004 146.149 125.301 130.572 125 114.225V112.75C124.921 96.2213 118.303 80.396 106.592 68.7318C94.8805 57.0676 79.0288 50.5129 62.5 50.4999C61.2027 50.5568 59.9092 50.682 58.625 50.8749L73.625 25.4999H176.875L228.625 113H228.5Z"
|
||||
|
@ -175,20 +206,33 @@ const Home = (props) => {
|
|||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-start">
|
||||
<div className="absolute mt-[-35px] ml-3">
|
||||
<h2 className="mb-0 text-4xl">
|
||||
<PersianNumber
|
||||
number={2}
|
||||
style={
|
||||
"!text-[25px] text-white font-bold text-gray-200"
|
||||
}
|
||||
/>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p className="mb-0 text-white text-[12px] mt-3 font-medium">
|
||||
کل شیفت های مجموعه{" "}
|
||||
کل شیفت های امروز{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-[#279e96] p-3 rounded-2xl mt-3">
|
||||
<div>
|
||||
<div className="flex justify-end ml-2">
|
||||
<svg
|
||||
width="30"
|
||||
height="36"
|
||||
viewBox="0 0 251 226"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="opacity-50"
|
||||
>
|
||||
<path
|
||||
d="M246.65 100.5L196.612 13.0002C194.463 9.19349 191.338 6.02857 187.559 3.83143C183.78 1.63429 179.483 0.48438 175.112 0.50016H75.062C70.6812 0.545125 66.3859 1.71914 62.5912 3.9088C58.7966 6.09846 55.6307 9.22974 53.3995 13.0002L3.36204 100.5C1.16661 104.3 0.0107422 108.611 0.0107422 113C0.0107422 117.389 1.16661 121.7 3.36204 125.5L53.3995 213C55.6307 216.771 58.7966 219.902 62.5912 222.092C66.3859 224.281 70.6812 225.455 75.062 225.5H175.137C179.507 225.515 183.801 224.365 187.578 222.167C191.355 219.97 194.478 216.806 196.625 213L246.662 125.5C248.857 121.7 250.013 117.389 250.013 113C250.013 108.611 248.845 104.3 246.65 100.5ZM175 200.5H74.9995L24.9995 113L74.9995 25.5002H175L225 113L175 200.5Z"
|
||||
|
@ -196,26 +240,39 @@ const Home = (props) => {
|
|||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-start">
|
||||
<div className="absolute mt-[-35px] ml-3">
|
||||
<h2 className="mb-0 text-4xl">
|
||||
<PersianNumber
|
||||
number={homePageData?.totalActivitiesToday}
|
||||
style={"!text-[25px] font-bold text-gray-200"}
|
||||
/>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p className="mb-0 text-gray-100 text-[12px] mt-3">
|
||||
کل تسک های مجموعه{" "}
|
||||
کل فعالیت های امروز{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>{" "}
|
||||
<div className="bg-[#75a29f46] p-4 rounded-2xl mt-4">
|
||||
<p className="mb-0 text-center text-[#006e67] text-sm font-medium">
|
||||
افزودن تسک{" "}
|
||||
</p>
|
||||
</div>
|
||||
<Link href={"/tasks/add-task?new=true"}>
|
||||
<div className="bg-[#75a29f46] p-4 rounded-2xl mt-4">
|
||||
<p className="mb-0 text-center text-[#006e67] text-sm font-medium">
|
||||
افزودن تسک{" "}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="col-span-2">
|
||||
<div className="bg-[#e4be8f34] p-4 rounded-2xl ">
|
||||
<p className="mb-0 text-center text-[#66451d] text-sm font-medium">
|
||||
شیفت بندی هفته{" "}
|
||||
</p>
|
||||
</div>
|
||||
<Link href={"/shifts/manage-shift"}>
|
||||
<div className="bg-[#e29d494b] p-4 rounded-2xl ">
|
||||
<p className="mb-0 text-center text-[#66451d] text-sm font-medium">
|
||||
شیفت بندی هفته{" "}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -247,8 +304,8 @@ const Home = (props) => {
|
|||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="mx-2 mt-1">
|
||||
<h3 className="text-sm font-bold "> شیفت های بسته شده</h3>
|
||||
<div className="mx-2 mt-1" onClick={() => handleGoToReport()}>
|
||||
<h3 className="text-sm font-bold "> فعالیت ها </h3>
|
||||
<p className="mb-0 text-right text-sm text-gray-500">
|
||||
خروجی اکسل
|
||||
</p>
|
||||
|
@ -265,7 +322,7 @@ const Home = (props) => {
|
|||
viewBox="0 0 251 226"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto mt-3"
|
||||
className="mx-auto mt-3 opacity-50"
|
||||
s
|
||||
>
|
||||
<path
|
||||
|
@ -282,8 +339,8 @@ const Home = (props) => {
|
|||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="mx-2 mt-1">
|
||||
<h3 className="text-sm font-bold "> تسک های مجموعه</h3>
|
||||
<div className="mx-2 mt-1 opacity-50">
|
||||
<h3 className="text-sm font-bold "> شیفت های تمام شده </h3>
|
||||
<p className="mb-0 text-right text-sm text-gray-500">
|
||||
خروجی اکسل
|
||||
</p>
|
||||
|
@ -300,7 +357,7 @@ const Home = (props) => {
|
|||
viewBox="0 0 251 226"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto mt-3"
|
||||
className="mx-auto mt-3 opacity-50"
|
||||
s
|
||||
>
|
||||
<path
|
||||
|
@ -317,8 +374,51 @@ const Home = (props) => {
|
|||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="mx-2 mt-1">
|
||||
<h3 className="text-sm font-bold ">کارمند های مجموعه</h3>
|
||||
<div className="mx-2 mt-1 opacity-50">
|
||||
<h3 className="text-sm font-bold ">
|
||||
{" "}
|
||||
شیفت های مجموعه{" "}
|
||||
<small className="text-red-500">(به زودی)</small>
|
||||
</h3>
|
||||
<p className="mb-0 text-right text-sm text-gray-500">
|
||||
خروجی اکسل
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rtl mt-4">
|
||||
<div className="flex ">
|
||||
<div className="w-[50px] h-[50px] rounded-2xl bg-white shadow">
|
||||
<svg
|
||||
width="25"
|
||||
height="25"
|
||||
viewBox="0 0 251 226"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto mt-3 opacity-50"
|
||||
s
|
||||
>
|
||||
<path
|
||||
d="M246.65 100.5L196.612 13.0002C194.463 9.19349 191.338 6.02857 187.559 3.83143C183.78 1.63429 179.483 0.48438 175.112 0.50016H75.062C70.6812 0.545125 66.3859 1.71914 62.5912 3.9088C58.7966 6.09846 55.6307 9.22974 53.3995 13.0002L3.36204 100.5C1.16661 104.3 0.0107422 108.611 0.0107422 113C0.0107422 117.389 1.16661 121.7 3.36204 125.5L53.3995 213C55.6307 216.771 58.7966 219.902 62.5912 222.092C66.3859 224.281 70.6812 225.455 75.062 225.5H175.137C179.507 225.515 183.801 224.365 187.578 222.167C191.355 219.97 194.478 216.806 196.625 213L246.662 125.5C248.857 121.7 250.013 117.389 250.013 113C250.013 108.611 248.845 104.3 246.65 100.5ZM175 200.5H74.9995L24.9995 113L74.9995 25.5002H175L225 113L175 200.5Z"
|
||||
fill="#ABABAB"
|
||||
/>
|
||||
<path
|
||||
d="M112 63.5C112 56.5964 117.596 51 124.5 51V51C131.404 51 137 56.5964 137 63.5V126C137 132.904 131.404 138.5 124.5 138.5V138.5C117.596 138.5 112 132.904 112 126V63.5Z"
|
||||
fill="#ABABAB"
|
||||
/>
|
||||
<path
|
||||
d="M124.5 173C131.404 173 137 167.404 137 160.5C137 153.596 131.404 148 124.5 148C117.596 148 112 153.596 112 160.5C112 167.404 117.596 173 124.5 173Z"
|
||||
fill="#ABABAB"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="mx-2 mt-1 opacity-50">
|
||||
<h3 className="text-sm font-bold ">
|
||||
{" "}
|
||||
کاست تمام شده آیتم ها{" "}
|
||||
<small className="text-red-500">(به زودی)</small>
|
||||
</h3>
|
||||
<p className="mb-0 text-right text-sm text-gray-500">
|
||||
خروجی اکسل
|
||||
</p>
|
||||
|
|
|
@ -154,6 +154,9 @@ export default function RootLayout({ children }) {
|
|||
//report
|
||||
const [reportDetail, setReportDetail] = useState(null);
|
||||
|
||||
//home page
|
||||
const [homePageData, setHomePageData] = useState([]);
|
||||
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const hiddenUrls = ["/login", "/pricing", "/about-us", "/"];
|
||||
|
@ -1529,6 +1532,31 @@ export default function RootLayout({ children }) {
|
|||
}
|
||||
};
|
||||
|
||||
const GetHomePageData = async (id) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await Chapar.get(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/page/dashboard/app`,
|
||||
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer " + localStorage.getItem("token"),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log(data);
|
||||
setHomePageData(data);
|
||||
setLoading(false);
|
||||
} catch ({ error, status }) {
|
||||
toast.error(`${error?.response?.data?.message}`, {
|
||||
position: "bottom-right",
|
||||
closeOnClick: true,
|
||||
});
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log(`
|
||||
bbbbbbbb
|
||||
|
@ -1636,6 +1664,7 @@ export default function RootLayout({ children }) {
|
|||
BottomSheetReportOpen,
|
||||
reportDetail,
|
||||
BottomFilterActivitiesOpen,
|
||||
homePageData,
|
||||
},
|
||||
setBottomSheetCreateRoleOpen,
|
||||
setBottomSheetCreateEmployeesOpen,
|
||||
|
@ -1758,6 +1787,8 @@ export default function RootLayout({ children }) {
|
|||
ReportShiftPlan,
|
||||
ReportTask,
|
||||
setBottomFilterActivitiesOpen,
|
||||
setHomePageData,
|
||||
GetHomePageData,
|
||||
}}
|
||||
>
|
||||
<html lang="en">
|
||||
|
|
|
@ -4,16 +4,19 @@ 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 { useParams, useSearchParams } from "next/navigation";
|
||||
import Buttonbriz from "plugins/Buttonbriz/page";
|
||||
import GoBack from "plugins/GoBack/page";
|
||||
import PersianNumber from "plugins/PersianNumber";
|
||||
import Slider from "rc-slider";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import React, { useCallback, useContext, useEffect, useState } from "react";
|
||||
import InfiniteScroll from "react-infinite-scroll-component";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
const CompleteShift = () => {
|
||||
const CTX = useContext(AppContext);
|
||||
const searchParams = useSearchParams();
|
||||
const day = searchParams.get("day");
|
||||
|
||||
const [closeShiftScore, setCloseShiftScore] = useState(50);
|
||||
const [activeShifPlan, setActiveShifPlan] = useState(-1);
|
||||
|
@ -124,11 +127,15 @@ const CompleteShift = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleCloseShift = () => {
|
||||
CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
|
||||
setActiveShifPlan(-1);
|
||||
handleDayCloseShift(1);
|
||||
};
|
||||
const handleCloseShift = useCallback(
|
||||
() => {
|
||||
CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
|
||||
setActiveShifPlan(-1);
|
||||
handleDayCloseShift(1);
|
||||
},
|
||||
[siftsData[activeShifPlan]?.currentShiftPlanId],
|
||||
body
|
||||
);
|
||||
|
||||
const handleGoToReport = (title, shiftId) => {
|
||||
CTX.setReportDetail({
|
||||
|
@ -140,7 +147,13 @@ const CompleteShift = () => {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleDayCloseShift(1);
|
||||
if (day == "tomorrow") {
|
||||
handleDayCloseShift(2);
|
||||
} else if (day == "yesterday") {
|
||||
handleDayCloseShift(0);
|
||||
} else {
|
||||
handleDayCloseShift(1);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -57,6 +57,44 @@ const Shifts = (props) => {
|
|||
setShiftplans(groupedArray);
|
||||
};
|
||||
|
||||
function checkDateStatus(planFor) {
|
||||
// Get today's date
|
||||
const today = new Date();
|
||||
// Get yesterday's date
|
||||
const yesterday = new Date(today);
|
||||
yesterday.setDate(today.getDate() - 1);
|
||||
// Get tomorrow's date
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
|
||||
// Parse the "planFor" date from the API response
|
||||
const planForDate = new Date(planFor);
|
||||
|
||||
// Check if the planForDate is today
|
||||
const isToday = planForDate.toDateString() === today.toDateString();
|
||||
|
||||
// Check if the planForDate is yesterday
|
||||
const isYesterday = planForDate.toDateString() === yesterday.toDateString();
|
||||
|
||||
// Check if the planForDate is tomorrow
|
||||
const isTomorrow = planForDate.toDateString() === tomorrow.toDateString();
|
||||
|
||||
console.log(
|
||||
"today",
|
||||
isToday,
|
||||
"yesterday",
|
||||
isYesterday,
|
||||
"tomorrow",
|
||||
isTomorrow
|
||||
);
|
||||
|
||||
return {
|
||||
today: isToday,
|
||||
yesterday: isYesterday,
|
||||
tomorrow: isTomorrow,
|
||||
};
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
CTX.GetShifPlans(0);
|
||||
}, []);
|
||||
|
@ -91,7 +129,7 @@ const Shifts = (props) => {
|
|||
{HasPermission("ManageShiftPlans", permissions) && (
|
||||
<>
|
||||
<Link href={"/shifts/manage-shift"}>
|
||||
<div className="bg-[#e4be8f34] p-4 rounded-2xl ">
|
||||
<div className="bg-[#e29d494b] p-4 rounded-2xl mb-5 ">
|
||||
<p className="mb-0 text-center text-[#66451d] text-sm font-medium">
|
||||
شیفت بندی هفته{" "}
|
||||
</p>
|
||||
|
@ -168,6 +206,36 @@ const Shifts = (props) => {
|
|||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{checkDateStatus(e.planFor).yesterday && (
|
||||
<Link href={"/shifts/complete-shift?day=yesterday"}>
|
||||
<div className="mt-6">
|
||||
<button className="btn btn-info w-full font-normal rounded-2xl text-sm p-3">
|
||||
بستن و تایید شیفت
|
||||
</button>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{checkDateStatus(e.planFor).today && (
|
||||
<Link href={"/shifts/complete-shift"}>
|
||||
<div className="mt-6">
|
||||
<button className="btn btn-info w-full font-normal rounded-2xl text-sm p-3">
|
||||
بستن و تایید شیفت
|
||||
</button>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{checkDateStatus(e.planFor).tomorrow && (
|
||||
<Link href={"/shifts/complete-shift?day=tomorrow"}>
|
||||
<div className="mt-6">
|
||||
<button className="btn btn-info w-full font-normal rounded-2xl text-sm p-3">
|
||||
بستن و تایید شیفت
|
||||
</button>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -56,15 +56,6 @@ const page = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const handleGoToReport = () => {
|
||||
CTX.setReportDetail({
|
||||
title: "فعالیت های مجموعه",
|
||||
shiftId: "",
|
||||
typeReport: "TASK",
|
||||
});
|
||||
CTX.setBottomSheetReportOpen(true);
|
||||
};
|
||||
|
||||
const attrs = useLongPress((e) => console.log(e), {
|
||||
// onStart: (event) => setSubButtonAction(true),
|
||||
onFinish: (event) => {
|
||||
|
@ -97,24 +88,6 @@ const page = () => {
|
|||
}}
|
||||
/>
|
||||
|
||||
{HasPermission("ManageReports", permissions) && (
|
||||
<>
|
||||
<div className="bg-primary-300 flex whitespace-nowrap rtl p-3">
|
||||
<div
|
||||
className=" bg-white rounded-3xl p-5 inline-block w-fit relative top-[-32px] mx-2"
|
||||
onClick={() => handleGoToReport()}
|
||||
>
|
||||
<div>
|
||||
<h2 className="text-sm"> خروجی گرفتن از فعالیت ها </h2>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<div className="w-10 h-3 rounded-full bg-secondary-200 opacity-30"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl ">
|
||||
{!!HasPermission("ManageTasks", permissions) && (
|
||||
<div className="flex bg-[#e066150e] rounded-full ">
|
||||
|
|
Loading…
Reference in New Issue