web/src/app/employees/page.jsx

398 lines
14 KiB
React
Raw Normal View History

2023-10-19 11:44:56 +03:30
"use client";
import AppHeader from "@comp/AppHeader/page";
2023-11-14 16:22:32 +03:30
import PositionEmployees from "@comp/EmployeesComponent/Position/page";
2023-10-19 11:44:56 +03:30
import RolesEmployees from "@comp/EmployeesComponent/Roles/page";
import Roles from "@comp/EmployeesComponent/Roles/page";
2023-11-14 16:22:32 +03:30
import SectionEmployees from "@comp/EmployeesComponent/Sections/page";
2023-10-19 11:44:56 +03:30
import UsersEmployees from "@comp/EmployeesComponent/Users/page";
2023-11-14 16:22:32 +03:30
import RoutineEmployees from "@comp/EmployeesComponent/routine/page";
2023-10-19 11:44:56 +03:30
import AppContext from "@ctx/AppContext";
import BottomSheetCreateEmployees from "plugins/BottomSheet/BottomSheetCreateEmployees";
2023-11-14 16:22:32 +03:30
import BottomSheetCreatePosition from "plugins/BottomSheet/BottomSheetCreatePosition";
2023-10-19 11:44:56 +03:30
import BottomSheetCreateRole from "plugins/BottomSheet/BottomSheetCreateRole";
2023-11-14 16:22:32 +03:30
import BottomSheetCreateRoutine from "plugins/BottomSheet/BottomSheetCreateRoutine";
import BottomSheetCreateSection from "plugins/BottomSheet/BottomSheetCreateSection";
2023-11-20 00:07:55 +03:30
import BottomSheetCreateShifts from "plugins/BottomSheet/BottomSheetCreateShifts";
2023-10-19 11:44:56 +03:30
import PersianNumber from "plugins/PersianNumber";
2023-11-14 16:22:32 +03:30
import React, { useContext, useEffect, useState } from "react";
2023-11-20 00:07:55 +03:30
import ShiftsEmployees from "@comp/EmployeesComponent/Shifts/page";
2023-12-12 14:51:25 +03:30
import ParseJwt from "plugins/ParseJwt/page";
import GoBack from "plugins/GoBack/page";
2023-10-19 11:44:56 +03:30
// import second from "@img/test.png";
const Employees = (props) => {
const CTX = useContext(AppContext);
2023-11-14 16:22:32 +03:30
const [activeSection, setActiveSection] = useState(0);
2023-10-19 11:44:56 +03:30
useEffect(() => {
2023-11-14 16:22:32 +03:30
CTX.GetRoutines();
2023-10-19 11:44:56 +03:30
}, []);
2023-11-20 00:07:55 +03:30
const handleGetApi = (num) => {
setActiveSection(num);
switch (num) {
case 0:
if (activeSection != num) {
CTX.GetRoutines();
}
break;
case 1:
if (activeSection != num) {
CTX.GetSections();
}
break;
case 2:
if (activeSection != num) {
CTX.GetPositions();
CTX.GetSections();
2023-11-20 00:07:55 +03:30
}
break;
case 3:
if (activeSection != num) {
CTX.GetUsers();
CTX.GetRoles();
}
break;
case 4:
if (activeSection != num) {
CTX.GetShifts();
CTX.GetRoutines();
}
break;
default:
break;
}
};
// const justLength = CTX.state.justLength;
2023-11-14 16:22:32 +03:30
2023-10-19 11:44:56 +03:30
return (
<div className="pb-20">
<AppHeader
title=" مدیریت کارکنان و نقش ها"
2023-12-12 14:51:25 +03:30
sub=" هسته اصلی تنظیمات مجموعه"
2023-10-19 11:44:56 +03:30
icon2={true}
iconName2="ARROW"
iconHref2="#"
2023-10-19 11:44:56 +03:30
iconEvent2={() => {
GoBack();
2023-10-19 11:44:56 +03:30
}}
/>
2023-11-14 16:22:32 +03:30
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-3 rtl">
<div>
<div
className="flex justify-between mt-7 bg-white rounded-2xl"
2023-11-20 00:07:55 +03:30
onClick={() => handleGetApi(0)}
2023-11-14 16:22:32 +03:30
>
<div className="flex p-2">
<div className="bg-gray-100 rounded-xl p-3 w-fit">
<p className="mb-0 text-center pt-3">
<PersianNumber number={1} style="text-[30px] " />
</p>
</div>
<div className="m-2">
<h4 className="text-base font-bold">
مدیریت روتین های مجموعه
</h4>
<p className="mb-0 text-[10px] opacity-90 ">
شما
<strong className="mx-1 text-primary-300">
2023-11-20 00:07:55 +03:30
{/* <PersianNumber number={routinesData?.length} /> */}
2023-11-14 16:22:32 +03:30
</strong>
روتین فعال دارید
</p>
</div>
</div>
{activeSection == 0 ? (
<div
className="w-[40px] h-[40px] bg-gray-100 shadow-sm rounded-xl m-[15px] "
onClick={() => CTX.setBottomSheetCreateRoutineOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
) : (
<div className="w-[10px] h-[10px] bg-gray-200 shadow-sm rounded-xl m-[15px] "></div>
)}
</div>
{activeSection == 0 && <RoutineEmployees />}
</div>
{/* <div className="flex justify-between mt-3">
2023-10-19 11:44:56 +03:30
<div>
<h4 className="text-base font-bold">مدیریت نقش های مجموعه</h4>
2023-11-14 16:22:32 +03:30
<p className="mb-0 text-[10px] opacity-90 ">
2023-10-19 11:44:56 +03:30
شما
<strong className="mx-1 text-primary-300">
2023-11-14 16:22:32 +03:30
<PersianNumber number={rolesData?.length} />
2023-10-19 11:44:56 +03:30
</strong>
نقش فعال دارید
</p>
</div>
<div
className="w-[40px] h-[40px] bg-white shadow-sm rounded-xl "
onClick={() => CTX.setBottomSheetCreateRoleOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
</div>
2023-11-14 16:22:32 +03:30
<RolesEmployees /> */}
2023-10-19 11:44:56 +03:30
2023-11-14 16:22:32 +03:30
<div>
<div
className="flex justify-between mt-7 bg-white rounded-2xl"
2023-11-20 00:07:55 +03:30
onClick={() => handleGetApi(1)}
2023-11-14 16:22:32 +03:30
>
<div className="flex p-2">
<div className="bg-gray-100 rounded-xl p-3 w-fit">
<p className="mb-0 text-center pt-3">
<PersianNumber number={2} style="text-[30px] " />
</p>
</div>
<div className="m-2">
<h4 className="text-base font-bold">مدیریت سکشن ها مجموعه</h4>
<p className="mb-0 text-[10px] opacity-90 ">
شما
<strong className="mx-1 text-primary-300">
2023-11-20 00:07:55 +03:30
{/* <PersianNumber number={sectionsData?.length} /> */}
2023-11-14 16:22:32 +03:30
</strong>
سکشن فعال دارید
</p>
</div>
</div>
{activeSection == 1 ? (
<div
className="w-[40px] h-[40px] bg-gray-100 shadow-sm rounded-xl m-[15px] "
onClick={() => CTX.setBottomSheetCreateSectionOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
) : (
<div className="w-[10px] h-[10px] bg-gray-200 shadow-sm rounded-xl m-[15px] "></div>
)}
2023-10-19 11:44:56 +03:30
</div>
2023-11-14 16:22:32 +03:30
{activeSection == 1 && <SectionEmployees />}
</div>
2023-10-19 11:44:56 +03:30
2023-11-14 16:22:32 +03:30
<div>
2023-10-19 11:44:56 +03:30
<div
2023-11-14 16:22:32 +03:30
className="flex justify-between mt-7 bg-white rounded-2xl"
2023-11-20 00:07:55 +03:30
onClick={() => handleGetApi(2)}
2023-10-19 11:44:56 +03:30
>
2023-11-14 16:22:32 +03:30
<div className="flex p-2">
<div className="bg-gray-100 rounded-xl p-3 w-fit">
<p className="mb-0 text-center pt-3">
<PersianNumber number={3} style="text-[30px] " />
</p>
</div>
<div className="m-2">
<h4 className="text-base font-bold">
مدیریت پوزیشن های مجموعه
</h4>
<p className="mb-0 text-[10px] opacity-90 ">
شما
<strong className="mx-1 text-primary-300">
2023-11-20 00:07:55 +03:30
{/* <PersianNumber number={positionsData?.length} /> */}
2023-11-14 16:22:32 +03:30
</strong>
پوزیشن فعال دارید
</p>
</div>
</div>
{activeSection == 2 ? (
<div
className="w-[40px] h-[40px] bg-gray-100 shadow-sm rounded-xl m-[15px] "
onClick={() => CTX.setBottomSheetCreatePositionOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
) : (
<div className="w-[10px] h-[10px] bg-gray-200 shadow-sm rounded-xl m-[15px] "></div>
)}
2023-10-19 11:44:56 +03:30
</div>
2023-11-14 16:22:32 +03:30
{activeSection == 2 && <PositionEmployees />}
2023-10-19 11:44:56 +03:30
</div>
2023-11-14 16:22:32 +03:30
<div>
<div
className="flex justify-between mt-7 bg-white rounded-2xl"
2023-11-20 00:07:55 +03:30
onClick={() => handleGetApi(3)}
2023-11-14 16:22:32 +03:30
>
<div className="flex p-2">
<div className="bg-gray-100 rounded-xl p-3 w-fit">
<p className="mb-0 text-center pt-3">
<PersianNumber number={4} style="text-[30px] " />
</p>
</div>
<div className="m-2">
<h4 className="text-base font-bold">مدیریت کارکنان مجموعه</h4>
<p className="mb-0 text-[10px] opacity-90 ">
شما
<strong className="mx-1 text-primary-300">
2023-11-20 00:07:55 +03:30
{/* <PersianNumber number={usersData?.length} /> */}
2023-11-14 16:22:32 +03:30
</strong>
کارمند فعال دارید
</p>
</div>
</div>
{activeSection == 3 ? (
<div
className="w-[40px] h-[40px] bg-gray-100 shadow-sm rounded-xl m-[15px] "
onClick={() => CTX.setBottomSheetCreateEmployeesOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
) : (
<div className="w-[10px] h-[10px] bg-gray-200 shadow-sm rounded-xl m-[15px] "></div>
)}
</div>
{activeSection == 3 && <UsersEmployees />}
</div>
2023-11-20 00:07:55 +03:30
<div>
<div
className="flex justify-between mt-7 bg-white rounded-2xl"
onClick={() => handleGetApi(4)}
>
<div className="flex p-2">
<div className="bg-gray-100 rounded-xl p-3 w-fit">
<p className="mb-0 text-center pt-3">
<PersianNumber number={5} style="text-[30px] " />
</p>
</div>
<div className="m-2">
<h4 className="text-base font-bold">مدیریت شیفت های مجموعه</h4>
<p className="mb-0 text-[10px] opacity-90 ">
شما
<strong className="mx-1 text-primary-300">
{/* <PersianNumber number={shiftsData?.length} /> */}
</strong>
شیفت فعال دارید
</p>
</div>
</div>
{activeSection == 4 ? (
<div
className="w-[40px] h-[40px] bg-gray-100 shadow-sm rounded-xl m-[15px] "
onClick={() => CTX.setBottomSheetCreateShiftsOpen(true)}
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-2 opacity-70"
>
<path
d="M8 1V15M1 8H15"
stroke="#2B2B2B"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
) : (
<div className="w-[10px] h-[10px] bg-gray-200 shadow-sm rounded-xl m-[15px] "></div>
)}
</div>
{activeSection == 4 && <ShiftsEmployees />}
</div>
2023-10-19 11:44:56 +03:30
</div>
2023-11-14 16:22:32 +03:30
{/* <BottomSheetCreateRole /> */}
2023-10-19 11:44:56 +03:30
<BottomSheetCreateEmployees />
2023-11-14 16:22:32 +03:30
<BottomSheetCreateSection />
<BottomSheetCreateRoutine />
<BottomSheetCreatePosition />
2023-11-20 00:07:55 +03:30
<BottomSheetCreateShifts />
2023-10-19 11:44:56 +03:30
</div>
);
};
export default Employees;