diff --git a/.env b/.env index c5bbeb4..fd43833 100644 --- a/.env +++ b/.env @@ -1,16 +1,20 @@ NODE_ENV="development" -NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769 -NEXT_PUBLIC_PUBLIC_URL=http://192.168.88.12:32769 -NEXT_PUBLIC_API_URL=http://192.168.88.12:32769/api +# NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769 +# NEXT_PUBLIC_PUBLIC_URL=http://192.168.88.12:32769 +# NEXT_PUBLIC_API_URL=http://192.168.88.12:32769/api # SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99 # NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages # NEXT_PUBLIC_API_URL_BackUp=https://192.168.88.12:49154/Files/BackUps +NEXT_PUBLIC_SERVER_URL=https://j3884z97-32769.euw.devtunnels.ms +NEXT_PUBLIC_PUBLIC_URL=https://j3884z97-32769.euw.devtunnels.ms +NEXT_PUBLIC_API_URL=https://j3884z97-32769.euw.devtunnels.ms/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_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 \ No newline at end of file diff --git a/components/AppHeader/page.jsx b/components/AppHeader/page.jsx index f0ca772..ca03dca 100644 --- a/components/AppHeader/page.jsx +++ b/components/AppHeader/page.jsx @@ -14,8 +14,10 @@ const AppHeader = ({ iconName2, iconHref2, iconEvent2, + iconEvent3, userIcon, userIconData, + userRole, }) => { const icons = [ { @@ -94,6 +96,9 @@ const AppHeader = ({ }, ]; + // console.log("title", title); + // console.log("sub", sub); + return (
@@ -115,33 +120,42 @@ const AppHeader = ({
-
- {icon1 ? ( - -
- {icons.find((e) => e.iconName == iconName1)?.icon} -
- - ) : ( - "" - )} + {!userRole ? ( +
+ {icon1 ? ( + +
+ {icons.find((e) => e.iconName == iconName1)?.icon} +
+ + ) : ( + "" + )} - {icon2 ? ( - -
- {icons.find((e) => e.iconName == iconName2)?.icon} -
- - ) : ( - "" - )} -
+ {icon2 ? ( + +
+ {icons.find((e) => e.iconName == iconName2)?.icon} +
+ + ) : ( + "" + )} +
+ ) : ( +
+

{userRole && userRole[0]?.roleName}

+
+ )} ); }; diff --git a/plugins/BottomSheet/BottomSheetChangeRole.jsx b/plugins/BottomSheet/BottomSheetChangeRole.jsx new file mode 100644 index 0000000..bf735f0 --- /dev/null +++ b/plugins/BottomSheet/BottomSheetChangeRole.jsx @@ -0,0 +1,40 @@ +"use client"; + +import React, { useContext } from "react"; +import { BottomSheet } from "react-spring-bottom-sheet"; +import AppContext from "@ctx/AppContext"; +import Buttonbriz from "plugins/Buttonbriz/page"; + +const BottomSheetChangeRole = (props) => { + const CTX = useContext(AppContext); + + const roles = CTX.state.profile.roles; + + return ( + CTX.setBottomSheetChangeRoleOpen(false)} + blocking={false} + > +
+

انتخاب نقش جدید

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

{e.roleName}

+
+ ))} + handleCreateRoutine()} + /> +
+
+ ); +}; + +export default BottomSheetChangeRole; diff --git a/plugins/BottomSheet/BottomSheetCreateEmployees.jsx b/plugins/BottomSheet/BottomSheetCreateEmployees.jsx index ee7be34..0cca9d6 100644 --- a/plugins/BottomSheet/BottomSheetCreateEmployees.jsx +++ b/plugins/BottomSheet/BottomSheetCreateEmployees.jsx @@ -282,7 +282,7 @@ const BottomSheetCreateEmployees = (props) => { lable="شماره تماس" id="phoneNumber-id" name="phoneNumber" - type={"text"} + type={"number"} value={phoneNumber} inputEvent={(e) => { setPhoneNumber(e.target.value); diff --git a/plugins/BottomSheet/BottomSheetCreateShifts.jsx b/plugins/BottomSheet/BottomSheetCreateShifts.jsx index 3d1acef..8f67225 100644 --- a/plugins/BottomSheet/BottomSheetCreateShifts.jsx +++ b/plugins/BottomSheet/BottomSheetCreateShifts.jsx @@ -215,6 +215,7 @@ const BottomSheetCreateShifts = (props) => { startAtTimeShift, "required" )} + readOnly={true} /> diff --git a/src/app/home/page.jsx b/src/app/home/page.jsx index 9f24069..9c286dc 100644 --- a/src/app/home/page.jsx +++ b/src/app/home/page.jsx @@ -12,6 +12,7 @@ import React, { useContext, useEffect } 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"; +import BottomSheetChangeRole from "plugins/BottomSheet/BottomSheetChangeRole"; ChartJS.register(ArcElement, Tooltip, Legend); @@ -62,25 +63,17 @@ const Home = (props) => { } }, []); + console.log(profile); + return (
{ - return undefined; - }} - icon2={true} - iconName2="NINJA" - iconHref2="#" - iconEvent2={() => { - return undefined; - }} + title={profile?.user?.firstName + " " + profile?.user?.lastName} + sub={profile?.user?.selectedRoleName} userIcon={true} - userIconData={profile.firstName} + userIconData={profile?.user?.firstName} + userRole={profile?.roles} + iconEvent3={() => CTX.setBottomSheetChangeRoleOpen(true)} />
@@ -117,7 +110,7 @@ const Home = (props) => {
-
+
@@ -148,6 +141,8 @@ const Home = (props) => {
+ +
); }; diff --git a/src/app/layout.jsx b/src/app/layout.jsx index 4a5c20c..eff2955 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -51,6 +51,9 @@ export default function RootLayout({ children }) { setBottomSheetAddUserToPositionShiftPlanOpen, ] = useState(false); + const [BottomSheetChangeRoleOpen, setBottomSheetChangeRoleOpen] = + useState(false); + // BigPlus const [BigPlusOpen, setBigPlusOpen] = useState(false); const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false); @@ -60,8 +63,10 @@ export default function RootLayout({ children }) { const [verifyCode, setVerifyCode] = useState(""); const [stepLogin, setStepLogin] = useState(0); const [tokenForStorage, setTokenForStorage] = useState(null); + const [profile, setProfile] = useState([]); // loading + const [loading, setLoading] = useState(false); //auth @@ -121,6 +126,9 @@ export default function RootLayout({ children }) { const [goToEditTask, setGoToEditTask] = useState(false); const [idEditTask, setIdEditTask] = useState(null); + // activity + const [activitiesData, setActivitiesData] = useState([null]); + // shift manage-shift const [searchUserChoose, setSearchUserChoose] = useState([]); @@ -128,8 +136,6 @@ export default function RootLayout({ children }) { const [openTimePicker, setOpenTimePicker] = useState(false); const [TimePickerOrder, setTimePickerOrder] = useState(null); - const [profile, setProfile] = useState([]); - const pathname = usePathname(); const router = useRouter(); const hiddenUrls = ["/login", "/"]; @@ -174,7 +180,7 @@ export default function RootLayout({ children }) { if (data.user.signUpStatus == 1) { setStepLogin(2); } else if (data.user.signUpStatus == 2) { - setProfile(data.user); + setProfile(data); toast.success(` ${data.user.firstName} جان خوش اومدی `, { position: "bottom-right", closeOnClick: true, @@ -202,10 +208,12 @@ export default function RootLayout({ children }) { }, } ); + + console.log("SignUpLogin", SignUpLogin); setLoading(false); if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) { - setProfile(data.user); + setProfile(data); toast.success(` ${data.user.firstName} جان خوش اومدی `, { position: "bottom-right", @@ -1209,6 +1217,31 @@ export default function RootLayout({ children }) { } }; + const GetActivity = async () => { + setLoading(true); + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/activity?page=0`, + + { + headers: { + Authorization: getToken(), + }, + } + ); + console.log("GetActivity", data); + + setActivitiesData(data); + setLoading(false); + } catch ({ error, status }) { + toast.error(`${error.response.data.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const CheckUser = async () => { setLoading(true); try { @@ -1224,6 +1257,7 @@ export default function RootLayout({ children }) { console.log("CheckUser", data); setProfile(data); + setLoading(false); } catch ({ error, status }) { toast.error(`${error.response.data.message}`, { @@ -1302,6 +1336,8 @@ export default function RootLayout({ children }) { tasksData, routineShiftPlan, BottomSheetAddUserToPositionShiftPlanOpen, + BottomSheetChangeRoleOpen, + activitiesData, }, setBottomSheetCreateRoleOpen, setBottomSheetCreateEmployeesOpen, @@ -1402,6 +1438,9 @@ export default function RootLayout({ children }) { GetRoutineShiftPlan, setBottomSheetAddUserToPositionShiftPlanOpen, CreateShifPlan, + setBottomSheetChangeRoleOpen, + setActivitiesData, + GetActivity, }} > diff --git a/src/app/shifts/manage-shift/page.jsx b/src/app/shifts/manage-shift/page.jsx index a7fc9f8..d748b27 100644 --- a/src/app/shifts/manage-shift/page.jsx +++ b/src/app/shifts/manage-shift/page.jsx @@ -153,6 +153,9 @@ const Calendar = () => { />
+
+

روتین را انتخاب کنید

+
{
{shiftPlanSteps >= 1 && ( - console.log("slide change")} - onSwiper={(swiper) => console.log(swiper)} - > - {daysUntilWeek?.map((e, index) => ( - -
{ - setSelectDay(index); - setShiftPlanSteps(2); - console.log(index); - }} - > -
-

- b.date == e.checkDay - ) - ? "text-red-500" - : "" - } `} - /> -

-
- + <> +
+

تاریخ را انتخاب کنید

+
+ console.log("slide change")} + onSwiper={(swiper) => console.log(swiper)} + > + {daysUntilWeek?.map((e, index) => ( +
b.date == e.checkDay) - ? "bg-transparent text-red-500" - : "bg-white text-gray-500" + ? "bg-white rounded-xl" + : " opacity-70" }`} + key={index} + onClick={() => { + setSelectDay(index); + setShiftPlanSteps(2); + console.log(index); + }} > -

- {/* {PersianD.find((i) => i == e.dayOfWeek)} */} - {e.dayOfWeek} -

+
+

+ b.date == e.checkDay + ) + ? "text-red-500" + : "" + } `} + /> +

+
+ +
b.date == e.checkDay) + ? "bg-transparent text-red-500" + : "bg-white text-gray-500" + }`} + > +

+ {/* {PersianD.find((i) => i == e.dayOfWeek)} */} + {e.dayOfWeek} +

+
-
-
- ))} -
+ + ))} + + )}
{shiftPlanSteps >= 2 && ( -
- <> - {!!routineShiftPlan?.find( - (e) => e?.day == daysUntilWeek[selectDay]?.value - ) && shiftsData.length > 0 ? ( -
- {shiftsPlan?.map((e, index) => ( -
{ - setselectShift(index); - setShiftPlanSteps(3); - }} - > -

{e?.title}

-
- ))} + <> +
+ <> +
+

شیفت را انتخاب کنید

- ) : ( -
-
-

- شما شیفتی دراین روز ندارید -

+ {!!routineShiftPlan?.find( + (e) => e?.day == daysUntilWeek[selectDay]?.value + ) && shiftsData.length > 0 ? ( +
+ {shiftsPlan?.map((e, index) => ( +
{ + setselectShift(index); + setShiftPlanSteps(3); + }} + > +

{e?.title}

+
+ ))}
-
- )} - -
+ ) : ( +
+
+

+ شما شیفتی دراین روز ندارید +

+
+
+ )} + +
+ )} {shiftPlanSteps >= 3 && ( diff --git a/src/app/tasks/page.jsx b/src/app/tasks/page.jsx index 21c6ab6..e28abb0 100644 --- a/src/app/tasks/page.jsx +++ b/src/app/tasks/page.jsx @@ -19,6 +19,7 @@ const page = () => { useEffect(() => { CTX.GetTasks(); + CTX.GetActivity(); }, []); return (