main
|
Last change
on this file since 700e2f9 was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago |
|
Init
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | import { type Component, For } from "solid-js";
|
|---|
| 2 | import CalendarDay from "@/components/CalendarDay";
|
|---|
| 3 | import { isFutureDate, isTodayDate } from "@/utils";
|
|---|
| 4 | import type { DiaryEntry } from "@/api/diary";
|
|---|
| 5 |
|
|---|
| 6 | interface CalendarGridProps {
|
|---|
| 7 | days: Array<{
|
|---|
| 8 | day: number | null;
|
|---|
| 9 | isCurrentMonth: boolean;
|
|---|
| 10 | date: Date | null;
|
|---|
| 11 | }>;
|
|---|
| 12 | getEntryForDate: (date: Date | null) => DiaryEntry | undefined;
|
|---|
| 13 | onDayClick: (date: Date | null) => void;
|
|---|
| 14 | isTherapistView?: boolean;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | const CalendarGrid: Component<CalendarGridProps> = (props) => (
|
|---|
| 18 | <div class="grid grid-cols-7 gap-2">
|
|---|
| 19 | <For each={props.days}>
|
|---|
| 20 | {(dayInfo) => {
|
|---|
| 21 | const entry = props.getEntryForDate(dayInfo.date);
|
|---|
| 22 | const isFuture = isFutureDate(dayInfo.date);
|
|---|
| 23 | const isToday = isTodayDate(dayInfo.date);
|
|---|
| 24 |
|
|---|
| 25 | return (
|
|---|
| 26 | <CalendarDay
|
|---|
| 27 | day={dayInfo.day}
|
|---|
| 28 | isCurrentMonth={dayInfo.isCurrentMonth}
|
|---|
| 29 | hasEntry={!!entry}
|
|---|
| 30 | isFuture={isFuture}
|
|---|
| 31 | isToday={isToday}
|
|---|
| 32 | isTherapistView={props.isTherapistView}
|
|---|
| 33 | entry={
|
|---|
| 34 | entry
|
|---|
| 35 | ? {
|
|---|
| 36 | dailyRating: entry.dailyRating,
|
|---|
| 37 | content: entry.content,
|
|---|
| 38 | }
|
|---|
| 39 | : undefined
|
|---|
| 40 | }
|
|---|
| 41 | onClick={() => props.onDayClick(dayInfo.date)}
|
|---|
| 42 | />
|
|---|
| 43 | );
|
|---|
| 44 | }}
|
|---|
| 45 | </For>
|
|---|
| 46 | </div>
|
|---|
| 47 | );
|
|---|
| 48 |
|
|---|
| 49 | export default CalendarGrid;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.