This commit is contained in:
2024-06-05 19:14:56 +05:00
parent acae2e5a4c
commit e4331fb31f
22 changed files with 799 additions and 293 deletions
+16 -13
View File
@@ -15,7 +15,6 @@ import {
parse,
addDays,
subDays,
parseISO,
isWithinInterval,
} from "date-fns";
import Button from "../components/Button";
@@ -24,8 +23,9 @@ import { Transition } from "react-transition-group";
import SpinnerIcon from "../components/icons/SpinnerIcon";
import useModalStore from "../stores/useModalStore";
import ModalContainer from "../components/ModalContainer";
import CreateSchedule from "../components/modals/CreateSchedule";
import CreateScheduleModal from "../components/modals/CreateScheduleModal";
import MoreIcon from "../components/icons/MoreIcon";
import ISchedule from "../types/ISchedule";
function DashboardPage() {
const [user, setAccessToken] = useAuthStore((state) => [
@@ -36,7 +36,7 @@ function DashboardPage() {
const [selectedBuildManagers, setSelectedBuildManagers] = useState<any[]>();
const [builds, setBuilds] = useState<any[]>();
const [selectedBuild, setSelectedBuild] = useState<{ [key: string]: any }>();
const [schedules, setSchedules] = useState<any[]>();
const [schedules, setSchedules] = useState<ISchedule[]>();
const [scheduledSessions, setScheduledSessions] = useState<any[]>();
const [generatedScheduledSessions, setGeneratedScheduledSessions] =
useState<any[][]>();
@@ -67,16 +67,20 @@ function DashboardPage() {
}
useEffect(() => {
console.log("schedules", schedules);
if (!selectedDate || !selectedBuild || !schedules?.length) return;
const foundSchedule = schedules.find(
(schedule) =>
isWithinInterval(selectedDate, {
start: parseISO(schedule.startDate),
end: parseISO(schedule.endDate),
start: new Date(schedule.startDate),
end: addDays(new Date(schedule.startDate), 14),
}) && selectedBuild.id === schedule.buildId
);
console.log("foundSchedule", foundSchedule);
if (foundSchedule) {
const startDateTime = parse(
foundSchedule.startTime,
@@ -477,20 +481,19 @@ function DashboardPage() {
<div key={schedule.id} className="flex flex-col gap-3 text-xs">
<p className="font-semibold flex gap-1">
<span>
{format(parseISO(schedule.startDate), "dd.MM.yyyy")}
Действует с{" "}
{format(new Date(schedule.startDate), "dd.MM.yyyy")}
</span>
<span>-</span>
{/* <span>-</span> */}
<span>
{format(parseISO(schedule.endDate), "dd.MM.yyyy")}
{/* {format(parseISO(schedule.endDate), "dd.MM.yyyy")} */}
</span>
</p>
<div className="flex flex-col gap-2">
<div className="grid grid-cols-3">
<p className="col-span-2 text-[#77828C]">
Общее кол-во сеансов
</p>
<p>{schedule.sessionCount}</p>
<p className="col-span-2 text-[#77828C]">Сеансов в день</p>
<p>{schedule.sessionsPerDay}</p>
</div>
<div className="grid grid-cols-3">
<p className="col-span-2 text-[#77828C]">
@@ -517,7 +520,7 @@ function DashboardPage() {
className="w-full"
handleClick={() =>
setModal(
<CreateSchedule
<CreateScheduleModal
companyId={company?.id}
buildId={selectedBuild?.id}
schedules={schedules}