brizco handle phe page . handle activities

main
حسین معصومی پور 2024-08-11 08:45:48 +03:30
parent 5d221c1a2c
commit 8681ba8d93
13 changed files with 325 additions and 181 deletions

12
.env
View File

@ -1,8 +1,8 @@
NODE_ENV="development"
NEXT_PUBLIC_SERVER_URL=http://192.168.1.10:32767
NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.10:32767
NEXT_PUBLIC_API_URL=http://192.168.1.10:32767/api
# NEXT_PUBLIC_SERVER_URL=http://192.168.1.106:32767
# NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.106:32767
# NEXT_PUBLIC_API_URL=http://192.168.1.106:32767/api
# NEXT_PUBLIC_VERSION=1.0.1.2
# SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99
# NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages
@ -14,9 +14,9 @@ NEXT_PUBLIC_API_URL=http://192.168.1.10:32767/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_VERSION=1.0.3.4
# NEXT_PUBLIC_API_URL_IMAGE=https://api.macsonline.ir/Files/ReportImages
# NEXT_PUBLIC_API_URL_BackUp=https://api.macsonline.ir/Files/Back1.10

View File

@ -14,5 +14,5 @@ CMD ["/app/node_modules/.bin/next", "start"]
# docker build -f Dockerfile.emergency -t registry.vnfco.ir/brizco/web:1.0.3.4 .
# docker push registry.vnfco.ir/brizco/web:1.0.3.4
# docker build -f Dockerfile.emergency -t registry.vnfco.ir/brizco/web:1.0.5.6 .
# docker push registry.vnfco.ir/brizco/web:1.0.5.6

View File

@ -6,16 +6,17 @@ import PersianNumber from "../../../plugins/PersianNumber";
import FormatJalaliDate from "plugins/FormatJalaliDate/page";
import moment from "jalali-moment";
const CoffeeBrewCard = ({ data }) => {
console.log("data", data);
const CoffeeBrewCard = ({ data, last }) => {
const today = new Date();
console.log(today, data?.logAt);
const formattedDate = FormatJalaliDate(data?.logAt, true);
return (
<div className="bg-gray-50 rounded-lg p-4 mt-3 ">
<div
className={` rounded-lg p-4 mt-3 ${
last ? "bg-gray-200 border border-primary-600" : "bg-gray-50"
} `}
>
<div className="flex justify-between">
<div>
<div className="flex">
@ -33,7 +34,7 @@ const CoffeeBrewCard = ({ data }) => {
<p className="mb-0 text-[13px] font-medium w-fit px-2 mt-1 ">
<small className="!text-[12px] text-gray-400">
{data.logBy}{" "}
{data?.logBy}{" "}
</small>
</p>
</div>
@ -47,8 +48,8 @@ const CoffeeBrewCard = ({ data }) => {
<div className=" w-full relative mr-5">
<p className="mb-0 text-gray-500 text-left pl-[55px] ">
BCG : {data.ratio} | OEG : {data.extractionTime} | ET :{" "}
{data.finalYield}
BCG : {data?.ratio} | OEG : {data?.extractionTime} | ET :{" "}
{data?.finalYield}
</p>
</div>
</div>

View File

@ -20,16 +20,21 @@ const TasksEmployees = () => {
const [listTaskActive, setListTaskActive] = useState(-1);
const handleInfiniteNextFetchTask = () => {
const handleInfiniteNextFetchTask = (id) => {
CTX.setPageGetTasks((e) => e + 1);
CTX.GetTasks(pageGetTasks + 1);
CTX.GetTasks(pageGetTasks + 1, id);
};
const handleListTaskActive = (id, index) => {
if (index == listTaskActive) {
setListTaskActive(-1);
} else {
setListTaskActive(index);
CTX.setStopGetTasks(false);
CTX.setPageGetTasks(0);
setListTaskActive(-1);
setTimeout(() => {
setListTaskActive(index);
}, 100);
CTX.GetTasks(0, id);
}
};
@ -91,7 +96,7 @@ const TasksEmployees = () => {
{tasksData.length != 0 ? (
<InfiniteScroll
dataLength={tasksData.length}
next={handleInfiniteNextFetchTask}
next={() => handleInfiniteNextFetchTask(e.id)}
hasMore={!stopGetTasks}
>
<TasksCard

View File

@ -3,7 +3,7 @@
"version": "0.2.7",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start",
"lint": "next lint"

View File

@ -14,14 +14,14 @@ import PersianNumber from "plugins/PersianNumber";
const BottomFilterActivities = ({
dateQueryFilterValue,
setActiveStaffIdValue,
setDateQueryFilterValue,
activeStaffId,
setActiveStaff,
}) => {
const CTX = useContext(AppContext);
const handleFilterActivity = (num) => {
setActiveStaffIdValue(num);
setDateQueryFilterValue(num);
};
const handleChangeFilter = () => {

View File

@ -23,7 +23,6 @@ ChartJS.register(
);
const CoffeeBrewChart = ({ data }) => {
console.log("data", data);
const chartData = {
labels: data?.map((entry) =>
new Date(entry?.logAt).toLocaleDateString("fa-IR", {

View File

@ -1,5 +1,5 @@
const HasPermission = (per, permissions) => {
return permissions?.includes(per);
return Array.isArray(permissions) && permissions.includes(per);
};
export default HasPermission;

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because one or more lines are too long

View File

@ -17,9 +17,10 @@ const page = () => {
const CTX = useContext(AppContext);
const coffeeBrewData = CTX.state.coffeeBrewData;
const [ratio, setRatio] = useState(null);
const [extractionTime, setExtractionTime] = useState(null);
const [finalYield, setFinalYield] = useState(null);
const [ratio, setRatio] = useState("");
const [extractionTime, setExtractionTime] = useState("");
const [finalYield, setFinalYield] = useState("");
const [, forceUpdate] = useState();
const validator = useRef(
new SimpleReactValidator({
@ -48,23 +49,42 @@ const page = () => {
const CreateBrew = async () => {
CTX.setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/brew/CoffeeBrew`,
JSON.stringify(body)
);
toast.success(`ادجاست ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
clear();
CTX.setLoading(false);
CTX.GetCoffeeBrewData();
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
if (validator.current.allValid()) {
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/brew/CoffeeBrew`,
JSON.stringify(body)
);
toast.success(`ادجاست ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
CTX.setLoading(false);
CTX.GetCoffeeBrewData();
// clear();
// validator.current.hideMessages();
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
CTX.setLoading(false);
}
} else {
toast.error("پرکردن همه ی فیلد ها واجب است", {
position: "bottom-right",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
validator.current.showMessages();
forceUpdate(1);
CTX.setLoading(false);
}
};
@ -73,6 +93,8 @@ const page = () => {
CTX.GetCoffeeBrewData();
}, []);
console.log("coffeeBrewData", coffeeBrewData);
return (
<>
{" "}
@ -139,7 +161,6 @@ const page = () => {
mt={"5"}
/>
</div>
<div className="">
<Input
lable="ET | گرماژ عصاره خروجی"
@ -162,7 +183,6 @@ const page = () => {
mt={"5"}
/>
</div>
<div>
{" "}
<Buttonbriz
@ -172,13 +192,49 @@ const page = () => {
buttonEvent={() => CreateBrew()}
/>
</div>
<h3 className="text-right px-3 pb-1 font-medium mt-7 text-sm">
تاریخچه ادجاست ها
</h3>
<div className="flex justify-between mt-4">
<div className=" ">
<div className=" p-3 rounded-2xl">
<div className="w-5 p-1 rounded-full bg-[#4bc0c0]"></div>
<div>
<p className="mb-0 text-gray-400 text-[12px] mt-1 font-medium text-center">
گرماژ قهوه{" "}
</p>
</div>
</div>
</div>
<div className="w-[2px] h-9 bg-primary-100 opacity-75 mt-4"></div>
<div className="">
<div className=" p-3 rounded-2xl">
<div className="w-5 p-1 rounded-full bg-[#9966ff]"></div>
<div>
<p className="mb-0 text-gray-400 text-[12px] mt-1 font-medium text-center">
زمان عصاره گیری{" "}
</p>
</div>
</div>
</div>
<div className="w-[2px] h-9 bg-primary-100 opacity-75 mt-4"></div>
<div className=" ">
<div className=" p-3 rounded-2xl">
<div className="w-5 p-1 rounded-full bg-[#ff9f40]"></div>
<div>
<p className="mb-0 text-gray-400 text-[12px] mt-1 font-medium text-center">
گرماژ عصاره خروجی{" "}
</p>
</div>
</div>
</div>
</div>
<CoffeeBrewChart data={coffeeBrewData?.pastRecipes} />
<CoffeeBrewCard data={coffeeBrewData?.currentRecipe} last />
{coffeeBrewData?.pastRecipes?.map((e) => (
<CoffeeBrewCard data={e} />
))}

View File

@ -7,6 +7,7 @@ import moment from "jalali-moment";
import { useParams, useSearchParams } from "next/navigation";
import Buttonbriz from "plugins/Buttonbriz/page";
import GoBack from "plugins/GoBack/page";
import NothingFound from "plugins/NothingFound/page";
import PersianNumber from "plugins/PersianNumber";
import Slider from "rc-slider";
import React, { useCallback, useContext, useEffect, useState } from "react";
@ -20,7 +21,9 @@ const CompleteShift = () => {
const [closeShiftScore, setCloseShiftScore] = useState(50);
const [activeShifPlan, setActiveShifPlan] = useState(-1);
const [selectDayForShift, setSelectDayForShift] = useState(-1);
const [dateQueryFilterValue, setDateQueryFilterValue] = useState(1);
const [activeStaff, setActiveStaff] = useState(-1);
const [activeStaffId, setActiveStaffId] = useState(-1);
const currentDate = new Date();
@ -28,6 +31,8 @@ const CompleteShift = () => {
const activitiesData = CTX.state.activitiesData;
const stopGetActivities = CTX.state.stopGetActivities;
const pageGetActivity = CTX.state.pageGetActivity;
const userStaffData = CTX.state.userStaffData;
const activities = CTX.state.activitiesData;
const circularHandleStyle = {
backgroundColor: "green",
@ -70,6 +75,7 @@ const CompleteShift = () => {
return tomorrow.format("D MMMM YYYY");
};
//handleOpenShift
const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => {
CTX.setStopGetActivities(false);
CTX.setPageGetActivity(0);
@ -84,52 +90,50 @@ const CompleteShift = () => {
closeOnClick: true,
});
} else {
handleActivityCloseShift(id, index);
}
};
const handleActivityCloseShift = (id, index) => {
CTX.setCompleteActivities([]);
setCloseShiftScore(50);
if (activeShifPlan == index) {
setActiveShifPlan(-1);
} else {
setActiveShifPlan(index);
if (selectDayForShift == 0) {
CTX.GetActivity(
moment().locale("fa").subtract(1, "day").unix() * 1000,
siftsData[index].currentShiftPlanId,
0
);
} else if (selectDayForShift == 1) {
CTX.GetActivity(
moment().locale("fa").startOf("day").unix() * 1000,
siftsData[index].currentShiftPlanId,
0
);
} else if (selectDayForShift == 2) {
CTX.GetActivity(
moment().locale("fa").add(1, "day").unix() * 1000,
siftsData[index].currentShiftPlanId,
0
);
CTX.setCompleteActivities([]);
setCloseShiftScore(50);
if (activeShifPlan == index) {
setActiveShifPlan(-1);
} else {
setActiveShifPlan(index);
CTX.GetUserStaff(dateQueryFilterValue);
}
}
};
const habdleActiveStaff = (indexShift, num, userId) => {
if (num == activeStaff) {
setActiveStaff(-1);
} else {
CTX.setStopGetActivities(false);
CTX.setPageGetActivity(0);
setActiveStaffId(userId);
setActiveStaff(num);
CTX.GetActivity(
null,
siftsData[indexShift].currentShiftPlanId,
0,
dateQueryFilterValue,
userId
);
}
};
//getShift
const handleDayCloseShift = (index) => {
setSelectDayForShift(index);
setDateQueryFilterValue(index);
setActiveShifPlan(-1);
if (index == 0) {
if (index == 2) {
CTX.GetShifts(moment().locale("fa").subtract(1, "day").unix() * 1000);
} else if (index == 1) {
CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000);
} else if (index == 2) {
} else if (index == 3) {
CTX.GetShifts(moment().locale("fa").add(1, "day").unix() * 1000);
}
};
//close Shift
const handleCloseShift = useCallback(
() => {
CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
@ -141,6 +145,7 @@ const CompleteShift = () => {
body
);
//goReport
const handleGoToReport = (title, shiftId) => {
CTX.setReportDetail({
title: title,
@ -152,9 +157,9 @@ const CompleteShift = () => {
useEffect(() => {
if (day == "tomorrow") {
handleDayCloseShift(2);
handleDayCloseShift(3);
} else if (day == "yesterday") {
handleDayCloseShift(0);
handleDayCloseShift(2);
} else {
handleDayCloseShift(1);
}
@ -172,28 +177,17 @@ const CompleteShift = () => {
}
}, [activitiesData]);
//scrollActivity
const handleInfiniteNextFetchActivity = () => {
CTX.setPageGetActivity((e) => e + 1);
if (selectDayForShift == 0) {
CTX.GetActivity(
moment().locale("fa").subtract(1, "day")?.unix() * 1000,
siftsData[activeShifPlan].currentShiftPlanId,
pageGetActivity + 1
);
} else if (selectDayForShift == 1) {
CTX.GetActivity(
moment().locale("fa").startOf("day").unix() * 1000,
siftsData[activeShifPlan].currentShiftPlanId,
pageGetActivity + 1
);
} else if (selectDayForShift == 2) {
CTX.GetActivity(
moment().locale("fa").add(1, "day").unix() * 1000,
siftsData[activeShifPlan].currentShiftPlanId,
pageGetActivity + 1
);
}
CTX.GetActivity(
null,
siftsData[indexShift].currentShiftPlanId,
pageGetActivity + 1,
dateQueryFilterValue,
userId
);
};
return (
@ -213,17 +207,17 @@ const CompleteShift = () => {
<div className="flex overflow-auto whitespace-nowrap mb-7 mt-4">
<div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${
selectDayForShift == 0
dateQueryFilterValue == 2
? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400"
}`}
onClick={() => handleDayCloseShift(0)}
onClick={() => handleDayCloseShift(2)}
>
<PersianNumber number={getYesterdayPersianDate()} />
</div>
<div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${
selectDayForShift == 1
dateQueryFilterValue == 1
? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400"
}`}
@ -237,11 +231,11 @@ const CompleteShift = () => {
<div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${
selectDayForShift == 2
dateQueryFilterValue == 3
? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400"
}`}
onClick={() => handleDayCloseShift(2)}
onClick={() => handleDayCloseShift(3)}
>
<PersianNumber number={getTomorrowPersianDate()} />
</div>
@ -318,18 +312,78 @@ const CompleteShift = () => {
)}
</div>
</div>
{activeShifPlan == index && (
<>
<InfiniteScroll
dataLength={siftsData[activeShifPlan]?.totalActivitiesCount}
next={handleInfiniteNextFetchActivity}
hasMore={!stopGetActivities}
>
{activitiesData?.map((e) => (
<ActivityCardCloseShift data={e} />
))}
</InfiniteScroll>
{" "}
{userStaffData?.map((data, indexStaff) => (
<>
<div
className={`px-1 rounded-2xl ${
activeStaff == indexStaff ? "pt-1" : "py-1"
}`}
key={indexStaff}
onClick={() =>
habdleActiveStaff(index, indexStaff, data?.id)
}
>
<div
className={`flex justify-between bg-gray-50 p-2 ${
activeStaff == indexStaff
? " rounded-b-0 rounded-t-xl"
: "rounded-xl"
}`}
// onClick={() => handleListTaskActive(e?.id, index)}
>
<p className="mb-0 text-[13px] mt-1">
{data?.firstName + " " + data?.lastName}
</p>
<div className="bg-gray-100 w-[30px] h-[30px] rounded-xl">
<svg
width="11"
height="11"
viewBox="0 0 151 89"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={`opacity-80 mt-2 mx-auto tr03 ${
activeStaff == indexStaff ? "rotate-180" : ""
}`}
>
<path
d="M13.0444 13.1674L75.3606 75.8506L138.044 13.5345"
stroke="#424242"
stroke-opacity="0.81"
stroke-width="25"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
</div>
</div>
<>
{activeStaff == indexStaff && (
<div className=" mt-3">
{activities.length != 0 ? (
<InfiniteScroll
dataLength={activities.length}
next={handleInfiniteNextFetchActivity}
hasMore={!stopGetActivities}
>
{activities?.map((e) => (
<ActivityCardCloseShift data={e} />
))}
</InfiniteScroll>
) : (
<NothingFound />
)}
</div>
)}
</>
</>
))}
<div className=" mt-5">
<div className=" p-3 relative top-[20px] ">
<Slider

View File

@ -21,13 +21,16 @@ import NothingFound from "plugins/NothingFound/page";
const page = () => {
const CTX = useContext(AppContext);
const activities = CTX.state.activitiesData;
const permissions = CTX.state.profile?.permissions;
const profile = CTX.state.profile;
const pageGetActivity = CTX.state.pageGetActivity;
const stopGetActivities = CTX.state.stopGetActivities;
const userStaffData = CTX.state.userStaffData;
const [activeStaff, setActiveStaff] = useState(-1);
const [activeStaffId, setActiveStaffId] = useState(-1);
const [dateQueryFilterValue, setActiveStaffIdValue] = useState(1);
const [dateQueryFilterValue, setDateQueryFilterValue] = useState(1);
const handleInfiniteNextFetchActivity = () => {
CTX.setPageGetActivity((e) => e + 1);
@ -53,9 +56,15 @@ const page = () => {
};
useEffect(() => {
CTX.GetUserStaff(dateQueryFilterValue);
CTX.GetUnReadNotif();
}, []);
if (permissions?.length > 0) {
if (HasPermission("ManageUsers", permissions)) {
CTX.GetUserStaff(dateQueryFilterValue);
} else {
CTX.GetActivity(null, null, 0, dateQueryFilterValue, profile?.user?.id);
setActiveStaff(-2);
}
}
}, [permissions]);
return (
<div className="pb-20">
@ -137,74 +146,94 @@ const page = () => {
</div>
</div>
</div>
{userStaffData?.map((e, index) => (
<>
<div
className={`px-1 rounded-2xl ${
activeStaff == index ? "pt-1" : "py-1"
}`}
key={index}
onClick={() => habdleActiveStaff(index, e?.id)}
>
<div
className={`flex justify-between bg-gray-50 p-2 ${
activeStaff == index
? " rounded-b-0 rounded-t-xl"
: "rounded-xl"
}`}
// onClick={() => handleListTaskActive(e?.id, index)}
{activeStaff == -2 ? (
<div className=" mt-3">
{activities.length != 0 ? (
<InfiniteScroll
dataLength={activities.length}
next={handleInfiniteNextFetchActivity}
hasMore={!stopGetActivities}
>
<p className="mb-0 text-[13px] mt-1">
{e?.firstName + " " + e?.lastName}
</p>
<div className="bg-gray-100 w-[30px] h-[30px] rounded-xl">
<svg
width="11"
height="11"
viewBox="0 0 151 89"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={`opacity-80 mt-2 mx-auto tr03 ${
activeStaff == index ? "rotate-180" : ""
}`}
>
<path
d="M13.0444 13.1674L75.3606 75.8506L138.044 13.5345"
stroke="#424242"
stroke-opacity="0.81"
stroke-width="25"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
</div>
</div>
{activeStaff == index && (
<div className=" mt-3">
{activities.length != 0 ? (
<InfiniteScroll
dataLength={activities.length}
next={handleInfiniteNextFetchActivity}
hasMore={!stopGetActivities}
>
{activities?.map((e) => (
<ActivityCard data={e} />
))}
</InfiniteScroll>
) : (
<NothingFound />
)}
</div>
{activities?.map((e) => (
<ActivityCard data={e} />
))}
</InfiniteScroll>
) : (
<NothingFound />
)}
</div>
) : (
<>
{userStaffData?.map((e, index) => (
<>
<div
className={`px-1 rounded-2xl ${
activeStaff == index ? "pt-1" : "py-1"
}`}
key={index}
onClick={() => habdleActiveStaff(index, e?.id)}
>
<div
className={`flex justify-between bg-gray-50 p-2 ${
activeStaff == index
? " rounded-b-0 rounded-t-xl"
: "rounded-xl"
}`}
// onClick={() => handleListTaskActive(e?.id, index)}
>
<p className="mb-0 text-[13px] mt-1">
{e?.firstName + " " + e?.lastName}
</p>
<div className="bg-gray-100 w-[30px] h-[30px] rounded-xl">
<svg
width="11"
height="11"
viewBox="0 0 151 89"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={`opacity-80 mt-2 mx-auto tr03 ${
activeStaff == index ? "rotate-180" : ""
}`}
>
<path
d="M13.0444 13.1674L75.3606 75.8506L138.044 13.5345"
stroke="#424242"
stroke-opacity="0.81"
stroke-width="25"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
</div>
</div>
{activeStaff == index && (
<div className=" mt-3">
{activities.length != 0 ? (
<InfiniteScroll
dataLength={activities.length}
next={handleInfiniteNextFetchActivity}
hasMore={!stopGetActivities}
>
{activities?.map((e) => (
<ActivityCard data={e} />
))}
</InfiniteScroll>
) : (
<NothingFound />
)}
</div>
)}
</>
))}
</>
))}
)}
</div>
<BottomFilterActivities
setActiveStaffIdValue={setActiveStaffIdValue}
setDateQueryFilterValue={setDateQueryFilterValue}
dateQueryFilterValue={dateQueryFilterValue}
activeStaffId={activeStaffId}
setActiveStaff={setActiveStaff}