fix: dates timezone, guest lookup fallback to bookings, regex fix

- localDate() uses local timezone instead of UTC (prevents showing yesterday
  after midnight in UTC+3)
- Guest lookup: fallback to bookings table by guest_email/guest_phone when
  no guest profile found in CRM (guests table)
- Fix REGEXP_REPLACE pattern from '\D' (PCRE) to '[^0-9]' (PostgreSQL POSIX)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 02:41:38 +03:00
parent e1d74ff63d
commit b0bbb11c87
2 changed files with 43 additions and 8 deletions

View File

@@ -195,10 +195,12 @@ export function WidgetPreview({ settings, slug, realRooms, realCategories, payme
paymentEnabled?: boolean
}) {
const [previewTab, setPreviewTab] = useState<'rooms' | 'rental'>('rooms')
const todayStr = new Date().toISOString().slice(0, 10)
const tomorrowStr = new Date(Date.now() + 86400000).toISOString().slice(0, 10)
const [checkIn, setCheckIn] = useState(todayStr)
const [checkOut, setCheckOut] = useState(tomorrowStr)
const localDate = (offsetDays = 0) => {
const d = new Date(); d.setDate(d.getDate() + offsetDays)
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
}
const [checkIn, setCheckIn] = useState(() => localDate(0))
const [checkOut, setCheckOut] = useState(() => localDate(1))
const [guests, setGuests] = useState(2)
const [extraBeds, setExtraBeds] = useState(0)
const [children, setChildren] = useState(0)