MVP frontend+backend
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { ReactNode, useState } from 'react'
|
||||
import { useWorkspace } from '@/context'
|
||||
import { usePlannedDays } from '@/hooks'
|
||||
import type { PlannedLeaveDay } from '@/types'
|
||||
import { Layout } from '@/components/layout/Layout'
|
||||
import { LoadingSpinner } from '@/components/common/LoadingSpinner'
|
||||
import { CalendarDay } from '@/components/common/CalendarDay'
|
||||
import { CalendarEvent } from '@/components/common/CalendarEvent'
|
||||
|
||||
export function Calendar(): ReactNode {
|
||||
const { workspace, isLoading: wsLoading } = useWorkspace()
|
||||
const { data: plannedDays, isLoading: pdLoading } = usePlannedDays(workspace?.id ?? null)
|
||||
const { isLoading: wsLoading, selectedChildId } = useWorkspace()
|
||||
const { data: plannedDays, isLoading: pdLoading } = usePlannedDays(selectedChildId ?? undefined)
|
||||
const [currentMonth, setCurrentMonth] = useState(new Date(2026, 5))
|
||||
|
||||
const isLoading = wsLoading || pdLoading
|
||||
@@ -49,8 +50,8 @@ export function Calendar(): ReactNode {
|
||||
|
||||
const getEventsForDate = (date: string) => {
|
||||
return (plannedDays ?? [])
|
||||
.filter((pd: any) => pd.date === date)
|
||||
.map((pd: any) => ({
|
||||
.filter((pd: PlannedLeaveDay) => pd.date === date)
|
||||
.map((pd: PlannedLeaveDay) => ({
|
||||
type: pd.dayType,
|
||||
color: getColorForType(pd.dayType),
|
||||
title: pd.dayType,
|
||||
@@ -66,7 +67,7 @@ export function Calendar(): ReactNode {
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout header={{ title: 'Kalender' }}>
|
||||
<Layout>
|
||||
<div data-testid="calendar" className="calendar">
|
||||
<div className="calendar__header">
|
||||
<button onClick={handlePrevMonth} aria-label="Previous month">
|
||||
|
||||
Reference in New Issue
Block a user