134 lines
6.4 KiB
JavaScript
134 lines
6.4 KiB
JavaScript
"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 = ({ tasksData, permissions }) => {
|
|
const CTX = useContext(AppContext);
|
|
const router = useRouter();
|
|
|
|
const goToEditTask = (id) => {
|
|
if (!!HasPermission("ManageTasks", permissions)) {
|
|
CTX.setGoToEditTask(true);
|
|
CTX.GetTask(id);
|
|
CTX.setIdEditTask(id);
|
|
CTX.setBottomSheetCreateTaskOpen(true);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
{tasksData?.map((e, index) => (
|
|
<div className="bg-gray-100 shadow-sm rounded-xl mx-2 my-2 p-2">
|
|
<div className="flex justify-between">
|
|
<div className="flex whitespace-nowrap overflow-auto w-10/12">
|
|
{/* <div className=" w-fit relative px-2 text-[12px] my-2 mx-1 rounded-3xl text-primary-300 bg-red-200 px-2">
|
|
<PersianNumber number={index + 1} />
|
|
</div> */}
|
|
|
|
<div className="flex">
|
|
<div className="relative pr-2 text-[11px] text-primary-500">
|
|
{e?.scheduleType == 0
|
|
? "روزانه"
|
|
: e?.scheduleType == 1
|
|
? "هفتگی"
|
|
: e?.scheduleType == 2
|
|
? "مخصوص"
|
|
: ""}
|
|
</div>
|
|
|
|
<div className="w-[2px] h-3 mx-1 bg-primary-200 opacity-75 mt-[2px]"></div>
|
|
|
|
<div className=" w-fit relative text-[11px] text-secondary-800 h-fit">
|
|
{e?.shifts[0]}
|
|
</div>
|
|
{e?.days?.length > 0 && (
|
|
<>
|
|
{e?.days.map((s) => (
|
|
<>
|
|
<div className="w-[2px] h-3 mx-1 bg-primary-200 opacity-75 mt-[2px]"></div>
|
|
<div className=" w-fit relative text-[11px] text-primary-600 h-fit ">
|
|
{" "}
|
|
{s}
|
|
</div>
|
|
</>
|
|
))}
|
|
</>
|
|
)}
|
|
</div>
|
|
|
|
<div className="w-[2px] h-3 mx-1 bg-primary-200 opacity-75 mt-[2px]"></div>
|
|
|
|
<div className=" w-fit relative text-[11px] text-secondary-950 h-fit ">
|
|
{" "}
|
|
{e?.positions[0]}
|
|
</div>
|
|
</div>
|
|
{HasPermission("ManageShifts", permissions) && (
|
|
<div className="w-1/12">
|
|
<div
|
|
className="w-[22px] h-[22px] bg-secondary-950 rounded-full relative pt-1"
|
|
onClick={() => goToEditTask(e.id)}
|
|
>
|
|
<svg
|
|
width="12"
|
|
height="12"
|
|
viewBox="0 0 18 18"
|
|
fill="none"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
className="mx-auto"
|
|
>
|
|
<g clip-path="url(#clip0_72_994)">
|
|
<path
|
|
d="M11.4653 2.36397L10.77 3.05922L4.37926 9.44922C3.94651 9.88272 3.72976 10.0995 3.54376 10.338C3.32409 10.6194 3.13573 10.924 2.98201 11.2462C2.85226 11.5192 2.75551 11.8102 2.56201 12.3907L1.74151 14.8515L1.54051 15.453C1.4935 15.5932 1.48652 15.7437 1.52037 15.8877C1.55422 16.0316 1.62755 16.1633 1.73212 16.2679C1.83669 16.3724 1.96835 16.4458 2.1123 16.4796C2.25626 16.5135 2.4068 16.5065 2.54701 16.4595L3.14851 16.2585L5.60926 15.438C6.19051 15.2445 6.48076 15.1477 6.75376 15.018C7.07626 14.8642 7.38076 14.676 7.66201 14.4562C7.90051 14.2702 8.11726 14.0535 8.55001 13.6207L14.9408 7.22997L15.636 6.53472C16.1891 5.98165 16.4998 5.23152 16.4998 4.44935C16.4998 3.66718 16.1891 2.91705 15.636 2.36397C15.0829 1.8109 14.3328 1.50018 13.5506 1.50018C12.7685 1.50018 12.0183 1.8109 11.4653 2.36397Z"
|
|
stroke="black"
|
|
stroke-width="1.5"
|
|
/>
|
|
<path
|
|
d="M11.4653 2.36397L10.77 3.05922L4.37926 9.44922C3.94651 9.88272 3.72976 10.0995 3.54376 10.338C3.32409 10.6194 3.13573 10.924 2.98201 11.2462C2.85226 11.5192 2.75551 11.8102 2.56201 12.3907L1.74151 14.8515L1.54051 15.453C1.4935 15.5932 1.48652 15.7437 1.52037 15.8877C1.55422 16.0316 1.62755 16.1633 1.73212 16.2679C1.83669 16.3724 1.96835 16.4458 2.1123 16.4796C2.25626 16.5135 2.4068 16.5065 2.54701 16.4595L3.14851 16.2585L5.60926 15.438C6.19051 15.2445 6.48076 15.1477 6.75376 15.018C7.07626 14.8642 7.38076 14.676 7.66201 14.4562C7.90051 14.2702 8.11726 14.0535 8.55001 13.6207L14.9408 7.22997L15.636 6.53472C16.1891 5.98165 16.4998 5.23152 16.4998 4.44935C16.4998 3.66718 16.1891 2.91705 15.636 2.36397C15.0829 1.8109 14.3328 1.50018 13.5506 1.50018C12.7685 1.50018 12.0183 1.8109 11.4653 2.36397Z"
|
|
stroke="white"
|
|
stroke-width="1.5"
|
|
/>
|
|
<g opacity="0.5">
|
|
<path
|
|
d="M10.77white 3.05847C10.77 3.05847 10.857 4.53597 12.1605 5.83947C13.464 7.14297 14.9408 7.22922 14.9408 7.22922M3.14852 16.2585L1.74152 14.85"
|
|
stroke="white"
|
|
stroke-width="1.5"
|
|
/>
|
|
<path
|
|
d="M10.77 3.05847C10.77 3.05847 10.857 4.53597 12.1605 5.83947C13.464 7.14297 14.9408 7.22922 14.9408 7.22922M3.14852 16.2585L1.74152 14.85"
|
|
stroke="white"
|
|
stroke-width="1.5"
|
|
/>
|
|
</g>
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_72_994">
|
|
<rect width="18" height="18" fill="white" />
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div className=" relative m-1 text-white">
|
|
<div className="text-right max-h-[40px] overflow-hidden">
|
|
<h4 className="mb-0 text-secondary-950 font-medium text-[12px] relative w-full ellipsis">
|
|
{e?.title}{" "}
|
|
</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TasksCard;
|