This commit is contained in:
2024-06-10 19:35:04 +05:00
parent 7e692fee4c
commit ac1a705187
11 changed files with 298 additions and 70 deletions
+53 -39
View File
@@ -26,6 +26,8 @@ import ModalContainer from "../components/ModalContainer";
import CreateScheduleModal from "../components/modals/CreateScheduleModal";
import MoreIcon from "../components/icons/MoreIcon";
import ISchedule from "../types/ISchedule";
import Calendar from "../components/Calendar";
import ChevronUpIcon from "../components/icons/ChevronUpIcon";
function DashboardPage() {
const [user, setAccessToken] = useAuthStore((state) => [
@@ -66,43 +68,48 @@ function DashboardPage() {
setSelectedDate(new Date());
}
// useEffect(() => {
// console.log("schedules", schedules);
// if (!selectedDate || !selectedBuild || !schedules?.length) return;
// const foundSchedule = schedules.find(
// (schedule) =>
// isWithinInterval(selectedDate, {
// 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,
// "HH:mm",
// selectedDate
// );
// const endDateTime = parse(foundSchedule.endTime, "HH:mm", selectedDate);
// const step = foundSchedule.sessionDuration + foundSchedule.sessionBreak;
// setDateTimes(
// eachMinuteOfInterval(
// {
// start: startDateTime,
// end: endDateTime,
// },
// { step }
// )
// );
// } else {
// setDateTimes(undefined);
// setGeneratedScheduledSessions(undefined);
// }
// }, [selectedDate, selectedBuild, schedules]);
useEffect(() => {
console.log("schedules", schedules);
if (!selectedDate || !selectedBuild || !schedules?.length) return;
const foundSchedule = schedules.find(
(schedule) =>
isWithinInterval(selectedDate, {
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,
"HH:mm",
selectedDate
);
const endDateTime = parse(foundSchedule.endTime, "HH:mm", selectedDate);
const step = foundSchedule.sessionDuration + foundSchedule.sessionBreak;
setDateTimes(
eachMinuteOfInterval(
{
start: startDateTime,
end: endDateTime,
},
{ step }
)
);
} else {
setDateTimes(undefined);
setGeneratedScheduledSessions(undefined);
}
if (!schedules) return;
// const schedule = schedules.find(schedule => schedule.startDate);
}, [selectedDate, selectedBuild, schedules]);
async function getCompany() {
@@ -402,7 +409,7 @@ function DashboardPage() {
return (
<div
key={index2}
className="w-[84px] h-[128px] flex justify-center items-center text-sm font-semibold bg-[#F0F1F2] border-r border-b border-[#DAE0E5]"
className="w-[84px] h-[164px] flex justify-center items-center text-sm font-semibold bg-[#F0F1F2] border-r border-b border-[#DAE0E5]"
>
{format(scheduledSession, "HH:mm")}
</div>
@@ -466,8 +473,15 @@ function DashboardPage() {
</button>
</div>
<div className="overflow-y-auto overflow-x-hidden">
<div className="p-4">
<p className="text-sm font-semibold opacity-50">Календарь</p>
<div className="p-4 space-y-2">
<div className="flex justify-between items-center">
<p className="text-sm font-semibold">Календарь</p>
<Button color="tertiary" icon={<ChevronUpIcon />} onlyIcon />
</div>
<Calendar
defaultValue={selectedDate}
onChange={(date) => setSelectedDate(date)}
/>
</div>
<div className="p-4 flex flex-col gap-4">