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"
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

View File

@ -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 (
<div className=" bg-primary-300 flex justify-between rtl pt-4 px-4 pb-[50px] w-full">
<div className="flex">
@ -115,6 +120,7 @@ const AppHeader = ({
</div>
</div>
{!userRole ? (
<div className="flex mt-2">
{icon1 ? (
<Link href={iconHref1}>
@ -142,6 +148,14 @@ const AppHeader = ({
""
)}
</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>
);
};

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="شماره تماس"
id="phoneNumber-id"
name="phoneNumber"
type={"text"}
type={"number"}
value={phoneNumber}
inputEvent={(e) => {
setPhoneNumber(e.target.value);

View File

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

View File

@ -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 (
<div className="pb-20">
<AppHeader
title={profile?.firstName + " " + profile?.lastName}
sub={profile.selectedComplexName}
icon1={true}
iconName1="ACOUNT"
iconHref1="/acount"
iconEvent1={() => {
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)}
/>
<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 className="bg-white rounded-2xl p-3">
<div className=" rounded-2xl p-3">
<div className="flex justify-between ">
<div>
<div className="flex mt-3">
@ -148,6 +141,8 @@ const Home = (props) => {
</div>
</div>
</div>
<BottomSheetChangeRole />
</div>
);
};

View File

@ -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,
}}
>
<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="font-bold text-right">
<p className="mb-0">روتین را انتخاب کنید</p>
</div>
<div
className="flex overflow-auto whitespace-nowrap mb-5"
id="swich-shifts"
@ -186,6 +189,10 @@ const Calendar = () => {
</div>
{shiftPlanSteps >= 1 && (
<>
<div className="font-bold text-right mt-3">
<p className="mb-0">تاریخ را انتخاب کنید</p>
</div>
<Swiper
spaceBetween={10}
slidesPerView={4.3}
@ -196,7 +203,9 @@ const Calendar = () => {
<SwiperSlide>
<div
className={`h-[70px] tr03 ${
selectDay == index ? "bg-white rounded-xl" : " opacity-70"
selectDay == index
? "bg-white rounded-xl"
: " opacity-70"
}`}
key={index}
onClick={() => {
@ -240,12 +249,17 @@ const Calendar = () => {
</SwiperSlide>
))}
</Swiper>
</>
)}
</div>
{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">
<>
<div className="font-bold text-right mt-3">
<p className="mb-0">شیفت را انتخاب کنید</p>
</div>
{!!routineShiftPlan?.find(
(e) => e?.day == daysUntilWeek[selectDay]?.value
) && shiftsData.length > 0 ? (
@ -280,6 +294,7 @@ const Calendar = () => {
)}
</>
</div>
</>
)}
{shiftPlanSteps >= 3 && (

View File

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