"use client"
import { formatPrice } from "@/lib/calculations"
import { type StoredQuote, type QuoteStatus } from "@/lib/db"
import { QuoteCard } from "./quote-card"
interface KanbanColumnProps {
title: string
status: QuoteStatus
quotes: StoredQuote[]
showTotal?: boolean
onStatusChange: (id: number, status: QuoteStatus) => void
onReject: (quote: StoredQuote) => void
}
function KanbanColumn({
title,
status,
quotes,
showTotal = true,
onStatusChange,
onReject,
}: KanbanColumnProps) {
const total = quotes.reduce((sum, q) => sum + (q.totalInclVat || 0), 0)
const bgColor = {
new: "bg-blue-50/50 border-blue-200",
contacted: "bg-amber-50/50 border-amber-200",
accepted: "bg-green-50/50 border-green-200",
rejected: "bg-gray-50/50 border-gray-200",
}[status]
const headerColor = {
new: "text-blue-700",
contacted: "text-amber-700",
accepted: "text-green-700",
rejected: "text-gray-500",
}[status]
return (
{/* Fixed header */}
{title}
{quotes.length}
{showTotal && quotes.length > 0 && (
Værdi: {formatPrice(Math.round(total))}
)}
{/* Scrollable content */}
{quotes.length === 0 ? (
Ingen tilbud
) : (
quotes.map((quote) => (
))
)}
)
}
interface KanbanBoardProps {
quotes: StoredQuote[]
onStatusChange: (id: number, status: QuoteStatus) => void
onReject: (quote: StoredQuote) => void
rejectedCount: number
onShowRejected: () => void
}
export function KanbanBoard({
quotes,
onStatusChange,
onReject,
rejectedCount,
onShowRejected,
}: KanbanBoardProps) {
// Only show 3 main columns
const columns: { title: string; status: QuoteStatus; showTotal: boolean }[] = [
{ title: "Nye tilbud", status: "new", showTotal: true },
{ title: "Kunde kontaktet", status: "contacted", showTotal: true },
{ title: "Tilbud accepteret", status: "accepted", showTotal: true },
]
const groupedQuotes = columns.reduce(
(acc, col) => {
acc[col.status] = quotes.filter((q) => q.status === col.status)
return acc
},
{} as Record
)
return (
{columns.map((col) => (
))}
{/* Rejected quotes link */}
{rejectedCount > 0 && (
)}
)
}