Two root causes fixed:
1. api.ts saveToken() updated only localStorage, not React state — WS kept
reconnecting with the expired token. Now dispatches hotelsync:token-updated
event; AuthContext listens and updates session state, triggering WS reconnect
with the fresh token.
2. AuthContext mount effect could race with login(): if refresh failed while
login() was concurrently setting a new token, catch() called setSession(null)
and wiped the fresh session. Fixed with functional setSession updater that
checks current state before clearing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If localStorage session has user but no token (corrupted/migrated session),
attempt a token refresh via httpOnly cookie. If refresh fails, clear session
and force re-login. Prevents WebSocket 'missing token' skip.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sessionStorage is per-tab — new tabs had no session, so WebSocket
didn't connect and real-time lock/booking sync didn't work.
localStorage shares session across tabs in the same browser.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- src/lib/api.ts: central API client with JWT auto-refresh, snake_case→camelCase transform
- src/contexts/AuthContext.tsx: real login via POST /api/auth/login
- src/pages/RoomsPage.tsx: load rooms from API, create/update via API
- src/pages/BookingsPage.tsx: load bookings + rooms from API
- src/pages/HousekeepingPage.tsx: load today's tasks from API, update status via API
- src/pages/CalendarPage.tsx: load rooms + bookings from API
- src/types/index.ts: fix HousekeepingTask.priority to match DB (medium/urgent)
- backend/src/routes/rooms.ts: update to use new column names (max_guests, base_rate) + all new fields
- backend/src/routes/bookings.ts: update price_per_night→base_rate, add paid_amount to PATCH
- backend/migrations/003_fix_constraints.sql: fix rooms.status values, add paid_amount, inquiry status, other source
- public/robots.txt + index.html: noindex for SPA inner pages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add AvailabilityPage with price grid (categories × dates), drag-select,
channel prices, EditPanel, PeriodModal, and rate periods tab
- Add ModulesContext with localStorage persistence and dynamic sidebar items
- Add ModulesPage with WiFi Auth, Payments, TV Welcome, Smart Locks,
OLAP Reports, Website Builder, Booking Widget modules
- Add ReportsPage (OLAP analytics with KPI cards, charts, tables)
- Add WebsitePage and BookingWidgetPage placeholders
- Remove hotel slug from URL routing; hotel context from JWT
- Add Доступность nav item in Sidebar under Управление
- Fix LoginPage redirects and HotelSync branding
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>