upd
This commit is contained in:
@@ -9,26 +9,21 @@ import {
|
||||
isEqual,
|
||||
} from "date-fns";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import Card from "../components/Card";
|
||||
import EmptyCard from "../components/EmptyCard";
|
||||
import TabButton from "../components/TabButton";
|
||||
import api from "../utils/api";
|
||||
import { ru } from "date-fns/locale";
|
||||
import { Transition } from "react-transition-group";
|
||||
import _ from "lodash";
|
||||
import useStore from "../stores/useStore";
|
||||
import useAuthStore from "../stores/useAuthStore";
|
||||
import Menu from "../components/Menu";
|
||||
import Button from "../components/Button";
|
||||
import Calendar from "../components/Calendar";
|
||||
import Managers from "../components/Managers";
|
||||
import Schedules from "../components/Schedules";
|
||||
import SpinnerIcon from "../components/icons/SpinnerIcon";
|
||||
import ModalContainer from "../components/ModalContainer";
|
||||
import ChevronLeftIcon from "../components/icons/ChevronLeftIcon";
|
||||
import ChevronRightIcon from "../components/icons/ChevronRightIcon";
|
||||
import IUser from "../types/IUser";
|
||||
import IError from "../types/IError";
|
||||
import Schedule from "../components/Schedule";
|
||||
|
||||
function DashboardPage() {
|
||||
const { user } = useAuthStore();
|
||||
@@ -46,16 +41,12 @@ function DashboardPage() {
|
||||
selectedDay,
|
||||
setSelectedDay,
|
||||
} = useStore();
|
||||
const [duration, setDuration] = useState<number>();
|
||||
const [, setDuration] = useState<number>();
|
||||
const [scheduledSessions, setScheduledSessions] = useState<any[]>();
|
||||
const [generatedScheduledSessions, setGeneratedScheduledSessions] =
|
||||
useState<any[]>();
|
||||
const [, setGeneratedScheduledSessions] = useState<any[]>();
|
||||
const [dateTimes, setDateTimes] = useState<Date[]>();
|
||||
const [currentTime, setCurrentTime] = useState<string>(
|
||||
format(new Date(), "HH:mm")
|
||||
);
|
||||
const [isLoadingScheduledSessions, setIsLoadingScheduledSessions] =
|
||||
useState(true);
|
||||
const [, setCurrentTime] = useState<string>(format(new Date(), "HH:mm"));
|
||||
const [, setIsLoadingScheduledSessions] = useState(true);
|
||||
const scheduledSessionsRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
function selectNextDay() {
|
||||
@@ -231,33 +222,33 @@ function DashboardPage() {
|
||||
if (useLoader) setIsLoadingScheduledSessions(false);
|
||||
}
|
||||
|
||||
async function updateScheduledSessionManager(
|
||||
scheduledSessionId: string,
|
||||
managerId: string | null
|
||||
) {
|
||||
if (!company || !scheduledSessions) return;
|
||||
// async function updateScheduledSessionManager(
|
||||
// scheduledSessionId: string,
|
||||
// managerId: string | null
|
||||
// ) {
|
||||
// if (!company || !scheduledSessions) return;
|
||||
|
||||
try {
|
||||
const result: any = await api
|
||||
.put(
|
||||
`companies/${company.id}/scheduled_sessions/${scheduledSessionId}`,
|
||||
{
|
||||
json: { userId: managerId },
|
||||
}
|
||||
)
|
||||
.json();
|
||||
// try {
|
||||
// const result: any = await api
|
||||
// .put(
|
||||
// `companies/${company.id}/scheduled_sessions/${scheduledSessionId}`,
|
||||
// {
|
||||
// json: { userId: managerId },
|
||||
// }
|
||||
// )
|
||||
// .json();
|
||||
|
||||
setScheduledSessions(
|
||||
scheduledSessions.map((scheduledSession) =>
|
||||
scheduledSession.id === result.id ? result : scheduledSession
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
console.log("Error: ", error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// setScheduledSessions(
|
||||
// scheduledSessions.map((scheduledSession) =>
|
||||
// scheduledSession.id === result.id ? result : scheduledSession
|
||||
// )
|
||||
// );
|
||||
// } catch (error) {
|
||||
// if (error instanceof Error) {
|
||||
// console.log("Error: ", error.message);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async function getSchedules() {
|
||||
if (!company || !selectedBuild) return;
|
||||
@@ -316,8 +307,8 @@ function DashboardPage() {
|
||||
}, [selectedDay, selectedBuild]);
|
||||
|
||||
return (
|
||||
<div className="main h-screen flex">
|
||||
<div className="left flex flex-col w-full">
|
||||
<div className="flex h-screen main">
|
||||
<div className="flex flex-col w-full left">
|
||||
<div className="flex bg-[#F0F1F2]">
|
||||
<Menu />
|
||||
{builds?.map((build) => (
|
||||
@@ -358,7 +349,7 @@ function DashboardPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex bg-[#F2F2F2]">
|
||||
{/* <div className="flex bg-[#F2F2F2]">
|
||||
<div className="w-[84px] h-[40px] flex justify-center items-center text-sm font-semibold bg-white border-r border-b border-[#DAE0E5]">
|
||||
{currentTime}
|
||||
</div>
|
||||
@@ -371,9 +362,9 @@ function DashboardPage() {
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
<div
|
||||
{/* <div
|
||||
ref={scheduledSessionsRef}
|
||||
className={`overflow-y-auto overflow-x-hidden flex-1 bg-[#F2F2F2] border-r border-[#DAE0E5]`}
|
||||
>
|
||||
@@ -443,7 +434,14 @@ function DashboardPage() {
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
{selectedBuild?.sessionLimit && scheduledSessions && (
|
||||
<Schedule
|
||||
slots={selectedBuild.sessionLimit}
|
||||
events={scheduledSessions}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="right w-[384px] flex flex-col">
|
||||
@@ -457,9 +455,9 @@ function DashboardPage() {
|
||||
Статистика
|
||||
</button>
|
||||
</div>
|
||||
<div className="overflow-y-auto overflow-x-hidden">
|
||||
<div className="overflow-x-hidden overflow-y-auto">
|
||||
<Calendar />
|
||||
<Schedules />
|
||||
{/* <Schedules /> */}
|
||||
<Managers />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user