diff --git a/brizco.rar b/brizco.rar new file mode 100644 index 0000000..b3a9379 Binary files /dev/null and b/brizco.rar differ diff --git a/components/AppHeader/page.jsx b/components/AppHeader/page.jsx index 180160d..f4f6654 100644 --- a/components/AppHeader/page.jsx +++ b/components/AppHeader/page.jsx @@ -1,3 +1,4 @@ +import Avatar from "boring-avatars"; import Link from "next/link"; import React from "react"; @@ -13,6 +14,7 @@ const AppHeader = ({ iconHref2, iconEvent2, userIcon, + userIconData, }) => { const icons = [ { @@ -95,7 +97,16 @@ const AppHeader = ({
{userIcon && ( -
+
+
+ +
+
)}

{title}

diff --git a/components/EmployeesComponent/Users/page.jsx b/components/EmployeesComponent/Users/page.jsx index 1376768..ac08a04 100644 --- a/components/EmployeesComponent/Users/page.jsx +++ b/components/EmployeesComponent/Users/page.jsx @@ -3,6 +3,7 @@ import AppContext from "@ctx/AppContext"; import React, { useContext } from "react"; import Avatar from "boring-avatars"; +import PersianNumber from "plugins/PersianNumber"; const UsersEmployees = () => { const CTX = useContext(AppContext); @@ -34,7 +35,13 @@ const UsersEmployees = () => {

{e.firstName}{" "}

-

صندوق دار

+

+ {e.roleNames.length > 0 + ? e.roleNames.length <= 1 + ? e.roleNames[0] + : e.roleNames[0] + " ......" + : "هیچی پیدا نمیشه براش ...."} +

{ }; return ( -
+
{/*
*/} diff --git a/components/ShiftComponent/ShiftCard/page.jsx b/components/ShiftComponent/ShiftCard/page.jsx new file mode 100644 index 0000000..9adcb0d --- /dev/null +++ b/components/ShiftComponent/ShiftCard/page.jsx @@ -0,0 +1,137 @@ +"use client"; + +import AppContext from "@ctx/AppContext"; +import { DaysOfWeek } from "plugins/DaysOfWeek/page"; +import PersianNumber from "plugins/PersianNumber"; +import { getTimeOfDay } from "plugins/TimeOfDay/page"; +import React, { useContext } from "react"; + +const ShiftCard = () => { + const CTX = useContext(AppContext); + const shiftsData = CTX.state.shiftsData; + + const goToEditUser = (id) => { + CTX.setGoToEditShift(true); + CTX.setBottomSheetCreateShiftsOpen(true); + CTX.setIdEditShift(id); + }; + + return ( + <> + {shiftsData.length > 0 ? ( + <> + {shiftsData && + shiftsData.map((e) => ( + <> +
+
+
+

+ {e?.title}{" "} +

+
+
goToEditUser(e.id)} + > + + + + + + + + + + + + + + + +
+
+ +
+
+

+ شروع : + + + + {getTimeOfDay(e?.startAt?.split(":")[0])} +

+ +

+ پایان : + + + + + + {getTimeOfDay(e?.endAt?.split(":")[0])} +

+
+
+ +
+ {e?.days.map((e) => ( +
+

+ {" "} + {DaysOfWeek(e)}{" "} +

+
+ ))} +
+
+ + ))} + + ) : ( +
+
+ چیزی یافت نشد +
+
+ )} + + ); +}; + +export default ShiftCard; diff --git a/package.json b/package.json index 4cab874..b849cc5 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "postcss": "8.4.28", "react": "18.2.0", "react-dom": "18.2.0", + "react-duration-picker": "^1.1.1", "react-modern-calendar-datepicker": "^3.1.6", "react-persian-datepicker": "^3.0.2", "react-spring-bottom-sheet": "^3.4.1", diff --git a/plugins/BottomSheet/BottomSheetCreateEmployees.jsx b/plugins/BottomSheet/BottomSheetCreateEmployees.jsx index 5ae4e95..3b111ee 100644 --- a/plugins/BottomSheet/BottomSheetCreateEmployees.jsx +++ b/plugins/BottomSheet/BottomSheetCreateEmployees.jsx @@ -184,6 +184,7 @@ const BottomSheetCreateEmployees = (props) => { onSpringStart={(e) => handleBottomSheetCreateEmployeesOpen(e)} open={CTX.state.BottomSheetCreateEmployeesOpen} onDismiss={() => CTX.setBottomSheetCreateEmployeesOpen(false)} + blocking={false} >

افزودن کاربر جدید

@@ -254,6 +255,7 @@ const BottomSheetCreateEmployees = (props) => { setBirthDate(e)} date={birthDate} + zindex="z-[1000]" />
diff --git a/plugins/BottomSheet/BottomSheetCreateRole.jsx b/plugins/BottomSheet/BottomSheetCreateRole.jsx index 7c6f4a1..a7ecd84 100644 --- a/plugins/BottomSheet/BottomSheetCreateRole.jsx +++ b/plugins/BottomSheet/BottomSheetCreateRole.jsx @@ -109,6 +109,7 @@ const BottomSheetCreateRole = (props) => { onSpringStart={(e) => handleBottomSheetCreateRole(e)} open={CTX.state.BottomSheetCreateRoleOpen} onDismiss={() => CTX.setBottomSheetCreateRoleOpen(false)} + blocking={false} >

افزودن نقش جدید

diff --git a/plugins/BottomSheet/BottomSheetCreateShifts.jsx b/plugins/BottomSheet/BottomSheetCreateShifts.jsx index d001059..99aa449 100644 --- a/plugins/BottomSheet/BottomSheetCreateShifts.jsx +++ b/plugins/BottomSheet/BottomSheetCreateShifts.jsx @@ -1,17 +1,144 @@ "use client"; -import React, { useContext } from "react"; +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"; const BottomSheetCreateShifts = (props) => { const CTX = useContext(AppContext); + const [title, setTitle] = useState(""); + const [description, setDescription] = useState(""); + 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: { + required: "پر کردن این فیلد الزامی میباشد", + }, + element: (message) => ( + <> +
+ {message} +
+ + ), + }) + ); + + const clear = () => { + setDayOfWeeksCurrent(""); + setDescription(""); + setTitle(""); + // CTX.setEndAtTimeShift(["00", "00"]); + // CTX.setStartAtTimeShift(["00", "00"]); + CTX.setdayOfWeeksChoose([]); + }; + + const body = { + title, + description, + endAt: endAtTimeShift[0] + ":" + endAtTimeShift[1] + ":00", + startAt: startAtTimeShift[0] + ":" + startAtTimeShift[1] + ":00", + dayOfWeeks: dayOfWeeksChoose, + }; + + const bodyUpdate = { + title, + description, + endAt: endAtTimeShift[0] + ":" + endAtTimeShift[1] + ":00", + startAt: startAtTimeShift[0] + ":" + startAtTimeShift[1] + ":00", + dayOfWeeks: dayOfWeeksChoose, + id: shiftData.id, + }; + + const handleCreateShift = (update) => { + if (validator.current.allValid()) { + if (update == "UPDATE") { + CTX.UpdateShift(bodyUpdate); + } else { + CTX.CreateShift(body); + } + } else { + toast.error("پرکردن همه ی فیلد ها واجب است", { + position: "bottom-right", + autoClose: 2000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + }); + + validator.current.showMessages(); + forceUpdate(1); + } + }; + + const deleteRole = (value) => { + console.log(value); + CTX.setDayOfWeeksChoose(dayOfWeeksChoose.filter((el) => el !== value)); + }; + + console.log(body); + + const handleBottomSheetCreateShift = (e) => { + if (e.type == "OPEN") { + if (goToEditShift) { + CTX.GetShift(idEditShift); + } + } else if (e.type == "CLOSE") { + CTX.setGoToEditShift(false); + CTX.setIdEditShift(null); + CTX.setShiftData([]); + // clear(); + } + }; + + useEffect(() => { + if (goToEditShift) { + setTitle(shiftData.title); + setDescription(shiftData.description); + CTX.setStartAtTimeShift([ + shiftData.startAt.split(":")[0], + shiftData.startAt.split(":")[1], + ]); + CTX.setEndAtTimeShift([ + shiftData.endAt.split(":")[0], + shiftData.endAt.split(":")[1], + ]); + + CTX.setDayOfWeeksChoose(shiftData.days); + } + }, [shiftData]); return ( handleBottomSheetCreateShift(e)} open={CTX.state.BottomSheetCreateShiftsOpen} onDismiss={() => CTX.setBottomSheetCreateShiftsOpen(false)} + blocking={false} >

@@ -22,100 +149,162 @@ const BottomSheetCreateShifts = (props) => {

{ + setTitle(e.target.value); + validator.current.showMessageFor("title"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "title", + title, + "required" + )} />
{ + validator.current.showMessageFor("startAt"); + }} + inputFocus={() => { + CTX.setOpenTimePicker(true); + CTX.setBottomSheetCreateShiftsOpen(false); + CTX.setTimePickerOrder("CREATE-SHIFT-START"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "startAtTimeShift", + startAtTimeShift, + "required" + )} />
{ + validator.current.showMessageFor("startAt"); + }} + inputFocus={() => { + CTX.setOpenTimePicker(true); + CTX.setBottomSheetCreateShiftsOpen(false); + CTX.setTimePickerOrder("CREATE-SHIFT-END"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "endAtTimeShift", + endAtTimeShift, + "required" + )} />
{ + 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 }, + ]} /> -
-
-
-
- - - +
+ {dayOfWeeksChoose && + dayOfWeeksChoose.map((e) => ( +
+
deleteRole(e)} + >
+ +
+

+ {week?.find((b) => b.value == e).key} +

+
-

شنبه

-
-
+ ))}
{ + setDescription(e.target.value); + validator.current.showMessageFor("description"); + }} textarea={true} + style="text-right" />
- -
-
- -
- - {/*
-

بستن

-
*/} -
+ {goToEditShift ? ( + handleCreateShift("UPDATE")} + subButton={true} + subButtonTitle="حذف شیفت" + subButtonEvent={() => CTX.DeleteShift(idEditShift)} + /> + ) : ( + handleCreateShift()} + /> + )}
); diff --git a/plugins/Buttonbriz/page.jsx b/plugins/Buttonbriz/page.jsx index c220004..e651cf9 100644 --- a/plugins/Buttonbriz/page.jsx +++ b/plugins/Buttonbriz/page.jsx @@ -97,7 +97,7 @@ const Buttonbriz = ({ className={`tr03 ${ subButtonAction ? "delete" - : "w-[140px] mr-[10px] p-[17px] mt-[5px]" + : "w-[200px] mr-[10px] p-[17px] mt-[5px]" }`} >

{ +const DatePickerIran = ({ datePickerEvent, date, zindex }) => { const CTX = useContext(AppContext); const [selectedDay, setSelectedDay] = useState(null); @@ -22,7 +22,9 @@ const DatePickerIran = ({ datePickerEvent, date }) => { return (

-
+

تاریخ تولد

diff --git a/plugins/DaysOfWeek/page.js b/plugins/DaysOfWeek/page.js new file mode 100644 index 0000000..a6be873 --- /dev/null +++ b/plugins/DaysOfWeek/page.js @@ -0,0 +1,17 @@ +export const DaysOfWeek = (day) => { + if (day == 6) { + return "شنبه"; + } else if (day == 1) { + return "دوشنبه"; + } else if (day == 2) { + return "سه شنبه"; + } else if (day == 3) { + return "چهارشنبه"; + } else if (day == 4) { + return "پنج شنبه"; + } else if (day == 5) { + return "جمعه"; + } else if (day == 0) { + return "یکشنبه"; + } +}; diff --git a/plugins/Input/page.jsx b/plugins/Input/page.jsx index f77725d..34cf189 100644 --- a/plugins/Input/page.jsx +++ b/plugins/Input/page.jsx @@ -10,6 +10,7 @@ const Input = ({ disabled, theme, inputEvent, + inputFocus, style, value, readOnly, @@ -63,6 +64,7 @@ const Input = ({ readOnly={readOnly ? true : false} value={value} onChange={inputEvent} + onFocus={inputFocus} /> )} diff --git a/plugins/PersianNumber/index.js b/plugins/PersianNumber/index.js index 68251a7..fe28994 100644 --- a/plugins/PersianNumber/index.js +++ b/plugins/PersianNumber/index.js @@ -1,4 +1,4 @@ -const PersianNumber = ({ number, isCost, size, bold }) => { +const PersianNumber = ({ number, isCost, size, bold, style }) => { if (number || number === 0) { const persianMap = "۰۱۲۳۴۵۶۷۸۹".split(""); const formatNumber = isCost @@ -8,7 +8,7 @@ const PersianNumber = ({ number, isCost, size, bold }) => { {formatNumber} diff --git a/plugins/TimeOfDay/page.js b/plugins/TimeOfDay/page.js new file mode 100644 index 0000000..0af9aec --- /dev/null +++ b/plugins/TimeOfDay/page.js @@ -0,0 +1,11 @@ +export const getTimeOfDay = (selectedTime) => { + if (selectedTime >= 0 && selectedTime < 12) { + return "صبح"; + } else if (selectedTime >= 12 && selectedTime < 15) { + return " ظهر"; + } else if (selectedTime >= 15 && selectedTime < 19) { + return "بعد از ظهر"; + } else { + return "شب"; + } +}; diff --git a/plugins/TimePicker/page.jsx b/plugins/TimePicker/page.jsx new file mode 100644 index 0000000..4d78275 --- /dev/null +++ b/plugins/TimePicker/page.jsx @@ -0,0 +1,116 @@ +"use client"; + +import AppContext from "@ctx/AppContext"; +import Buttonbriz from "plugins/Buttonbriz/page"; +import PersianNumber from "plugins/PersianNumber"; +import { useState, useEffect, useRef, useContext } from "react"; + +const TimePicker = () => { + const CTX = useContext(AppContext); + + const [hureSelect, setHureSelect] = useState(0); + const [secondSelect, setSecondSelect] = useState(0); + const [time, setTime] = useState(["00", "00"]); + const hoursArray = Array.from({ length: 24 }, (_, index) => { + const formattedHour = index < 10 ? `0${index}` : `${index}`; + return formattedHour; + }); + const secondsArray = Array.from({ length: 60 }, (_, index) => { + const formattedSecond = index < 10 ? `0${index}` : `${index}`; + return formattedSecond; + }); + + const handleButtonTimePicker = () => { + if (CTX.state.TimePickerOrder === "CREATE-SHIFT-START") { + CTX.setBottomSheetCreateShiftsOpen(true); + CTX.setStartAtTimeShift(time); + CTX.setOpenTimePicker(false); + } + if (CTX.state.TimePickerOrder === "CREATE-SHIFT-END") { + CTX.setBottomSheetCreateShiftsOpen(true); + CTX.setEndAtTimeShift(time); + CTX.setOpenTimePicker(false); + } + }; + + const handleHureSelect = (e) => { + setHureSelect(e); + setTime([e, secondSelect]); + }; + + const handleSecondSelect = (e) => { + setSecondSelect(e); + setTime([hureSelect, e]); + }; + return ( +
+
+
+
+

+ ساعت +

+
+ {hoursArray.map((e) => ( +
handleHureSelect(e)} + > +

+ +

+
+ ))} +
+
+ +
+

+ دقیقه{" "} +

+
+ {secondsArray.map((e) => ( +
handleSecondSelect(e)} + > +

+ +

+
+ ))} +
+
+
+
+

+ + : + +

+
+ +
+ handleButtonTimePicker()} + /> +
+
+
+ ); +}; + +export default TimePicker; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dba9238..a702298 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ dependencies: react-dom: specifier: 18.2.0 version: 18.2.0(react@18.2.0) + react-duration-picker: + specifier: ^1.1.1 + version: 1.1.1(react@18.2.0) react-modern-calendar-datepicker: specifier: ^3.1.6 version: 3.1.6(react-dom@18.2.0)(react@18.2.0) @@ -1621,6 +1624,15 @@ packages: scheduler: 0.23.0 dev: false + /react-duration-picker@1.1.1(react@18.2.0): + resolution: {integrity: sha512-1yzIjfpoSbRgJm88h8RF5VkTA0wa+sBRMmH9dudxzs7A8BC4LFvQiku51atx//JI5Yb4iwAelB9jjuWyxbkcqg==} + peerDependencies: + react: '>=16.8.0' + dependencies: + prop-types: 15.8.1 + react: 18.2.0 + dev: false + /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} dev: false diff --git a/src/app/acount/page.jsx b/src/app/acount/page.jsx index 5c779d5..d3e125c 100644 --- a/src/app/acount/page.jsx +++ b/src/app/acount/page.jsx @@ -1,16 +1,68 @@ +"use client"; import AppHeader from "@comp/AppHeader/page"; import Buttonbriz from "plugins/Buttonbriz/page"; import Input from "plugins/Input/page"; -import React from "react"; +import React, { useContext, useEffect, useRef, useState } from "react"; import person from "@img/person.png"; import Image from "next/image"; +import AppContext from "@ctx/AppContext"; +import Avatar from "boring-avatars"; +import { toast } from "react-toastify"; +import SimpleReactValidator from "simple-react-validator"; +import DatePickerIran from "plugins/DatePickerIran/page"; +import moment from "jalali-moment"; const page = () => { + const CTX = useContext(AppContext); + const profile = CTX.state.profile; + + const [fistName, setFistName] = useState(""); + const [lastName, setLastName] = useState(""); + const [phoneNumber, setPhoneNumber] = useState(""); + const [nationalId, setNationalId] = useState(""); + const [birthDateTimeStamp, setBirthDateTimeStamp] = useState(""); + const [, forceUpdate] = useState(); + + const validator = useRef( + new SimpleReactValidator({ + messages: { + required: "پر کردن این فیلد الزامی میباشد", + }, + element: (message) => ( + <> +
+ {message} +
+ + ), + }) + ); + + useEffect(() => { + // if (profile.birthDateTimeStamp < 0) { + // return (date = moment + // .unix(profile.birthDateTimeStamp) + // .locale("fa") + // .format("YYYY/MM/DD") + // .split("/")); + // } + + console.log(profile.birthDateTimeStamp < 0); + setFistName(profile.firstName); + setLastName(profile.lastName); + setPhoneNumber(profile.phoneNumber); + setNationalId(profile.nationalId); + + // setBirthDateTimeStamp( + // profile.birthDateTimeStamp < 0 ? ["1376", "09", "14"] : "" + // ); + }, [profile]); + return (
{
-
-
+
{ + toast.warning( + ` ${profile?.firstName} جان + فعلا دکوریه بعدا تلاش کن`, + { + position: "bottom-right", + closeOnClick: true, + } + ); + }} + > {
{ + setFistName(e.target.value); + validator.current.showMessageFor("fistName"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "fistName", + fistName, + "required" + )} />
@@ -63,39 +141,68 @@ const page = () => { id="lastName-id" name="lastName" type={"text"} + value={lastName} + inputEvent={(e) => { + setLastName(e.target.value); + validator.current.showMessageFor("lastName"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "lastName", + lastName, + "required" + )} />
{ + setPhoneNumber(e.target.value); + validator.current.showMessageFor("phoneNumber"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "phoneNumber", + phoneNumber, + "required" + )} + readOnly={true} />
- -
- -
-
{ + setNationalId(e.target.value); + validator.current.showMessageFor("nationalId"); + }} + style="text-right" + validator={true} + validatorData={validator.current.message( + "nationalId", + nationalId, + "required" + )} />
-
- -
+ setBirthDateTimeStamp(e)} + date={birthDateTimeStamp} + zindex="z-[101]" + />
diff --git a/src/app/home/page.jsx b/src/app/home/page.jsx index 5f87ffb..3208ed5 100644 --- a/src/app/home/page.jsx +++ b/src/app/home/page.jsx @@ -15,6 +15,8 @@ const Home = (props) => { const CTX = useContext(AppContext); const router = useRouter(); + const profile = CTX.state.profile; + useEffect(() => { if (!!localStorage.token) { const datatoken = ParseJwt(getToken()); @@ -32,8 +34,8 @@ const Home = (props) => { return (
{ return undefined; }} userIcon={true} + userIconData={profile.firstName} />
diff --git a/src/app/layout.jsx b/src/app/layout.jsx index 83c61a1..2851375 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -16,6 +16,7 @@ import { toast, ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import Loading from "plugins/Loading/page"; import Chapar, { getToken } from "plugins/Chapar"; +import TimePicker from "plugins/TimePicker/page"; const inter = Inter({ subsets: ["latin"] }); @@ -66,6 +67,21 @@ export default function RootLayout({ children }) { const [goToEditUser, setGoToEditUser] = useState(false); 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]); + const [shiftData, setShiftData] = useState([null]); + const [goToEditShift, setGoToEditShift] = useState(false); + const [idEditShift, setIdEditShift] = useState(null); + + // TimePicker + const [openTimePicker, setOpenTimePicker] = useState(false); + const [TimePickerOrder, setTimePickerOrder] = useState(null); + + const [profile, setProfile] = useState([]); + const pathname = usePathname(); const router = useRouter(); const hiddenUrls = ["/login", "/"]; @@ -78,7 +94,6 @@ export default function RootLayout({ children }) { setBigPlusRotateIcon(false); }; - const ConfirmPhoneNumber = async (phoneNumber) => { try { const data = await Chapar.get( @@ -111,6 +126,7 @@ export default function RootLayout({ children }) { if (data.user.signUpStatus == 1) { setStepLogin(2); } else if (data.user.signUpStatus == 2) { + setProfile(data.user); toast.success(` ${data.user.firstName} جان خوش اومدی `, { position: "bottom-right", closeOnClick: true, @@ -141,6 +157,8 @@ export default function RootLayout({ children }) { setLoading(false); if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) { + setProfile(data.user); + toast.success(` ${data.user.firstName} جان خوش اومدی `, { position: "bottom-right", closeOnClick: true, @@ -438,10 +456,162 @@ export default function RootLayout({ children }) { setLoading(false); } }; + const CreateShift = async (body) => { + setLoading(true); + try { + const data = await Chapar.post( + `${process.env.NEXT_PUBLIC_API_URL}/shift`, + JSON.stringify(body), + { + headers: { + Authorization: getToken(), + }, + } + ); + toast.success(`شیفت ساخته شد`, { + position: "bottom-right", + closeOnClick: true, + }); + setBottomSheetCreateShiftsOpen(false); + setLoading(false); + GetShifts(); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const UpdateShift = async (body) => { + setLoading(true); + try { + const data = await Chapar.put( + `${process.env.NEXT_PUBLIC_API_URL}/shift`, + body, - // useEffect(() => { - // GetPermissions(); - // }, []); + { + headers: { + Authorization: getToken(), + }, + } + ); + toast.success(`شیفت ویرایش شد`, { + position: "bottom-right", + closeOnClick: true, + }); + + setBottomSheetCreateShiftsOpen(false); + setLoading(false); + GetShifts(); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const GetShifts = async () => { + setLoading(true); + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/shift?page=0`, + + { + headers: { + Authorization: getToken(), + }, + } + ); + console.log("GetShifts", data); + + setShiftsData(data); + setLoading(false); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const GetShift = async (id) => { + setLoading(true); + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/shift/${id}`, + + { + headers: { + Authorization: getToken(), + }, + } + ); + console.log("GetShift", data); + + setShiftData(data); + setLoading(false); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const DeleteShift = async (id) => { + setLoading(true); + try { + const data = await Chapar.delete( + `${process.env.NEXT_PUBLIC_API_URL}/shift/${id}`, + + { + headers: { + Authorization: getToken(), + }, + } + ); + setBottomSheetCreateShiftsOpen(false); + + setLoading(false); + GetShifts(); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const CheckUser = async () => { + setLoading(true); + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/user/profile`, + + { + headers: { + Authorization: getToken(), + }, + } + ); + console.log("CheckUser", data); + + setProfile(data); + setLoading(false); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + + useEffect(() => { + if (profile.length <= 0 && localStorage.token) CheckUser(); + }, []); return ( @@ -514,8 +710,10 @@ export default function RootLayout({ children }) { {shouldRenderComponent && } + + {openTimePicker && } {BigPlusOpen ? ( -
+
{ const CTX = useContext(AppContext); + useEffect(() => { + CTX.GetShifts(); + }, []); + return ( <>
@@ -48,202 +53,8 @@ const Shifts = (props) => {
-
-
-
-

- شیفت صبح{" "} -

-
-
-
- - - - - - - - - - - -
-
- - - -
-
-
- -
-
-

- ساعت شروع : - - - - صبح -

- -

- ساعت شروع : - - - - ظهر -

-
-
- -
-
-

- {" "} - 21 نفر در این شیفت قرار دارند -

-
- -
-

- {" "} - 40 تسک فهال{" "} -

-
- -
-

- {" "} - 21 نفر در این شیفت قرار دارند -

-
-
-
- -
-
-
-

- شیفت عصر شنبه{" "} -

-
-
-
- - - - - - - - - - - -
-
- - - -
-
-
- -
-
-

- ساعت شروع : - - - - صبح -

- -

- ساعت شروع : - - - - ظهر -

-
-
- -
-
-

- {" "} - 21 نفر در این شیفت قرار دارند -

-
- -
-

- {" "} - 40 تسک فهال{" "} -

-
- -
-

- {" "} - 21 نفر در این شیفت قرار دارند -

-
-
-
+
diff --git a/style/globals.css b/style/globals.css index f40357e..f3310fc 100644 --- a/style/globals.css +++ b/style/globals.css @@ -113,7 +113,7 @@ body { } [data-rsbs-backdrop] { - z-index: 20 !important; + z-index: 100000 !important; background-color: rgba(0, 0, 0, 0.8) !important; } [data-rsbs-overlay] { @@ -165,7 +165,7 @@ body { .delete { --border-size: 3px; --border-angle: 0turn; - width: 140px; + width: 180px; height: fit-content; padding: 17px; margin-right: 10px;