From 9cff16953796bd5d93c98e054319d53e78fbf56e Mon Sep 17 00:00:00 2001
From: mpn <123456>
Date: Thu, 7 Dec 2023 13:46:57 +0330
Subject: [PATCH] pre login user
---
.env | 16 +-
components/AppHeader/page.jsx | 66 ++++---
plugins/BottomSheet/BottomSheetChangeRole.jsx | 40 ++++
.../BottomSheetCreateEmployees.jsx | 2 +-
.../BottomSheet/BottomSheetCreateShifts.jsx | 1 +
src/app/home/page.jsx | 27 ++-
src/app/layout.jsx | 47 ++++-
src/app/shifts/manage-shift/page.jsx | 181 ++++++++++--------
src/app/tasks/page.jsx | 1 +
9 files changed, 245 insertions(+), 136 deletions(-)
create mode 100644 plugins/BottomSheet/BottomSheetChangeRole.jsx
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 (
+
@@ -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 (