Compare commits

...

2 Commits

12 changed files with 1018 additions and 97 deletions

View File

@ -10,4 +10,5 @@ COPY next.config.js ./next.config.js
EXPOSE 3000
ENV PORT 3000
CMD ["node_modules/.bin/next", "start"]
CMD ["/app/node_modules/.bin/next", "start"]

View File

@ -109,7 +109,7 @@ const ShiftCard = () => {
</div>
</div>
<div className="flex flex-wrap px-3 pb-4 pt-2">
{/* <div className="flex flex-wrap px-3 pb-4 pt-2">
{e?.days.map((e) => (
<div className="bg-secondaryLighter-100 rounded-full py-1 px-4 mx-1 mt-2">
<p className="mb-0 text-[11px] white text-secondary-200 font-bold ">
@ -118,7 +118,7 @@ const ShiftCard = () => {
</p>
</div>
))}
</div>
</div> */}
</div>
</>
))}

401
datacalender.js 100644
View File

@ -0,0 +1,401 @@
export const PersianM = (month) => {
console.log("montssh", month);
switch (month) {
case (month = "1"):
return "month";
case (month = "2"):
return "اردیبهشت";
case (month = "3"):
return "خرداد";
case (month = "4"):
return " تیر";
case (month = "5"):
return "آمرداد";
case (month = "6"):
return "شهریور";
case (month = "7"):
return "مهر";
case (month = "8"):
return "آبان";
case (month = "9"):
return "آذر";
case (month = "10"):
return "دی";
case (month = "11"):
return "بهمن";
case (month = "12"):
return "اسفند";
default:
return "ماه";
}
};
export const PersianDay = (dayOfWeek) => {
switch (dayOfWeek) {
case (dayOfWeek = "Sunday"):
return "یکشنبه";
case (dayOfWeek = "Monday"):
return "دوشنبه";
case (dayOfWeek = "Tuesday"):
return "سه شنبه";
case (dayOfWeek = "Wednesday"):
return "چهار شنبه";
case (dayOfWeek = "Thursday"):
return "پنج شنبه";
case (dayOfWeek = "Friday"):
return "جمعه";
case (dayOfWeek = "Saturday"):
return "شنبه";
default:
return null;
}
};
//Solution to find holidays in persian calendar
//https://www.time.ir/fa/eventyear-%D8%AA%D9%82%D9%88%DB%8C%D9%85-%D8%B3%D8%A7%D9%84%DB%8C%D8%A7%D9%86%D9%87
// Array.from(document.querySelectorAll("li[class='eventHoliday ']"),(node=> ({date:'1402/'+( Array.from(document.querySelectorAll("div[class='col-md-12']>div>div>span>span>span"),node=>node.innerText).findIndex(x=>x === node.innerText.split(" ")[1]) +1).toString() +"/"+node.innerText.split(" ")[0].replace(/[۰-۹]/g, d => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d)),description:node.innerText.split(" ").slice(2).join(" ")}) ))
export const holidays = {
y1404: [
{
date: "1404/1/1",
description: "جشن نوروز/جشن سال نو",
},
{
date: "1404/1/2",
description: "عیدنوروز",
},
{
date: "1404/1/2",
description: "شهادت حضرت علی علیه السلام [ ٢١ رمضان ]",
},
{
date: "1404/1/3",
description: "عیدنوروز",
},
{
date: "1404/1/4",
description: "عیدنوروز",
},
{
date: "1404/1/11",
description: "عید سعید فطر [ ١ شوال ]",
},
{
date: "1404/1/12",
description: "روز جمهوری اسلامی",
},
{
date: "1404/1/12",
description: "تعطیل به مناسبت عید سعید فطر [ ٢ شوال ]",
},
{
date: "1404/1/13",
description: "جشن سیزده به در",
},
{
date: "1404/2/4",
description: "شهادت امام جعفر صادق علیه السلام [ ٢٥ شوال ]",
},
{
date: "1404/3/14",
description: "رحلت حضرت امام خمینی",
},
{
date: "1404/3/15",
description: "قیام 15 خرداد",
},
{
date: "1404/3/17",
description: "عید سعید قربان [ ١٠ ذوالحجه ]",
},
{
date: "1404/3/25",
description: "عید سعید غدیر خم [ ١٨ ذوالحجه ]",
},
{
date: "1404/4/14",
description: "تاسوعای حسینی [ ٩ محرم ]",
},
{
date: "1404/4/15",
description: "عاشورای حسینی [ ١٠ محرم ]",
},
{
date: "1404/5/24",
description: "اربعین حسینی [ ٢٠ صفر ]",
},
{
date: "1404/6/1",
description: "رحلت رسول اکرم؛شهادت امام حسن مجتبی علیه السلام [ ٢٨ صفر ]",
},
{
date: "1404/6/2",
description: "شهادت امام رضا علیه السلام [ ٢٩ صفر ]",
},
{
date: "1404/6/10",
description: "شهادت امام حسن عسکری علیه السلام [ ٨ ربيع الاول ]",
},
{
date: "1404/6/19",
description:
"میلاد رسول اکرم و امام جعفر صادق علیه السلام [ ١٧ ربيع الاول ]",
},
{
date: "1404/9/4",
description: "شهادت حضرت فاطمه زهرا سلام الله علیها [ ٣ جمادي الثانيه ]",
},
{
date: "1404/10/13",
description: "ولادت امام علی علیه السلام و روز پدر [ ١٣ رجب ]",
},
{
date: "1404/10/27",
description: "مبعث رسول اکرم (ص) [ ٢٧ رجب ]",
},
{
date: "1404/11/15",
description:
"ولادت حضرت قائم عجل الله تعالی فرجه و جشن نیمه شعبان [ ١٥ شعبان ]",
},
{
date: "1404/11/22",
description: "پیروزی انقلاب اسلامی",
},
{
date: "1404/12/20",
description: "شهادت حضرت علی علیه السلام [ ٢١ رمضان ]",
},
{
date: "1404/12/29",
description: "روز ملی شدن صنعت نفت ایران",
},
],
y1403: [
{
date: "1403/1/1",
description: "جشن نوروز/جشن سال نو",
},
{
date: "1403/1/2",
description: "عیدنوروز",
},
{
date: "1403/1/3",
description: "عیدنوروز",
},
{
date: "1403/1/4",
description: "عیدنوروز",
},
{
date: "1403/1/12",
description: "روز جمهوری اسلامی",
},
{
date: "1403/1/13",
description: "جشن سیزده به در",
},
{
date: "1403/1/13",
description: "شهادت حضرت علی علیه السلام [ ٢١ رمضان ]",
},
{
date: "1403/1/23",
description: "عید سعید فطر [ ١ شوال ]",
},
{
date: "1403/1/24",
description: "تعطیل به مناسبت عید سعید فطر [ ٢ شوال ]",
},
{
date: "1403/2/16",
description: "شهادت امام جعفر صادق علیه السلام [ ٢٥ شوال ]",
},
{
date: "1403/3/14",
description: "رحلت حضرت امام خمینی",
},
{
date: "1403/3/15",
description: "قیام 15 خرداد",
},
{
date: "1403/3/28",
description: "عید سعید قربان [ ١٠ ذوالحجه ]",
},
{
date: "1403/4/5",
description: "عید سعید غدیر خم [ ١٨ ذوالحجه ]",
},
{
date: "1403/4/26",
description: "تاسوعای حسینی [ ٩ محرم ]",
},
{
date: "1403/4/27",
description: "عاشورای حسینی [ ١٠ محرم ]",
},
{
date: "1403/6/4",
description: "اربعین حسینی [ ٢٠ صفر ]",
},
{
date: "1403/6/12",
description: "رحلت رسول اکرم؛شهادت امام حسن مجتبی علیه السلام [ ٢٨ صفر ]",
},
{
date: "1403/6/14",
description: "شهادت امام رضا علیه السلام [ ٣٠ صفر ]",
},
{
date: "1403/6/22",
description: "شهادت امام حسن عسکری علیه السلام [ ٨ ربيع الاول ]",
},
{
date: "1403/6/31",
description:
"میلاد رسول اکرم و امام جعفر صادق علیه السلام [ ١٧ ربيع الاول ]",
},
{
date: "1403/9/15",
description: "شهادت حضرت فاطمه زهرا سلام الله علیها [ ٣ جمادي الثانيه ]",
},
{
date: "1403/10/25",
description: "ولادت امام علی علیه السلام و روز پدر [ ١٣ رجب ]",
},
{
date: "1403/11/9",
description: "مبعث رسول اکرم (ص) [ ٢٧ رجب ]",
},
{
date: "1403/11/22",
description: "پیروزی انقلاب اسلامی",
},
{
date: "1403/11/27",
description:
"ولادت حضرت قائم عجل الله تعالی فرجه و جشن نیمه شعبان [ ١٥ شعبان ]",
},
{
date: "1403/12/29",
description: "روز ملی شدن صنعت نفت ایران",
},
{
date: "1403/12/30",
description: "آخرین روز سال",
},
],
y1402: [
{
date: "1402/1/1",
description: "جشن نوروز/جشن سال نو",
},
{
date: "1402/1/2",
description: "عیدنوروز",
},
{
date: "1402/1/3",
description: "عیدنوروز",
},
{
date: "1402/1/4",
description: "عیدنوروز",
},
{
date: "1402/1/12",
description: "روز جمهوری اسلامی",
},
{
date: "1402/1/13",
description: "جشن سیزده به در",
},
{
date: "1402/1/23",
description: "شهادت حضرت علی علیه السلام [ ٢١ رمضان ]",
},
{
date: "1402/2/2",
description: "عید سعید فطر [ ١ شوال ]",
},
{
date: "1402/2/3",
description: "تعطیل به مناسبت عید سعید فطر [ ٢ شوال ]",
},
{
date: "1402/2/26",
description: "شهادت امام جعفر صادق علیه السلام [ ٢٥ شوال ]",
},
{
date: "1402/3/14",
description: "رحلت حضرت امام خمینی",
},
{
date: "1402/3/15",
description: "قیام 15 خرداد",
},
{
date: "1402/4/8",
description: "عید سعید قربان [ ١٠ ذوالحجه ]",
},
{
date: "1402/4/16",
description: "عید سعید غدیر خم [ ١٨ ذوالحجه ]",
},
{
date: "1402/5/5",
description: "تاسوعای حسینی [ ٩ محرم ]",
},
{
date: "1402/5/6",
description: "عاشورای حسینی [ ١٠ محرم ]",
},
{
date: "1402/6/15",
description: "اربعین حسینی [ ٢٠ صفر ]",
},
{
date: "1402/6/23",
description: "رحلت رسول اکرم؛شهادت امام حسن مجتبی علیه السلام [ ٢٨ صفر ]",
},
{
date: "1402/6/25",
description: "شهادت امام رضا علیه السلام [ ٣٠ صفر ]",
},
{
date: "1402/7/2",
description: "شهادت امام حسن عسکری علیه السلام [ ٨ ربيع الاول ]",
},
{
date: "1402/7/11",
description:
"میلاد رسول اکرم و امام جعفر صادق علیه السلام [ ١٧ ربيع الاول ]",
},
{
date: "1402/9/26",
description: "شهادت حضرت فاطمه زهرا سلام الله علیها [ ٣ جمادي الثانيه ]",
},
{
date: "1402/11/5",
description: "ولادت امام علی علیه السلام و روز پدر [ ١٣ رجب ]",
},
{
date: "1402/11/19",
description: "مبعث رسول اکرم (ص) [ ٢٧ رجب ]",
},
{
date: "1402/11/22",
description: "پیروزی انقلاب اسلامی",
},
{
date: "1402/12/6",
description:
"ولادت حضرت قائم عجل الله تعالی فرجه و جشن نیمه شعبان [ ١٥ شعبان ]",
},
{
date: "1402/12/29",
description: "روز ملی شدن صنعت نفت ایران",
},
],
};

View File

@ -1,6 +1,6 @@
{
"name": "brizco",
"version": "0.1.0",
"version": "0.1.2",
"private": true,
"scripts": {
"dev": "next dev",
@ -14,6 +14,7 @@
"autoprefixer": "10.4.15",
"axios": "^1.5.1",
"boring-avatars": "^1.10.1",
"core-util-is": "^1.0.3",
"framer-motion": "^10.16.1",
"jalali-moment": "^3.3.11",
"next": "13.4.19",

View File

@ -0,0 +1,221 @@
"use client";
import React, { useContext, useEffect, useRef, useState } from "react";
import { BottomSheet } from "react-spring-bottom-sheet";
import Input from "plugins/Input/page";
import AppContext from "@ctx/AppContext";
import SimpleReactValidator from "simple-react-validator";
import { toast } from "react-toastify";
import Buttonbriz from "plugins/Buttonbriz/page";
import DatePickerIran from "plugins/DatePickerIran/page";
import moment from "jalali-moment";
import validateIranPhone from "plugins/IranPhoneRegex";
const jalaliMoment = require("jalali-moment");
const BottomManageShift = (props) => {
const CTX = useContext(AppContext);
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [phoneNumber, setPhoneNumber] = useState("");
const [nationalId, setNationalId] = useState("");
const [gender, setGender] = useState(parseInt(0));
const [birthDate, setBirthDate] = useState(null);
const [roleSelectCurrntData, setRoleSelectCurrntData] = useState("");
const [roleSelectData, setRoleSelectData] = useState([]);
const [, forceUpdate] = 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 rolesChoose = CTX.state.rolesChoose;
const rolesData = CTX.state.rolesData;
const goToEditUser = CTX.state.goToEditUser;
const idEditUser = CTX.state.idEditUser;
const userData = CTX.state.userData;
const body = {
phoneNumber,
firstName,
lastName,
birthDateTimeStamp:
birthDate &&
moment
.utc(
[birthDate.year, birthDate.month, birthDate.day],
"jYYYY-jMM-jDDTHH"
)
.unix(),
gender: parseInt(gender),
nationalId,
roleIds: rolesChoose,
};
const bodyUpdate = {
phoneNumber,
firstName,
lastName,
birthDateTimeStamp:
birthDate &&
moment
.utc(
[birthDate.year, birthDate.month, birthDate.day],
"jYYYY-jMM-jDDTHH"
)
.unix(),
gender: parseInt(gender),
nationalId,
roleIds: rolesChoose,
userId: userData.id,
};
console.log(bodyUpdate);
const clear = () => {
setFirstName("");
setLastName("");
setPhoneNumber("");
setNationalId("");
setGender("");
setBirthDate("");
setRoleSelectCurrntData("");
setRoleSelectData([]);
CTX.setRolesChoose([]);
};
const handleCreateUser = (update) => {
if (validateIranPhone(phoneNumber)) {
if (validator.current.allValid()) {
if (update == "UPDATE") {
CTX.UpdateUser(bodyUpdate);
} else {
CTX.CreateUser(body);
}
} else {
toast.error("پرکردن همه ی فیلد ها واجب است", {
position: "bottom-right",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
validator.current.showMessages();
forceUpdate(1);
}
} else {
toast.error("شماره تماس را درست وارد کنید", {
position: "bottom-right",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
}
};
const deleteRole = (id) => {
CTX.setRolesChoose(rolesChoose.filter((el) => el !== id));
};
const handleBottomSheetCreateEmployeesOpen = (e) => {
setRoleSelectData(
rolesData.map((item) => ({
key: item.persianName,
value: item.id,
}))
);
console.log(idEditUser);
if (e.type == "OPEN") {
CTX.GetRoles();
if (goToEditUser) {
CTX.GetUser(idEditUser);
}
} else if (e.type == "CLOSE") {
clear();
CTX.setGoToEditUser(false);
CTX.setIdEditUser(null);
CTX.setUserData([]);
}
};
useEffect(() => {
if (goToEditUser) {
const date = moment
.unix(userData.birthDateTimeStamp)
.locale("fa")
.format("YYYY/MM/DD")
.split("/");
setFirstName(userData.firstName);
setLastName(userData.lastName);
setPhoneNumber(userData.phoneNumber);
setNationalId(userData.nationalId);
setGender(userData.gender);
setBirthDate({
day: parseInt(date[2]),
month: parseInt(date[1]),
year: parseInt(date[0]),
});
// setRoleSelectCurrntData("");
CTX.setRolesChoose(userData.roleIds);
console.log("userData2", userData);
}
}, [userData]);
return (
<BottomSheet
onSpringStart={(e) => handleBottomSheetCreateEmployeesOpen(e)}
open={CTX.state.BottomManageShiftOpen}
onDismiss={() => CTX.setBottomManageShiftOpen(false)}
blocking={false}
>
<div className="text-center py-2 bg-primary-300 ">
<p className="mb-0 text-white relative top-[-5px]">
تغییر حالت تسک ها یک شیفت خاص
</p>
</div>
<div className="bg-body-100 p-4 ">
<div className="">
<Input
lable="نام "
id="firstName-id"
name="firstName"
type={"text"}
value={firstName}
inputEvent={(e) => {
setFirstName(e.target.value);
validator.current.showMessageFor("firstName");
}}
style="text-right"
validator={true}
validatorData={validator.current.message(
"firstName",
firstName,
"required"
)}
/>
</div>
</div>
</BottomSheet>
);
};
export default BottomManageShift;

View File

@ -15,23 +15,12 @@ const BottomSheetCreateShifts = (props) => {
const [dayOfWeeksCurrent, setDayOfWeeksCurrent] = useState("");
const [, forceUpdate] = useState();
const dayOfWeeksChoose = CTX.state.dayOfWeeksChoose;
const startAtTimeShift = CTX.state.startAtTimeShift;
const endAtTimeShift = CTX.state.endAtTimeShift;
const goToEditShift = CTX.state.goToEditShift;
const idEditShift = CTX.state.idEditShift;
const shiftData = CTX.state.shiftData;
const week = [
{ key: "شنبه", value: 6 },
{ key: "یکشنبه", value: 0 },
{ key: "دوشنبه", value: 1 },
{ key: "سه شنبه", value: 2 },
{ key: "چهار شنبه", value: 3 },
{ key: "پنج شنبه", value: 4 },
{ key: "جمعه", value: 5 },
];
const validator = useRef(
new SimpleReactValidator({
messages: {
@ -53,7 +42,6 @@ const BottomSheetCreateShifts = (props) => {
setTitle("");
// CTX.setEndAtTimeShift(["00", "00"]);
// CTX.setStartAtTimeShift(["00", "00"]);
CTX.setdayOfWeeksChoose([]);
};
const body = {
@ -61,7 +49,6 @@ const BottomSheetCreateShifts = (props) => {
description,
endAt: endAtTimeShift[0] + ":" + endAtTimeShift[1] + ":00",
startAt: startAtTimeShift[0] + ":" + startAtTimeShift[1] + ":00",
dayOfWeeks: dayOfWeeksChoose,
};
const bodyUpdate = {
@ -69,7 +56,6 @@ const BottomSheetCreateShifts = (props) => {
description,
endAt: endAtTimeShift[0] + ":" + endAtTimeShift[1] + ":00",
startAt: startAtTimeShift[0] + ":" + startAtTimeShift[1] + ":00",
dayOfWeeks: dayOfWeeksChoose,
id: shiftData.id,
};
@ -96,11 +82,6 @@ const BottomSheetCreateShifts = (props) => {
}
};
const deleteRole = (value) => {
console.log(value);
CTX.setDayOfWeeksChoose(dayOfWeeksChoose.filter((el) => el !== value));
};
console.log(body);
const handleBottomSheetCreateShift = (e) => {
@ -128,8 +109,6 @@ const BottomSheetCreateShifts = (props) => {
shiftData.endAt.split(":")[0],
shiftData.endAt.split(":")[1],
]);
CTX.setDayOfWeeksChoose(shiftData.days);
}
}, [shiftData]);
@ -218,60 +197,6 @@ const BottomSheetCreateShifts = (props) => {
/>
</div>
<div className="">
<Input
lable="انتخاب روز"
id="dayOfWeeksCurrent-id"
name="dayOfWeeksCurrent"
type={"text"}
value={dayOfWeeksCurrent}
inputEvent={(e) => {
setDayOfWeeksCurrent(e.target.value);
if (!!dayOfWeeksChoose.find((b) => b == e.target.value)) {
toast.error("روز تکراری است", {
position: "bottom-right",
closeOnClick: true,
});
} else {
CTX.setDayOfWeeksChoose((current) => [
...current,
parseInt(e.target.value),
]);
}
}}
style="text-right"
select={true}
selectData={[
{ key: "شنبه", value: parseInt(6) },
{ key: "یکشنبه", value: 0 },
{ key: "دوشنبه", value: 1 },
{ key: "سه شنبه", value: 2 },
{ key: "چهار شنبه", value: 3 },
{ key: "پنج شنبه", value: 4 },
{ key: "جمعه", value: 5 },
]}
/>
<div className="flex flex-wrap mt-3 rtl">
{dayOfWeeksChoose &&
dayOfWeeksChoose.map((e) => (
<div className="flex bg-gray-300 p-1 rounded-full m-1 justify-start">
<div
className="w-[30px] h-[30px] rounded-full bg-gray-400 "
onClick={() => deleteRole(e)}
></div>
<div>
<p className="mb-0 px-3 text-sm mt-1">
{week?.find((b) => b.value == e).key}
</p>
</div>
</div>
))}
</div>
</div>
<div className="">
<Input
lable=" توضیحات"

View File

@ -20,6 +20,9 @@ dependencies:
boring-avatars:
specifier: ^1.10.1
version: 1.10.1
core-util-is:
specifier: ^1.0.3
version: 1.0.3
framer-motion:
specifier: ^10.16.1
version: 10.16.1(react-dom@18.2.0)(react@18.2.0)
@ -728,6 +731,13 @@ packages:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: false
<<<<<<< HEAD
/core-util-is@1.0.3:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
dev: false
=======
>>>>>>> e41e593cde5b6163efe27a5dd7b6af11013cad88
/css-loader@6.8.1(webpack@5.89.0):
resolution: {integrity: sha512-xDAXtEVGlD0gJ07iclwWVkLoZOpEvAWaSyf6W18S2pOC//K8+qUDIx8IIT3D+HjnmkJPQeesOPv5aiUaJsCM2g==}
engines: {node: '>= 12.13.0'}

View File

@ -17,6 +17,7 @@ import "react-toastify/dist/ReactToastify.css";
import Loading from "plugins/Loading/page";
import Chapar, { getToken } from "plugins/Chapar";
import TimePicker from "plugins/TimePicker/page";
import axios from "axios";
const inter = Inter({ subsets: ["latin"] });
@ -36,6 +37,8 @@ export default function RootLayout({ children }) {
const [BottomSheetCreateShiftsOpen, setBottomSheetCreateShiftsOpen] =
useState(false);
const [BottomManageShiftOpen, setBottomManageShiftOpen] = useState(false);
// BigPlus
const [BigPlusOpen, setBigPlusOpen] = useState(false);
const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false);
@ -68,7 +71,6 @@ export default function RootLayout({ children }) {
const [idEditUser, setIdEditUser] = useState(null);
// shift
const [dayOfWeeksChoose, setDayOfWeeksChoose] = useState([]);
const [startAtTimeShift, setStartAtTimeShift] = useState(["00", "00"]);
const [endAtTimeShift, setEndAtTimeShift] = useState(["00", "00"]);
const [shiftsData, setShiftsData] = useState([null]);
@ -76,6 +78,9 @@ export default function RootLayout({ children }) {
const [goToEditShift, setGoToEditShift] = useState(false);
const [idEditShift, setIdEditShift] = useState(null);
// shift manage-shift
const [searchUserChoose, setSearchUserChoose] = useState([]);
// TimePicker
const [openTimePicker, setOpenTimePicker] = useState(false);
const [TimePickerOrder, setTimePickerOrder] = useState(null);
@ -639,7 +644,6 @@ export default function RootLayout({ children }) {
idEditUser,
goToEditUser,
userData,
dayOfWeeksChoose,
openTimePicker,
endAtTimeShift,
startAtTimeShift,
@ -649,6 +653,8 @@ export default function RootLayout({ children }) {
goToEditShift,
shiftData,
profile,
searchUserChoose,
BottomManageShiftOpen,
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
@ -686,7 +692,6 @@ export default function RootLayout({ children }) {
DeleteUser,
GetUser,
UpdateUser,
setDayOfWeeksChoose,
setOpenTimePicker,
setEndAtTimeShift,
setStartAtTimeShift,
@ -702,6 +707,8 @@ export default function RootLayout({ children }) {
DeleteShift,
setProfile,
CheckUser,
setSearchUserChoose,
setBottomManageShiftOpen,
}}
>
<html lang="en">

View File

@ -10,6 +10,8 @@ import core from "../../public/images/core.png";
import { useEffect, useState } from "react";
import PersianNumber from "../../plugins/PersianNumber";
import UnderDevelopeTimer from "../../components/UnderDevelopeTimer";
import { version } from "../../package.json";
import Link from "next/link";
export default function Home() {
const [state, setstate] = useState(false);
@ -19,7 +21,7 @@ export default function Home() {
}, []);
return (
<div className="h-[100vh] overflow-hidden relative ">
<div className="h-[100vh] overflow-hidden relative bg-info-100">
<div className="flex justify-center">
<div
className={`relative z-50 ${
@ -66,15 +68,16 @@ export default function Home() {
</div>
<motion.div animate={{ y: [0, -130] }} transition={{ duration: 3 }}>
<div className="text-center">
<h3 className="font-bold text-2xl text-gray-700 rtl">
کارگران مشغول کارند
<br />
<PersianNumber number={30} size={30} />
<h3 className="font-bold text-2xl text-gray-700 rtl text-white">
تا اینجا ورژن <br />
{" "}
شهریــــــــــــــــــــــور میبینمتون
</h3>
<UnderDevelopeTimer />
<Link href={"/login"}>
<p className="mb-0 mt-5 text-white ">
<PersianNumber number={version} style="text-[40px] font-bold" />
</p>
</Link>
</div>
</motion.div>
</div>

View File

@ -0,0 +1,337 @@
"use client";
import React, { useContext, useEffect, useState } from "react";
import moment from "jalali-moment";
import "moment/locale/fa"; // Set the locale to Farsi (Persian)
import AppHeader from "@comp/AppHeader/page";
import { Swiper, SwiperSlide } from "swiper/react";
import PersianNumber from "plugins/PersianNumber";
import { PersianD, PersianDay, PersianM, holidays } from "datacalender";
import AppContext from "@ctx/AppContext";
import Input from "plugins/Input/page";
import { toast } from "react-toastify";
import Avatar from "boring-avatars";
import BottomManageShift from "plugins/BottomSheet/BottomManageShift";
const Calendar = () => {
const CTX = useContext(AppContext);
const shiftsData = CTX.state.shiftsData;
const searchUserChoose = CTX.state.searchUserChoose;
const usersData = CTX.state.usersData;
console.log("usersData", usersData);
const [searchUserCurrntData, setSearchUserCurrntData] = useState([]);
const [daysUntilEnd, setDaysUntilEnd] = useState([]);
const [selectDay, setSelectDay] = useState(null);
const [selectShift, setselectShift] = useState(0);
const [manageShiftEmployeesData, setManageShiftEmployeesData] = useState([]);
const today = moment().format("jYYYY/jM/jD"); // Get the current Jalali date
const todayJustDay = moment().format("jD"); // Get the current Jalali date
// Find the end of the current month
const endOfMonth = moment(today, "jYYYY/jM/jD").endOf("jMonth");
const daysInCurrentMonth = moment(today, "jYYYY/jM/jD")
.endOf("jMonth")
.jDate();
const daysEndOfMonth = () => {
const days = [];
for (let i = -1; i < daysInCurrentMonth - todayJustDay + 1; i++) {
const currentDate = moment(today, "jYYYY/jM/jD").add(i, "days");
const isToday = currentDate.isSame(moment(), "day");
days.push({
checkDay: currentDate.format("jYYYY/jM/jD"),
date: currentDate.format("jD / jM"),
dayOfWeek: currentDate.format("dddd"),
today: isToday, // Set today: true if it's the current date
});
}
return setDaysUntilEnd(days);
};
console.log("daysUntilEnd", daysUntilEnd[selectDay]);
const handleManageShiftEmployeesOpen = (e) => {
setManageShiftEmployeesData(
usersData.map((item) => ({
key:
item.firstName +
" " +
item.lastName +
"( " +
item.roleNames[0] +
" )",
value: item.userId,
}))
);
};
const deleteSearchUser = (id) => {
CTX.setSearchUserChoose(searchUserChoose.filter((el) => el !== id));
};
useEffect(() => {
daysEndOfMonth();
setSelectDay(1);
CTX.GetShifts();
CTX.GetUsers();
}, []);
useEffect(() => {
// if (!!CTX.GetUsers()) {
//
// }
handleManageShiftEmployeesOpen();
}, [usersData]);
console.log("searchUserChooseqqqqqqqqqqqqqqqqqqqqqqqqq", searchUserChoose);
console.log(daysUntilEnd);
return (
<div className="pb-20">
<AppHeader
title=" شیفت بندی های هفتگی"
sub={`شیفت بندی
تا
${daysInCurrentMonth}
${PersianM(moment().format("jM"))}
`}
icon2={true}
iconName2="ARROW"
iconHref2="/home"
/>
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-4 rtl">
<Swiper
spaceBetween={10}
slidesPerView={4.3}
onSlideChange={() => console.log("slide change")}
onSwiper={(swiper) => console.log(swiper)}
>
{daysUntilEnd?.map((e, index) => (
<SwiperSlide>
<div
className={`h-[70px] tr03 ${
selectDay == index ? "bg-white rounded-xl" : " opacity-70"
}`}
key={index}
onClick={() => {
setSelectDay(index);
console.log(index);
}}
>
<div className="py-2">
<p className="mb-0 text-center ">
<PersianNumber
number={e.date}
style={`text-[20px] ${
selectDay == index
? "font-bold"
: !!holidays.y1402?.find((b) => b.date == e.checkDay)
? "text-red-500"
: ""
} `}
/>
</p>
</div>
<div
className={`w-fit mx-auto sahdow px-1 rounded-full ${
selectDay == index
? "bg-secondary-100 text-gray-100"
: !!holidays.y1402?.find((b) => b.date == e.checkDay)
? "bg-transparent text-red-500"
: "bg-white text-gray-500"
}`}
>
<p className="mb-0 text-center text-sm ">
{/* {PersianD.find((i) => i == e.dayOfWeek)} */}
{PersianDay(e.dayOfWeek)}
</p>
</div>
</div>
</SwiperSlide>
))}
</Swiper>
</div>
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden rtl">
{shiftsData.length > 0 ? (
<div
className="flex overflow-auto whitespace-nowrap"
id="swich-shifts"
>
{shiftsData.map((e, index) => (
<div
className={` shadow-sm relative block max-w-max mx-2 rounded-full mt-2 px-4 py-2 ${
selectShift == index
? "bg-secondary-100 text-white"
: "bg-white opacity-60"
}`}
onClick={() => setselectShift(index)}
>
<p className="mb-0">{e?.title}</p>
</div>
))}
</div>
) : (
<div className="flex justify-center py-5">
<div className="bg-white shadow mt-5 w-fit rounded-full p-4">
چیزی یافت نشد
</div>
</div>
)}
</div>
<div className="bg-white relative top-[15px] rounded-t-3xl p-4 rtl pt-6 h-screen sm:h-auto ">
<div className="mx-3 flex justify-center">
<div className=" bg-gray-100 rounded-xl w-fit mr-0 p-3">
<p className="mb-0 text-right text-sm rtl opacity-80">
ویرایش برای{" "}
<small className=" text-sm font-bold">
{shiftsData && shiftsData[selectShift]?.title}
</small>{" "}
تاریخ{" "}
<small className=" text-sm font-bold text-primary-300 bg-white px-2 rounded-full">
<PersianNumber
number={daysUntilEnd && daysUntilEnd[selectDay]?.checkDay}
/>
</small>{" "}
میباشد
</p>
</div>
</div>
<div className=" m-1">
<Input
lable="جستجوی افراد"
id="SearchUser-id"
name="SearchUser"
type={"text"}
value={searchUserCurrntData}
inputEvent={(e) => {
setSearchUserCurrntData(e.target.value);
if (!!searchUserChoose.find((b) => b == e.target.value)) {
toast.error("نقش تکراری است", {
position: "bottom-right",
closeOnClick: true,
});
} else {
CTX.setSearchUserChoose((current) => [
...current,
e.target.value,
]);
}
}}
style="text-right"
// validatorData={validator.current.message(
// "phoneNumber",
// phoneNumber,
// "required"
// )}
select={true}
selectData={manageShiftEmployeesData}
theme={1}
/>
</div>
<div
className={`flex j flex-wrap mt-3 rtl ${
searchUserChoose.length > 0 ? "" : "justify-center"
}`}
>
{searchUserChoose.length > 0 ? (
searchUserChoose.map((e) => (
<div className="flex bg-gray-100 p-1 rounded-full m-1 justify-start">
<div
className="w-[30px] h-[30px] rounded-full bg-gray-400 "
onClick={() => deleteSearchUser(e)}
>
<Avatar
size={30}
name={usersData.find((b) => b.userId == e)?.firstName}
variant="beam"
colors={["#9d9f88", "#83af96", "#b2de93"]}
/>
</div>
<div>
<p className="mb-0 px-3 text-sm mt-1">
{usersData.find((b) => b.userId == e)?.firstName}
</p>
</div>
</div>
))
) : (
<div className="flex justify-center py-5">
<div className="bg-white shadow mt-5 w-fit rounded-full p-4">
چیزی یافت نشد
</div>
</div>
)}
</div>
<div className="flex jc mt-10">
<button className="btn btn-primary inline-block w-full">
{" "}
ثبت نهایی شیفت
</button>
<button
className="btn bg-transparent border-[2px] border-info-100 border-dashed text-info-100 text-[12px] mx-2 w-full"
onClick={() => CTX.setBottomManageShiftOpen(true)}
>
تغییر حالت تسک ها{" "}
</button>
</div>
</div>
<BottomManageShift />
</div>
);
};
export default Calendar;
{
/* {shiftsData.map((e, index) => (
<div
className={`bg-gray-200 p-5 rounded-3xl relative w-full pb-20 border-[4px] border-white !z-[${index}] `}
style={{ top: `${27 * (shiftsData.length - 1 - index)}px` }}
>
<div className="flex rtl">
<div className="w-[40px] h-[40px] bg-primary-300 rounded-full">
<svg
width="15"
height="15"
viewBox="0 0 150 88"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="mx-auto mt-[10px]"
>
<path
d="M137.5 75L75 12.5L12.5 75"
stroke="white"
stroke-width="25"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
<div className="mx-3 ">
<p className="mb-0 font-bold text-xl text-right">{e?.title}</p>
<p className="mb-0 text-sm text-right">
{e?.title} {}
</p>
</div>
</div>
</div>
))} */
}

View File

@ -3,6 +3,7 @@
import AppHeader from "@comp/AppHeader/page";
import ShiftCard from "@comp/ShiftComponent/ShiftCard/page";
import AppContext from "@ctx/AppContext";
import Link from "next/link";
import BottomSheetCreateShifts from "plugins/BottomSheet/BottomSheetCreateShifts";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect } from "react";
@ -43,14 +44,18 @@ const Shifts = (props) => {
نمایید و با توجه به نیاز های مجموعه خود شیفت بندی کنید .{" "}
</p>
<div className="flex my-3">
<button className="btn btn-secondary text-[12px] w-full">
{" "}
شیفت بندی هفته
</button>
<button className="btn bg-transparent border-[2px] border-white border-dashed text-white text-[12px] mx-2 w-full">
{" "}
شیفت بندی هغته بعد
</button>
<Link href={"/shifts/manage-shift"} className="w-full">
<button className="btn btn-secondary text-[12px] w-full">
{" "}
شیفت بندی هفته
</button>
</Link>
<Link href={"/shifts/manage-shift"} className="w-full">
<button className="btn bg-transparent border-[2px] border-white border-dashed text-white text-[12px] mx-2 w-full">
{" "}
شیفت بندی هغته بعد
</button>
</Link>
</div>
</div>
</div>

View File

@ -204,3 +204,13 @@ body {
inherits: true;
initial-value: 0turn;
}
#swich-shifts::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
#swich-shifts {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}