export interface BookingSummaryInput { bookingNumber: number; contactName: string; phone: string; objectNames: string[]; date: Date; checkOutDate: Date | null; checkIn: string; checkOut: string; guestCount: number; cost: number; prepayment: number; discount: number; comment: string | null; source: string | null; bookedByName: string; } function formatDate(d: Date): string { const dd = String(d.getDate()).padStart(2, "0"); const mm = String(d.getMonth() + 1).padStart(2, "0"); return `${dd}.${mm}.${d.getFullYear()}`; } /** * Guest-facing confirmation text for the "Скопировать бронирование" button * — meant to be pasted straight to the client (WhatsApp/Telegram/SMS), so * it deliberately excludes internal-only fields (source, who booked it). * Field set and order match exactly what was asked for; a multi-day stay's * date line shows both days ("дд.мм.гггг - дд.мм.гггг"). */ export function formatBookingSummary(b: BookingSummaryInput): string { const dateLine = b.checkOutDate ? `${formatDate(b.date)} - ${formatDate(b.checkOutDate)}` : formatDate(b.date); const lines = [ `Ваше бронирование подтверждено! Номер бронирования: ${b.bookingNumber}`, `Гость: ${b.contactName}`, `Номер для связи: ${b.phone}`, `Объект бронирования: ${b.objectNames.join("/") || "—"}`, `Дата: ${dateLine}`, `Время заезда/выезда: ${b.checkIn} - ${b.checkOut}`, `Количество гостей: ${b.guestCount}`, `Стоимость бронирования: ${b.cost}`, `Предоплата: ${b.prepayment}`, `Дополнительные пожелания: ${b.comment?.trim() || "-"}`, `Скидка: ${b.discount}`, ]; return lines.join("\n"); }