diff --git a/.env b/.env index 023304b..bf70d31 100644 --- a/.env +++ b/.env @@ -1,8 +1,8 @@ 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.189.123:32769 +NEXT_PUBLIC_PUBLIC_URL=http://192.168.189.123:32769 +NEXT_PUBLIC_API_URL=http://192.168.189.123:32769/api # SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99 # NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages diff --git a/components/LoginComponents/LoginStep.jsx b/components/LoginComponents/LoginStep.jsx index e57c4ea..4107123 100644 --- a/components/LoginComponents/LoginStep.jsx +++ b/components/LoginComponents/LoginStep.jsx @@ -63,12 +63,6 @@ const LoginStep = (props) => { }`} >
گزارشات
++ شما در حال گرفتن گزارش برای + {reportDetail?.title} + هستید +
+
{subButtonTitle}
diff --git a/src/app/layout.jsx b/src/app/layout.jsx
index 3a18bba..92c3d62 100644
--- a/src/app/layout.jsx
+++ b/src/app/layout.jsx
@@ -19,6 +19,7 @@ import Chapar, { getToken } from "plugins/Chapar";
import TimePicker from "plugins/TimePicker/page";
import axios from "axios";
import "rc-slider/assets/index.css";
+import BottomSheetReport from "plugins/BottomSheet/BottomSheetReport";
const inter = Inter({ subsets: ["latin"] });
@@ -55,6 +56,8 @@ export default function RootLayout({ children }) {
const [BottomSheetChangeRoleOpen, setBottomSheetChangeRoleOpen] =
useState(false);
+ const [BottomSheetReportOpen, setBottomSheetReportOpen] = useState(false);
+
// BigPlus
const [BigPlusOpen, setBigPlusOpen] = useState(false);
const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false);
@@ -117,6 +120,7 @@ export default function RootLayout({ children }) {
const [goToEditShift, setGoToEditShift] = useState(false);
const [idEditShift, setIdEditShift] = useState(null);
const [shiftPlanData, setShiftPlanData] = useState([]);
+ const [shiftPlansData, setShifPlansData] = useState([]);
// task
const [routineForTaskChoose, setRoutineForTaskChoose] = useState([]);
@@ -145,6 +149,9 @@ export default function RootLayout({ children }) {
// closeShift
const [completeActivities, setCompleteActivities] = useState([]);
+ //report
+ const [reportDetail, setReportDetail] = useState(null);
+
const pathname = usePathname();
const router = useRouter();
const hiddenUrls = ["/login", "/pricing", "/about-us", "/"];
@@ -263,7 +270,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateRole = async (body) => {
setLoading(true);
try {
@@ -388,7 +394,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateUser = async (body) => {
setLoading(true);
try {
@@ -514,7 +519,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateShift = async (body) => {
setLoading(true);
try {
@@ -600,57 +604,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
- const GetShiftPlan = async (id) => {
- setLoading(true);
- try {
- const data = await Chapar.get(
- `${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}`,
- {
- headers: {
- Authorization: getToken(),
- },
- }
- );
- setShiftPlanData(data);
- setLoading(false);
- } catch ({ error, status }) {
- toast.error(`${error?.response?.data?.message}`, {
- position: "bottom-right",
- closeOnClick: true,
- });
- setLoading(false);
- }
- };
- const UpdateShiftPlan = async (body, id) => {
- setLoading(true);
- try {
- const data = await Chapar.put(
- `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`,
- body,
-
- {
- headers: {
- Authorization: getToken(),
- },
- }
- );
- toast.success(`شیفت ویرایش شد`, {
- position: "bottom-right",
- closeOnClick: true,
- });
-
- setLoading(false);
- setShiftPlanData(id);
- } catch ({ error, status }) {
- toast.error(`${error?.response?.data?.message}`, {
- position: "bottom-right",
- closeOnClick: true,
- });
- setLoading(false);
- }
- };
-
const GetShift = async (id) => {
setLoading(true);
try {
@@ -697,7 +650,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateSection = async (body) => {
setLoading(true);
try {
@@ -822,7 +774,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateRoutine = async (body) => {
setLoading(true);
try {
@@ -927,7 +878,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const GetRoutineShiftPlan = async (id, time) => {
setLoading(true);
try {
@@ -951,6 +901,56 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
+ const GetShiftPlan = async (id) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.get(
+ `${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}`,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ setShiftPlanData(data);
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+ const UpdateShiftPlan = async (body, id) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.put(
+ `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`,
+ body,
+
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ toast.success(`شیفت ویرایش شد`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+
+ setLoading(false);
+ setShiftPlanData(id);
+ router.push("/shifts");
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
const CreateShifPlan = async (body) => {
setLoading(true);
try {
@@ -967,6 +967,8 @@ export default function RootLayout({ children }) {
position: "bottom-right",
closeOnClick: true,
});
+
+ router.push("/shifts");
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
@@ -975,7 +977,31 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
+ const GetShifPlans = async (page) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.get(
+ `${process.env.NEXT_PUBLIC_API_URL}/shift/plan?page=${page}`,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ console.log(data);
+
+ setShifPlansData(data);
+
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
const DeleteRoutine = async (id) => {
setLoading(true);
try {
@@ -1000,7 +1026,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreatePosition = async (body) => {
setLoading(true);
try {
@@ -1125,7 +1150,6 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
-
const CreateTask = async (body) => {
setLoading(true);
try {
@@ -1427,6 +1451,76 @@ export default function RootLayout({ children }) {
}
};
+ const ReportShiftPlan = async (shiftPlanId) => {
+ setLoading(true);
+ try {
+ const response = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/report/shift/plan/${shiftPlanId}`,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to download report");
+ }
+
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "report.xlsx"; // Change the filename if needed
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+
+ setLoading(false);
+ } catch (error) {
+ toast.error(error.message, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+
+ const ReportTask = async () => {
+ setLoading(true);
+ try {
+ const response = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/report/task`,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to download report");
+ }
+
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "report.xlsx"; // Change the filename if needed
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+
+ setLoading(false);
+ } catch (error) {
+ toast.error(error.message, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+
useEffect(() => {
console.log(`
bbbbbbbb
@@ -1526,6 +1620,9 @@ export default function RootLayout({ children }) {
pageGetTasks,
stopGetActivities,
pageGetActivity,
+ shiftPlansData,
+ BottomSheetReportOpen,
+ reportDetail,
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
@@ -1641,6 +1738,12 @@ export default function RootLayout({ children }) {
setPageGetTasks,
setStopGetActivities,
setPageGetActivity,
+ setShifPlansData,
+ GetShifPlans,
+ setBottomSheetReportOpen,
+ setReportDetail,
+ ReportShiftPlan,
+ ReportTask,
}}
>
@@ -1649,6 +1752,7 @@ export default function RootLayout({ children }) {
{shouldRenderComponent &&
{e?.title}
- -
- {" "}
-
+
{e?.title}
+
{" "}
+ {" "}
+
{" "} - بسته شده + گزارش شیفت{" "}
روتین را انتخاب کنید
{e.name}
+{e.name}
تاریخ را انتخاب کنید
@@ -309,14 +339,13 @@ const Calendar = () => { ))} > - )} -
شیفت را انتخاب کنید
{e?.title}
+{e?.title}
ویرایش برای{" "} @@ -376,6 +405,9 @@ const Calendar = () => {
پرسنل را انتخاب کنید
+- { - usersData.find((b) => b.userId == item?.value) - ?.firstName - } -
++ { + usersData.find((b) => b.userId == item?.value) + ?.firstName + } +
++ سوپروایزر را انتخاب کنید + (ضروری) +
++ شیفت توسط سوپروایزر بسته میشود لطفا برای هر شیفت آن را مشخص کنید +
+غیر فعال کردن شیفت
++ با خاموش کردن شیفت فعالیت ها برای افراد داخل شیفت خاموش میشود{" "} +
+
+
+ {" "} + {e.shiftTitle} +
+ +
+