From 006d108f549362e3030fea233af389fc03a34029 Mon Sep 17 00:00:00 2001 From: ogrechko Date: Sun, 13 Sep 2026 19:49:21 +0000 Subject: [PATCH] Rewrite guest confirmation text; add discount and multi-day checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy button text now matches the exact guest-facing template requested — "Ваше бронирование подтверждено!", Гость/Номер для связи/Объект бронирования/Количество гостей/Дополнительные пожелания/Скидка — dropping the internal-only fields (source, who booked it) since this text gets pasted straight to the client, not kept for internal records (those still show on the on-screen summary card). New checkOutDate column (nullable — null means same-day, the common case) lets a booking span multiple days; the Google Calendar link and copy text both show the date range when set. New discount column (same shape as prepayment) feeds the new "Скидка" line. Statistics page gains a money row for the selected month: total booked, prepayments collected, amount still outstanding, and total discount given. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Gh2UXUQUVBWroWEnn1FLFG --- .../(admin)/bookings/[id]/booking-detail.tsx | 22 +- src/app/(admin)/bookings/booking-card.tsx | 7 +- .../(admin)/bookings/new/new-booking-form.tsx | 22 +- src/app/(admin)/statistics/page.tsx | 6 +- .../(admin)/statistics/statistics-view.tsx | 55 ++- src/app/api/bookings/[id]/route.ts | 5 +- src/app/api/bookings/route.ts | 11 + src/components/booking-summary-card.tsx | 8 +- src/lib/bookings/calendar-link.ts | 6 +- src/lib/bookings/format.ts | 28 +- src/lib/bookings/service.ts | 40 ++ src/lib/db/migrations/0003_little_bishop.sql | 2 + src/lib/db/migrations/meta/0003_snapshot.json | 411 ++++++++++++++++++ src/lib/db/migrations/meta/_journal.json | 7 + src/lib/db/schema.ts | 5 + 15 files changed, 600 insertions(+), 35 deletions(-) create mode 100644 src/lib/db/migrations/0003_little_bishop.sql create mode 100644 src/lib/db/migrations/meta/0003_snapshot.json diff --git a/src/app/(admin)/bookings/[id]/booking-detail.tsx b/src/app/(admin)/bookings/[id]/booking-detail.tsx index 284ad34..d7221af 100644 --- a/src/app/(admin)/bookings/[id]/booking-detail.tsx +++ b/src/app/(admin)/bookings/[id]/booking-detail.tsx @@ -33,11 +33,13 @@ export function BookingDetail({ const [phone, setPhone] = useState(booking.phone); const [objectIds, setObjectIds] = useState>(new Set(booking.objects.map((o) => o.id))); const [date, setDate] = useState(toDateInputValue(booking.date)); + const [checkOutDate, setCheckOutDate] = useState(booking.checkOutDate ? toDateInputValue(booking.checkOutDate) : ""); const [checkIn, setCheckIn] = useState(booking.checkIn); const [checkOut, setCheckOut] = useState(booking.checkOut); const [guestCount, setGuestCount] = useState(String(booking.guestCount)); const [cost, setCost] = useState(String(booking.cost)); const [prepayment, setPrepayment] = useState(String(booking.prepayment)); + const [discount, setDiscount] = useState(String(booking.discount)); const [comment, setComment] = useState(booking.comment ?? ""); const [source, setSource] = useState(booking.source ?? ""); @@ -66,11 +68,13 @@ export function BookingDetail({ phone, objectIds: Array.from(objectIds), date, + checkOutDate: checkOutDate || null, checkIn, checkOut, guestCount: Number(guestCount), cost: Number(cost), prepayment: Number(prepayment) || 0, + discount: Number(discount) || 0, comment: comment.trim() || null, source: source.trim() || null, }), @@ -160,22 +164,26 @@ export function BookingDetail({ -
+
+
-
+
+
- {formatDate(booking.date)}, {booking.checkIn}–{booking.checkOut} + + {formatDate(booking.date)} + {booking.checkOutDate ? ` - ${formatDate(booking.checkOutDate)}` : ""}, {booking.checkIn}–{booking.checkOut} + {booking.guestCount} diff --git a/src/app/(admin)/bookings/new/new-booking-form.tsx b/src/app/(admin)/bookings/new/new-booking-form.tsx index c3ffce8..f358c99 100644 --- a/src/app/(admin)/bookings/new/new-booking-form.tsx +++ b/src/app/(admin)/bookings/new/new-booking-form.tsx @@ -13,11 +13,13 @@ export function NewBookingForm({ objects }: { objects: BookableObjectDTO[] }) { const [phone, setPhone] = useState(""); const [objectIds, setObjectIds] = useState>(new Set()); const [date, setDate] = useState(""); + const [checkOutDate, setCheckOutDate] = useState(""); const [checkIn, setCheckIn] = useState(""); const [checkOut, setCheckOut] = useState(""); const [guestCount, setGuestCount] = useState(""); const [cost, setCost] = useState(""); const [prepayment, setPrepayment] = useState("0"); + const [discount, setDiscount] = useState("0"); const [comment, setComment] = useState(""); const [source, setSource] = useState(""); const [loading, setLoading] = useState(false); @@ -50,11 +52,13 @@ export function NewBookingForm({ objects }: { objects: BookableObjectDTO[] }) { phone, objectIds: Array.from(objectIds), date, + checkOutDate: checkOutDate || null, checkIn, checkOut, guestCount: Number(guestCount), cost: Number(cost), prepayment: Number(prepayment) || 0, + discount: Number(discount) || 0, comment: comment.trim() || null, source: source.trim() || null, }), @@ -117,22 +121,26 @@ export function NewBookingForm({ objects }: { objects: BookableObjectDTO[] }) { )}
-
+
+
-
+
+