pre login user

main
mpn 2023-12-07 13:46:57 +03:30
parent e21571d5f8
commit 9cff169537
9 changed files with 245 additions and 136 deletions

16
.env
View File

@ -1,16 +1,20 @@
NODE_ENV="development" NODE_ENV="development"
NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769 # NEXT_PUBLIC_SERVER_URL=http://192.168.88.12:32769
NEXT_PUBLIC_PUBLIC_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_API_URL=http://192.168.88.12:32769/api
# SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99 # SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99
# NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages # 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_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_SERVER_URL=https://api.brizco.io
NEXT_PUBLIC_API_URL=https://api.brizco.io/api # 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_IMAGE=https://api.macsonline.ir/Files/ReportImages
# NEXT_PUBLIC_API_URL_BackUp=https://api.macsonline.ir/Files/BackUps # NEXT_PUBLIC_API_URL_BackUp=https://api.macsonline.ir/Files/BackUps

View File

@ -14,8 +14,10 @@ const AppHeader = ({
iconName2, iconName2,
iconHref2, iconHref2,
iconEvent2, iconEvent2,
iconEvent3,
userIcon, userIcon,
userIconData, userIconData,
userRole,
}) => { }) => {
const icons = [ const icons = [
{ {
@ -94,6 +96,9 @@ const AppHeader = ({
}, },
]; ];
// console.log("title", title);
// console.log("sub", sub);
return ( return (
<div className=" bg-primary-300 flex justify-between rtl pt-4 px-4 pb-[50px] w-full"> <div className=" bg-primary-300 flex justify-between rtl pt-4 px-4 pb-[50px] w-full">
<div className="flex"> <div className="flex">
@ -115,33 +120,42 @@ const AppHeader = ({
</div> </div>
</div> </div>
<div className="flex mt-2"> {!userRole ? (
{icon1 ? ( <div className="flex mt-2">
<Link href={iconHref1}> {icon1 ? (
<div <Link href={iconHref1}>
className="w-[40px] h-[40px] bg-white rounded-full mx-1 pt-[3px]" <div
onClick={iconEvent1} className="w-[40px] h-[40px] bg-white rounded-full mx-1 pt-[3px]"
> onClick={iconEvent1}
{icons.find((e) => e.iconName == iconName1)?.icon} >
</div> {icons.find((e) => e.iconName == iconName1)?.icon}
</Link> </div>
) : ( </Link>
"" ) : (
)} ""
)}
{icon2 ? ( {icon2 ? (
<Link href={iconHref2}> <Link href={iconHref2}>
<div <div
className="w-[40px] h-[40px] bg-white rounded-full mx-1 pt-[3px]" className="w-[40px] h-[40px] bg-white rounded-full mx-1 pt-[3px]"
onClick={iconEvent2} onClick={iconEvent2}
> >
{icons.find((e) => e.iconName == iconName2)?.icon} {icons.find((e) => e.iconName == iconName2)?.icon}
</div> </div>
</Link> </Link>
) : ( ) : (
"" ""
)} )}
</div> </div>
) : (
<div
className="w-fit h-fit bg-white rounded-full mx-1 "
onClick={iconEvent3}
>
<p className="mb-0 p-2 px-4">{userRole && userRole[0]?.roleName}</p>
</div>
)}
</div> </div>
); );
}; };

View File

@ -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 (
<BottomSheet
open={CTX.state.BottomSheetChangeRoleOpen}
onDismiss={() => CTX.setBottomSheetChangeRoleOpen(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-3 ">
{roles?.map((e) => (
<div className="bg-gray-100 rounded-xl border-[1px] border-gray-200 p-5 m-2">
<p className="mb-0 text-right">{e.roleName}</p>
</div>
))}
<Buttonbriz
title="ثبت نقش"
color="PRIMARY"
icon="CHECK"
// buttonEvent={() => handleCreateRoutine()}
/>
</div>
</BottomSheet>
);
};
export default BottomSheetChangeRole;

View File

@ -282,7 +282,7 @@ const BottomSheetCreateEmployees = (props) => {
lable="شماره تماس" lable="شماره تماس"
id="phoneNumber-id" id="phoneNumber-id"
name="phoneNumber" name="phoneNumber"
type={"text"} type={"number"}
value={phoneNumber} value={phoneNumber}
inputEvent={(e) => { inputEvent={(e) => {
setPhoneNumber(e.target.value); setPhoneNumber(e.target.value);

View File

@ -215,6 +215,7 @@ const BottomSheetCreateShifts = (props) => {
startAtTimeShift, startAtTimeShift,
"required" "required"
)} )}
readOnly={true}
/> />
</div> </div>

View File

@ -12,6 +12,7 @@ import React, { useContext, useEffect } from "react";
// import { Swiper, SwiperSlide } from "swiper/react"; // import { Swiper, SwiperSlide } from "swiper/react";
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js"; import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
import { Doughnut, Pie } from "react-chartjs-2"; import { Doughnut, Pie } from "react-chartjs-2";
import BottomSheetChangeRole from "plugins/BottomSheet/BottomSheetChangeRole";
ChartJS.register(ArcElement, Tooltip, Legend); ChartJS.register(ArcElement, Tooltip, Legend);
@ -62,25 +63,17 @@ const Home = (props) => {
} }
}, []); }, []);
console.log(profile);
return ( return (
<div className="pb-20"> <div className="pb-20">
<AppHeader <AppHeader
title={profile?.firstName + " " + profile?.lastName} title={profile?.user?.firstName + " " + profile?.user?.lastName}
sub={profile.selectedComplexName} sub={profile?.user?.selectedRoleName}
icon1={true}
iconName1="ACOUNT"
iconHref1="/acount"
iconEvent1={() => {
return undefined;
}}
icon2={true}
iconName2="NINJA"
iconHref2="#"
iconEvent2={() => {
return undefined;
}}
userIcon={true} userIcon={true}
userIconData={profile.firstName} userIconData={profile?.user?.firstName}
userRole={profile?.roles}
iconEvent3={() => CTX.setBottomSheetChangeRoleOpen(true)}
/> />
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl"> <div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl">
@ -117,7 +110,7 @@ const Home = (props) => {
</div> </div>
</div> </div>
<div className="bg-white rounded-2xl p-3"> <div className=" rounded-2xl p-3">
<div className="flex justify-between "> <div className="flex justify-between ">
<div> <div>
<div className="flex mt-3"> <div className="flex mt-3">
@ -148,6 +141,8 @@ const Home = (props) => {
</div> </div>
</div> </div>
</div> </div>
<BottomSheetChangeRole />
</div> </div>
); );
}; };

View File

@ -51,6 +51,9 @@ export default function RootLayout({ children }) {
setBottomSheetAddUserToPositionShiftPlanOpen, setBottomSheetAddUserToPositionShiftPlanOpen,
] = useState(false); ] = useState(false);
const [BottomSheetChangeRoleOpen, setBottomSheetChangeRoleOpen] =
useState(false);
// BigPlus // BigPlus
const [BigPlusOpen, setBigPlusOpen] = useState(false); const [BigPlusOpen, setBigPlusOpen] = useState(false);
const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false); const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false);
@ -60,8 +63,10 @@ export default function RootLayout({ children }) {
const [verifyCode, setVerifyCode] = useState(""); const [verifyCode, setVerifyCode] = useState("");
const [stepLogin, setStepLogin] = useState(0); const [stepLogin, setStepLogin] = useState(0);
const [tokenForStorage, setTokenForStorage] = useState(null); const [tokenForStorage, setTokenForStorage] = useState(null);
const [profile, setProfile] = useState([]);
// loading // loading
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
//auth //auth
@ -121,6 +126,9 @@ export default function RootLayout({ children }) {
const [goToEditTask, setGoToEditTask] = useState(false); const [goToEditTask, setGoToEditTask] = useState(false);
const [idEditTask, setIdEditTask] = useState(null); const [idEditTask, setIdEditTask] = useState(null);
// activity
const [activitiesData, setActivitiesData] = useState([null]);
// shift manage-shift // shift manage-shift
const [searchUserChoose, setSearchUserChoose] = useState([]); const [searchUserChoose, setSearchUserChoose] = useState([]);
@ -128,8 +136,6 @@ export default function RootLayout({ children }) {
const [openTimePicker, setOpenTimePicker] = useState(false); const [openTimePicker, setOpenTimePicker] = useState(false);
const [TimePickerOrder, setTimePickerOrder] = useState(null); const [TimePickerOrder, setTimePickerOrder] = useState(null);
const [profile, setProfile] = useState([]);
const pathname = usePathname(); const pathname = usePathname();
const router = useRouter(); const router = useRouter();
const hiddenUrls = ["/login", "/"]; const hiddenUrls = ["/login", "/"];
@ -174,7 +180,7 @@ export default function RootLayout({ children }) {
if (data.user.signUpStatus == 1) { if (data.user.signUpStatus == 1) {
setStepLogin(2); setStepLogin(2);
} else if (data.user.signUpStatus == 2) { } else if (data.user.signUpStatus == 2) {
setProfile(data.user); setProfile(data);
toast.success(` ${data.user.firstName} جان خوش اومدی `, { toast.success(` ${data.user.firstName} جان خوش اومدی `, {
position: "bottom-right", position: "bottom-right",
closeOnClick: true, closeOnClick: true,
@ -202,10 +208,12 @@ export default function RootLayout({ children }) {
}, },
} }
); );
console.log("SignUpLogin", SignUpLogin);
setLoading(false); setLoading(false);
if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) { if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
setProfile(data.user); setProfile(data);
toast.success(` ${data.user.firstName} جان خوش اومدی `, { toast.success(` ${data.user.firstName} جان خوش اومدی `, {
position: "bottom-right", 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 () => { const CheckUser = async () => {
setLoading(true); setLoading(true);
try { try {
@ -1224,6 +1257,7 @@ export default function RootLayout({ children }) {
console.log("CheckUser", data); console.log("CheckUser", data);
setProfile(data); setProfile(data);
setLoading(false); setLoading(false);
} catch ({ error, status }) { } catch ({ error, status }) {
toast.error(`${error.response.data.message}`, { toast.error(`${error.response.data.message}`, {
@ -1302,6 +1336,8 @@ export default function RootLayout({ children }) {
tasksData, tasksData,
routineShiftPlan, routineShiftPlan,
BottomSheetAddUserToPositionShiftPlanOpen, BottomSheetAddUserToPositionShiftPlanOpen,
BottomSheetChangeRoleOpen,
activitiesData,
}, },
setBottomSheetCreateRoleOpen, setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen, setBottomSheetCreateEmployeesOpen,
@ -1402,6 +1438,9 @@ export default function RootLayout({ children }) {
GetRoutineShiftPlan, GetRoutineShiftPlan,
setBottomSheetAddUserToPositionShiftPlanOpen, setBottomSheetAddUserToPositionShiftPlanOpen,
CreateShifPlan, CreateShifPlan,
setBottomSheetChangeRoleOpen,
setActivitiesData,
GetActivity,
}} }}
> >
<html lang="en"> <html lang="en">

View File

@ -153,6 +153,9 @@ const Calendar = () => {
/> />
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-4 rtl"> <div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-4 rtl">
<div className="font-bold text-right">
<p className="mb-0">روتین را انتخاب کنید</p>
</div>
<div <div
className="flex overflow-auto whitespace-nowrap mb-5" className="flex overflow-auto whitespace-nowrap mb-5"
id="swich-shifts" id="swich-shifts"
@ -186,100 +189,112 @@ const Calendar = () => {
</div> </div>
{shiftPlanSteps >= 1 && ( {shiftPlanSteps >= 1 && (
<Swiper <>
spaceBetween={10} <div className="font-bold text-right mt-3">
slidesPerView={4.3} <p className="mb-0">تاریخ را انتخاب کنید</p>
onSlideChange={() => console.log("slide change")} </div>
onSwiper={(swiper) => console.log(swiper)} <Swiper
> spaceBetween={10}
{daysUntilWeek?.map((e, index) => ( slidesPerView={4.3}
<SwiperSlide> onSlideChange={() => console.log("slide change")}
<div onSwiper={(swiper) => console.log(swiper)}
className={`h-[70px] tr03 ${ >
selectDay == index ? "bg-white rounded-xl" : " opacity-70" {daysUntilWeek?.map((e, index) => (
}`} <SwiperSlide>
key={index}
onClick={() => {
setSelectDay(index);
setShiftPlanSteps(2);
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 <div
className={`w-fit mx-auto sahdow px-1 rounded-full ${ className={`h-[70px] tr03 ${
selectDay == index selectDay == index
? "bg-secondary-100 text-gray-100" ? "bg-white rounded-xl"
: !!holidays.y1402?.find((b) => b.date == e.checkDay) : " opacity-70"
? "bg-transparent text-red-500"
: "bg-white text-gray-500"
}`} }`}
key={index}
onClick={() => {
setSelectDay(index);
setShiftPlanSteps(2);
console.log(index);
}}
> >
<p className="mb-0 text-center text-sm "> <div className="py-2">
{/* {PersianD.find((i) => i == e.dayOfWeek)} */} <p className="mb-0 text-center ">
{e.dayOfWeek} <PersianNumber
</p> 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)} */}
{e.dayOfWeek}
</p>
</div>
</div> </div>
</div> </SwiperSlide>
</SwiperSlide> ))}
))} </Swiper>
</Swiper> </>
)} )}
</div> </div>
{shiftPlanSteps >= 2 && ( {shiftPlanSteps >= 2 && (
<div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden rtl"> <>
<> <div className="bg-body-100 relative top-[-40px] rounded-t-3xl overflow-hidden px-4 rtl">
{!!routineShiftPlan?.find( <>
(e) => e?.day == daysUntilWeek[selectDay]?.value <div className="font-bold text-right mt-3">
) && shiftsData.length > 0 ? ( <p className="mb-0">شیفت را انتخاب کنید</p>
<div
className="flex overflow-auto whitespace-nowrap"
id="swich-shifts"
>
{shiftsPlan?.map((e, index) => (
<div
className={` shadow-sm relative block max-w-fit mx-2 rounded-full mt-2 px-4 py-2 tr03 ${
selectShift == index
? "bg-secondary-100 text-white w-full"
: "bg-white opacity-60 "
}`}
onClick={() => {
setselectShift(index);
setShiftPlanSteps(3);
}}
>
<p className="mb-0">{e?.title}</p>
</div>
))}
</div> </div>
) : ( {!!routineShiftPlan?.find(
<div className="flex justify-center "> (e) => e?.day == daysUntilWeek[selectDay]?.value
<div className="bg-gray-300 mt-5 w-fit rounded-full p-2 !px-4"> ) && shiftsData.length > 0 ? (
<p className="mb-0 text-gray-600 text-sm"> <div
شما شیفتی دراین روز ندارید className="flex overflow-auto whitespace-nowrap"
</p> id="swich-shifts"
>
{shiftsPlan?.map((e, index) => (
<div
className={` shadow-sm relative block max-w-fit mx-2 rounded-full mt-2 px-4 py-2 tr03 ${
selectShift == index
? "bg-secondary-100 text-white w-full"
: "bg-white opacity-60 "
}`}
onClick={() => {
setselectShift(index);
setShiftPlanSteps(3);
}}
>
<p className="mb-0">{e?.title}</p>
</div>
))}
</div> </div>
</div> ) : (
)} <div className="flex justify-center ">
</> <div className="bg-gray-300 mt-5 w-fit rounded-full p-2 !px-4">
</div> <p className="mb-0 text-gray-600 text-sm">
شما شیفتی دراین روز ندارید
</p>
</div>
</div>
)}
</>
</div>
</>
)} )}
{shiftPlanSteps >= 3 && ( {shiftPlanSteps >= 3 && (

View File

@ -19,6 +19,7 @@ const page = () => {
useEffect(() => { useEffect(() => {
CTX.GetTasks(); CTX.GetTasks();
CTX.GetActivity();
}, []); }, []);
return ( return (
<div className="pb-20"> <div className="pb-20">