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" NODE_ENV="development"
NEXT_PUBLIC_SERVER_URL=http://192.168.1.10:32767 # NEXT_PUBLIC_SERVER_URL=http://192.168.1.106:32767
NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.10:32767 # NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.106:32767
NEXT_PUBLIC_API_URL=http://192.168.1.10:32767/api # NEXT_PUBLIC_API_URL=http://192.168.1.106:32767/api
# NEXT_PUBLIC_VERSION=1.0.1.2 # NEXT_PUBLIC_VERSION=1.0.1.2
# 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
@ -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_SERVER_URL=https://api.brizco.io
# NEXT_PUBLIC_PUBLIC_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=https://api.brizco.io/api
# NEXT_PUBLIC_VERSION=1.0.3.4 # NEXT_PUBLIC_VERSION=1.0.3.4
# 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/Back1.10 # 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 build -f Dockerfile.emergency -t registry.vnfco.ir/brizco/web:1.0.5.6 .
# docker push registry.vnfco.ir/brizco/web:1.0.3.4 # 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 FormatJalaliDate from "plugins/FormatJalaliDate/page";
import moment from "jalali-moment"; import moment from "jalali-moment";
const CoffeeBrewCard = ({ data }) => { const CoffeeBrewCard = ({ data, last }) => {
console.log("data", data);
const today = new Date(); const today = new Date();
console.log(today, data?.logAt);
const formattedDate = FormatJalaliDate(data?.logAt, true); const formattedDate = FormatJalaliDate(data?.logAt, true);
return ( 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 className="flex justify-between">
<div> <div>
<div className="flex"> <div className="flex">
@ -33,7 +34,7 @@ const CoffeeBrewCard = ({ data }) => {
<p className="mb-0 text-[13px] font-medium w-fit px-2 mt-1 "> <p className="mb-0 text-[13px] font-medium w-fit px-2 mt-1 ">
<small className="!text-[12px] text-gray-400"> <small className="!text-[12px] text-gray-400">
{data.logBy}{" "} {data?.logBy}{" "}
</small> </small>
</p> </p>
</div> </div>
@ -47,8 +48,8 @@ const CoffeeBrewCard = ({ data }) => {
<div className=" w-full relative mr-5"> <div className=" w-full relative mr-5">
<p className="mb-0 text-gray-500 text-left pl-[55px] "> <p className="mb-0 text-gray-500 text-left pl-[55px] ">
BCG : {data.ratio} | OEG : {data.extractionTime} | ET :{" "} BCG : {data?.ratio} | OEG : {data?.extractionTime} | ET :{" "}
{data.finalYield} {data?.finalYield}
</p> </p>
</div> </div>
</div> </div>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
const HasPermission = (per, permissions) => { const HasPermission = (per, permissions) => {
return permissions?.includes(per); return Array.isArray(permissions) && permissions.includes(per);
}; };
export default HasPermission; 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 CTX = useContext(AppContext);
const coffeeBrewData = CTX.state.coffeeBrewData; const coffeeBrewData = CTX.state.coffeeBrewData;
const [ratio, setRatio] = useState(null); const [ratio, setRatio] = useState("");
const [extractionTime, setExtractionTime] = useState(null); const [extractionTime, setExtractionTime] = useState("");
const [finalYield, setFinalYield] = useState(null); const [finalYield, setFinalYield] = useState("");
const [, forceUpdate] = useState();
const validator = useRef( const validator = useRef(
new SimpleReactValidator({ new SimpleReactValidator({
@ -48,23 +49,42 @@ const page = () => {
const CreateBrew = async () => { const CreateBrew = async () => {
CTX.setLoading(true); CTX.setLoading(true);
try {
const data = await Chapar.post( if (validator.current.allValid()) {
`${process.env.NEXT_PUBLIC_API_URL}/brew/CoffeeBrew`, try {
JSON.stringify(body) const data = await Chapar.post(
); `${process.env.NEXT_PUBLIC_API_URL}/brew/CoffeeBrew`,
toast.success(`ادجاست ساخته شد`, { JSON.stringify(body)
position: "bottom-right", );
closeOnClick: true, toast.success(`ادجاست ساخته شد`, {
}); position: "bottom-right",
clear(); closeOnClick: true,
CTX.setLoading(false); });
CTX.GetCoffeeBrewData();
} catch ({ error, status }) { CTX.setLoading(false);
toast.error(`${error?.response?.data?.message}`, { 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", position: "bottom-right",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true, closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
}); });
validator.current.showMessages();
forceUpdate(1);
CTX.setLoading(false); CTX.setLoading(false);
} }
}; };
@ -73,6 +93,8 @@ const page = () => {
CTX.GetCoffeeBrewData(); CTX.GetCoffeeBrewData();
}, []); }, []);
console.log("coffeeBrewData", coffeeBrewData);
return ( return (
<> <>
{" "} {" "}
@ -139,7 +161,6 @@ const page = () => {
mt={"5"} mt={"5"}
/> />
</div> </div>
<div className=""> <div className="">
<Input <Input
lable="ET | گرماژ عصاره خروجی" lable="ET | گرماژ عصاره خروجی"
@ -162,7 +183,6 @@ const page = () => {
mt={"5"} mt={"5"}
/> />
</div> </div>
<div> <div>
{" "} {" "}
<Buttonbriz <Buttonbriz
@ -172,13 +192,49 @@ const page = () => {
buttonEvent={() => CreateBrew()} buttonEvent={() => CreateBrew()}
/> />
</div> </div>
<h3 className="text-right px-3 pb-1 font-medium mt-7 text-sm"> <h3 className="text-right px-3 pb-1 font-medium mt-7 text-sm">
تاریخچه ادجاست ها تاریخچه ادجاست ها
</h3> </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} /> <CoffeeBrewChart data={coffeeBrewData?.pastRecipes} />
<CoffeeBrewCard data={coffeeBrewData?.currentRecipe} last />
{coffeeBrewData?.pastRecipes?.map((e) => ( {coffeeBrewData?.pastRecipes?.map((e) => (
<CoffeeBrewCard data={e} /> <CoffeeBrewCard data={e} />
))} ))}

View File

@ -7,6 +7,7 @@ import moment from "jalali-moment";
import { useParams, useSearchParams } from "next/navigation"; import { useParams, useSearchParams } from "next/navigation";
import Buttonbriz from "plugins/Buttonbriz/page"; import Buttonbriz from "plugins/Buttonbriz/page";
import GoBack from "plugins/GoBack/page"; import GoBack from "plugins/GoBack/page";
import NothingFound from "plugins/NothingFound/page";
import PersianNumber from "plugins/PersianNumber"; import PersianNumber from "plugins/PersianNumber";
import Slider from "rc-slider"; import Slider from "rc-slider";
import React, { useCallback, useContext, useEffect, useState } from "react"; import React, { useCallback, useContext, useEffect, useState } from "react";
@ -20,7 +21,9 @@ const CompleteShift = () => {
const [closeShiftScore, setCloseShiftScore] = useState(50); const [closeShiftScore, setCloseShiftScore] = useState(50);
const [activeShifPlan, setActiveShifPlan] = useState(-1); 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(); const currentDate = new Date();
@ -28,6 +31,8 @@ const CompleteShift = () => {
const activitiesData = CTX.state.activitiesData; const activitiesData = CTX.state.activitiesData;
const stopGetActivities = CTX.state.stopGetActivities; const stopGetActivities = CTX.state.stopGetActivities;
const pageGetActivity = CTX.state.pageGetActivity; const pageGetActivity = CTX.state.pageGetActivity;
const userStaffData = CTX.state.userStaffData;
const activities = CTX.state.activitiesData;
const circularHandleStyle = { const circularHandleStyle = {
backgroundColor: "green", backgroundColor: "green",
@ -70,6 +75,7 @@ const CompleteShift = () => {
return tomorrow.format("D MMMM YYYY"); return tomorrow.format("D MMMM YYYY");
}; };
//handleOpenShift
const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => { const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => {
CTX.setStopGetActivities(false); CTX.setStopGetActivities(false);
CTX.setPageGetActivity(0); CTX.setPageGetActivity(0);
@ -84,52 +90,50 @@ const CompleteShift = () => {
closeOnClick: true, closeOnClick: true,
}); });
} else { } else {
handleActivityCloseShift(id, index); CTX.setCompleteActivities([]);
} setCloseShiftScore(50);
}; if (activeShifPlan == index) {
const handleActivityCloseShift = (id, index) => { setActiveShifPlan(-1);
CTX.setCompleteActivities([]); } else {
setCloseShiftScore(50); setActiveShifPlan(index);
if (activeShifPlan == index) { CTX.GetUserStaff(dateQueryFilterValue);
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
);
} }
} }
}; };
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) => { const handleDayCloseShift = (index) => {
setSelectDayForShift(index); setDateQueryFilterValue(index);
setActiveShifPlan(-1); setActiveShifPlan(-1);
if (index == 0) { if (index == 2) {
CTX.GetShifts(moment().locale("fa").subtract(1, "day").unix() * 1000); CTX.GetShifts(moment().locale("fa").subtract(1, "day").unix() * 1000);
} else if (index == 1) { } else if (index == 1) {
CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000); 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); CTX.GetShifts(moment().locale("fa").add(1, "day").unix() * 1000);
} }
}; };
//close Shift
const handleCloseShift = useCallback( const handleCloseShift = useCallback(
() => { () => {
CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId); CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
@ -141,6 +145,7 @@ const CompleteShift = () => {
body body
); );
//goReport
const handleGoToReport = (title, shiftId) => { const handleGoToReport = (title, shiftId) => {
CTX.setReportDetail({ CTX.setReportDetail({
title: title, title: title,
@ -152,9 +157,9 @@ const CompleteShift = () => {
useEffect(() => { useEffect(() => {
if (day == "tomorrow") { if (day == "tomorrow") {
handleDayCloseShift(2); handleDayCloseShift(3);
} else if (day == "yesterday") { } else if (day == "yesterday") {
handleDayCloseShift(0); handleDayCloseShift(2);
} else { } else {
handleDayCloseShift(1); handleDayCloseShift(1);
} }
@ -172,28 +177,17 @@ const CompleteShift = () => {
} }
}, [activitiesData]); }, [activitiesData]);
//scrollActivity
const handleInfiniteNextFetchActivity = () => { const handleInfiniteNextFetchActivity = () => {
CTX.setPageGetActivity((e) => e + 1); CTX.setPageGetActivity((e) => e + 1);
if (selectDayForShift == 0) { CTX.GetActivity(
CTX.GetActivity( null,
moment().locale("fa").subtract(1, "day")?.unix() * 1000, siftsData[indexShift].currentShiftPlanId,
siftsData[activeShifPlan].currentShiftPlanId, pageGetActivity + 1,
pageGetActivity + 1 dateQueryFilterValue,
); userId
} 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
);
}
}; };
return ( return (
@ -213,17 +207,17 @@ const CompleteShift = () => {
<div className="flex overflow-auto whitespace-nowrap mb-7 mt-4"> <div className="flex overflow-auto whitespace-nowrap mb-7 mt-4">
<div <div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${ 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" ? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400" : "opacity-50 border-secondary-400"
}`} }`}
onClick={() => handleDayCloseShift(0)} onClick={() => handleDayCloseShift(2)}
> >
<PersianNumber number={getYesterdayPersianDate()} /> <PersianNumber number={getYesterdayPersianDate()} />
</div> </div>
<div <div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${ 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" ? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400" : "opacity-50 border-secondary-400"
}`} }`}
@ -237,11 +231,11 @@ const CompleteShift = () => {
<div <div
className={` shadow-sm relative block max-w-max ml-2 rounded-full mt-2 px-4 py-1 tr03 border-2 ${ 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" ? " bg-primary-200 border-secondary-300"
: "opacity-50 border-secondary-400" : "opacity-50 border-secondary-400"
}`} }`}
onClick={() => handleDayCloseShift(2)} onClick={() => handleDayCloseShift(3)}
> >
<PersianNumber number={getTomorrowPersianDate()} /> <PersianNumber number={getTomorrowPersianDate()} />
</div> </div>
@ -318,18 +312,78 @@ const CompleteShift = () => {
)} )}
</div> </div>
</div> </div>
{activeShifPlan == index && ( {activeShifPlan == index && (
<> <>
<InfiniteScroll {" "}
dataLength={siftsData[activeShifPlan]?.totalActivitiesCount} {userStaffData?.map((data, indexStaff) => (
next={handleInfiniteNextFetchActivity} <>
hasMore={!stopGetActivities} <div
> className={`px-1 rounded-2xl ${
{activitiesData?.map((e) => ( activeStaff == indexStaff ? "pt-1" : "py-1"
<ActivityCardCloseShift data={e} /> }`}
))} key={indexStaff}
</InfiniteScroll> 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=" mt-5">
<div className=" p-3 relative top-[20px] "> <div className=" p-3 relative top-[20px] ">
<Slider <Slider

View File

@ -21,13 +21,16 @@ import NothingFound from "plugins/NothingFound/page";
const page = () => { const page = () => {
const CTX = useContext(AppContext); const CTX = useContext(AppContext);
const activities = CTX.state.activitiesData; const activities = CTX.state.activitiesData;
const permissions = CTX.state.profile?.permissions;
const profile = CTX.state.profile;
const pageGetActivity = CTX.state.pageGetActivity; const pageGetActivity = CTX.state.pageGetActivity;
const stopGetActivities = CTX.state.stopGetActivities; const stopGetActivities = CTX.state.stopGetActivities;
const userStaffData = CTX.state.userStaffData; const userStaffData = CTX.state.userStaffData;
const [activeStaff, setActiveStaff] = useState(-1); const [activeStaff, setActiveStaff] = useState(-1);
const [activeStaffId, setActiveStaffId] = useState(-1); const [activeStaffId, setActiveStaffId] = useState(-1);
const [dateQueryFilterValue, setActiveStaffIdValue] = useState(1); const [dateQueryFilterValue, setDateQueryFilterValue] = useState(1);
const handleInfiniteNextFetchActivity = () => { const handleInfiniteNextFetchActivity = () => {
CTX.setPageGetActivity((e) => e + 1); CTX.setPageGetActivity((e) => e + 1);
@ -53,9 +56,15 @@ const page = () => {
}; };
useEffect(() => { useEffect(() => {
CTX.GetUserStaff(dateQueryFilterValue); if (permissions?.length > 0) {
CTX.GetUnReadNotif(); if (HasPermission("ManageUsers", permissions)) {
}, []); CTX.GetUserStaff(dateQueryFilterValue);
} else {
CTX.GetActivity(null, null, 0, dateQueryFilterValue, profile?.user?.id);
setActiveStaff(-2);
}
}
}, [permissions]);
return ( return (
<div className="pb-20"> <div className="pb-20">
@ -137,74 +146,94 @@ const page = () => {
</div> </div>
</div> </div>
</div> </div>
{userStaffData?.map((e, index) => ( {activeStaff == -2 ? (
<> <div className=" mt-3">
<div {activities.length != 0 ? (
className={`px-1 rounded-2xl ${ <InfiniteScroll
activeStaff == index ? "pt-1" : "py-1" dataLength={activities.length}
}`} next={handleInfiniteNextFetchActivity}
key={index} hasMore={!stopGetActivities}
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"> {activities?.map((e) => (
{e?.firstName + " " + e?.lastName} <ActivityCard data={e} />
</p> ))}
</InfiniteScroll>
<div className="bg-gray-100 w-[30px] h-[30px] rounded-xl"> ) : (
<svg <NothingFound />
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>
) : (
<>
{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> </div>
<BottomFilterActivities <BottomFilterActivities
setActiveStaffIdValue={setActiveStaffIdValue} setDateQueryFilterValue={setDateQueryFilterValue}
dateQueryFilterValue={dateQueryFilterValue} dateQueryFilterValue={dateQueryFilterValue}
activeStaffId={activeStaffId} activeStaffId={activeStaffId}
setActiveStaff={setActiveStaff} setActiveStaff={setActiveStaff}