Fix: UI components and form logic updates

This commit is contained in:
2025-12-03 21:48:28 +03:00
parent ee68deb4ce
commit 92c9d1fcdc
10 changed files with 563 additions and 38 deletions

View File

@@ -12,23 +12,30 @@ export default async function CalendarPage() {
start_time,
end_time,
status,
hall_id,
halls (name),
customers (full_name)
customers (full_name, phone)
`)
.neq('status', 'cancelled') // Don't show cancelled events
// Fetch halls for filter
const { data: halls } = await supabase
.from('halls')
.select('id, name')
.order('name')
// Transform data for calendar
const events = reservations?.map(res => ({
id: res.id,
title: `${res.halls?.name || 'Salon'} - ${res.customers?.full_name || 'Müşteri'}`,
title: `${res.customers?.full_name || 'Müşteri'} ${res.customers?.phone ? `(${res.customers.phone})` : ''}`,
start: new Date(res.start_time),
end: new Date(res.end_time),
resource: res,
})) || []
return (
<div className="space-y-4">
<h2 className="text-3xl font-bold tracking-tight">Takvim</h2>
<CalendarView events={events} />
<div className="space-y-4 h-full">
<CalendarView events={events} halls={halls || []} />
</div>
)
}

View File

@@ -18,7 +18,7 @@ import { Textarea } from "@/components/ui/textarea"
import { createHall } from "./actions"
import { useRouter } from "next/navigation"
import { useState } from "react"
import { useToast } from "@/hooks/use-toast" // Note: Need to check if toast hook exists or create it
import { toast } from "sonner"
const formSchema = z.object({
name: z.string().min(2, {
@@ -49,9 +49,10 @@ export function HallForm() {
await createHall(values)
router.push('/dashboard/halls')
router.refresh()
toast.success("Salon başarıyla oluşturuldu")
} catch (error) {
console.error(error)
alert("Bir hata oluştu")
toast.error("Bir hata oluştu")
} finally {
setLoading(false)
}

View File

@@ -17,7 +17,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { Textarea } from "@/components/ui/textarea"
import { createReservation } from "./actions"
import { useState } from "react"
import { useToast } from "@/hooks/use-toast" // Assuming we have this or will use alert
import { toast } from "sonner"
const formSchema = z.object({
hall_id: z.string().min(1, "Salon seçmelisiniz."),

View File

@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { Toaster } from "@/components/ui/sonner"
const geistSans = Geist({
variable: "--font-geist-sans",
@@ -28,6 +29,7 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
<Toaster />
</body>
</html>
);