Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SjoenH committed Apr 19, 2024
1 parent 9b5dd44 commit 637698d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
DrawService,
} from "../../../../api";
import { CompareDates } from "@/utils";
import DrawPeriodMonths from "./Months";
import { useMutation, useQuery, useQueryClient } from "react-query";
import useUser from "@/hooks/useUser.tsx";
import { getMonthsMap, GetWeeklyPeriods } from "@/utils/calendar.ts";
import Weeks from "@/pages/selectPeriods/Calendar/Weeks.tsx";
import { MonthsContainer } from "@/pages/selectPeriods/Calendar/MonthsContainer.tsx";

const DrawPeriodsCalendar = () => {
const user = useUser();
Expand Down Expand Up @@ -55,11 +56,18 @@ const DrawPeriodsCalendar = () => {
};

return (
<DrawPeriodMonths
months={monthMap}
selected={bookingRequests || []}
onClick={toggleBooking}
/>
<div className="flex flex-col gap-1">
{Object.entries(monthMap).map(([month, weeks]) => (
<MonthsContainer key={month} month={Number(month)}>
<Weeks
weeks={weeks}
selected={bookingRequests || []}
month={Number(month)}
onClick={toggleBooking}
/>
</MonthsContainer>
))}
</div>
);
};

Expand Down
54 changes: 0 additions & 54 deletions kabinizer-front-end/src/pages/selectPeriods/Calendar/Months.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import MonthColumn from "@/components/MonthVertical.tsx";
import { COLORS, MONTHS } from "@/options";

export const MonthsContainer = ({
children,
month,
}: {
children: React.ReactNode;
month: number;
}) => {
return (
<div key={month} className="flex items-center gap-x-4">
<MonthColumn
month={MONTHS[month]}
color={COLORS[month % COLORS.length].selected}
/>
<div
className={`relative flex w-72 flex-col rounded-lg p-2 ${
month % 2
? "bg-blue-200 dark:bg-blue-700"
: "bg-purple-200 dark:bg-purple-700"
}`}
>
{children}
</div>
</div>
);
};

0 comments on commit 637698d

Please sign in to comment.