feat: implement flexible feeding intervals and fix layout alignment

This commit is contained in:
2026-01-12 23:06:12 +01:00
parent 87f4e43c9f
commit 3600ba665d
8 changed files with 149 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
import { useState, useEffect } from "react"
import { format, eachDayOfInterval, isSameDay } from "date-fns"
import { de, enUS } from "date-fns/locale"
import { CalendarIcon, User, Home, X, Info } from "lucide-react"
import { CalendarIcon, User, Home, X, Info, Utensils, Trash2 } from "lucide-react"
import { toast } from "sonner"
import { Button } from "@/components/ui/button"
@@ -37,6 +37,9 @@ type Plan = {
webhookUrl: string | null
notifyAll: boolean
bookings: Booking[]
feedingPerDay: number
feedingInterval: number
litterInterval: number
}
interface PlanDashboardProps {
@@ -255,6 +258,21 @@ export function PlanDashboard({ plan, dict, settingsDict, lang }: PlanDashboardP
</DialogContent>
</Dialog>
)}
<div className="mt-3 flex flex-wrap gap-2 pt-2 border-t border-border/50">
{Math.floor((day.getTime() - new Date(plan.startDate).setHours(0, 0, 0, 0)) / (1000 * 60 * 60 * 24)) % plan.feedingInterval === 0 && (
<div className="flex gap-1 items-center" title={`${plan.feedingPerDay}x ${dict.feeding}`}>
{Array.from({ length: plan.feedingPerDay }).map((_, i) => (
<Utensils key={i} className="w-3.5 h-3.5 text-orange-500/70" />
))}
</div>
)}
{Math.floor((day.getTime() - new Date(plan.startDate).setHours(0, 0, 0, 0)) / (1000 * 60 * 60 * 24)) % plan.litterInterval === 0 && (
<div className="flex items-center gap-1 text-xs text-muted-foreground/70" title={dict.litter}>
<Trash2 className="w-3.5 h-3.5 text-blue-500/70" />
</div>
)}
</div>
</div>
)
})}