Add Availability Calendar, Modules system, and route refactoring

- 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>
This commit is contained in:
2026-03-11 14:43:18 +03:00
parent 63c9ae574f
commit b277e3e38d
14 changed files with 1869 additions and 78 deletions

View File

@@ -5,7 +5,7 @@ import { MOCK_USERS } from '../data/mockData'
interface AuthContextValue {
session: AuthSession | null
user: User | null
login: (email: string, password: string) => Promise<boolean>
login: (email: string, password: string) => Promise<User | null>
logout: () => void
}
@@ -17,15 +17,15 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
return stored ? JSON.parse(stored) : null
})
const login = async (email: string, _password: string): Promise<boolean> => {
const login = async (email: string, _password: string): Promise<User | null> => {
// Mock authentication — in production, call POST /auth/login
await new Promise(r => setTimeout(r, 800))
const user = MOCK_USERS.find(u => u.email.toLowerCase() === email.toLowerCase())
if (!user) return false
if (!user) return null
const s: AuthSession = { user, token: 'mock-jwt-token-' + user.id }
setSession(s)
sessionStorage.setItem('hotelsync-session', JSON.stringify(s))
return true
return user
}
const logout = () => {

View File

@@ -0,0 +1,54 @@
import { createContext, useContext, useState } from 'react'
import type { ModuleStatus } from '../data/modulesData'
// Default statuses for demo
const DEFAULT_STATUSES: Record<string, ModuleStatus> = {
'wifi-auth': 'active',
'payments': 'trial',
'tv-welcome': 'inactive',
'smart-locks': 'inactive',
'olap-reports': 'active', // active в демо — виден в сайдбаре
'website-builder':'inactive',
'booking-widget': 'inactive',
}
interface ModulesContextValue {
statuses: Record<string, ModuleStatus>
setStatus: (id: string, status: ModuleStatus) => void
isActive: (id: string) => boolean
}
const ModulesContext = createContext<ModulesContextValue | null>(null)
export function ModulesProvider({ children }: { children: React.ReactNode }) {
const [statuses, setStatuses] = useState<Record<string, ModuleStatus>>(() => {
try {
const stored = localStorage.getItem('hotelsync-modules')
return stored ? { ...DEFAULT_STATUSES, ...JSON.parse(stored) } : DEFAULT_STATUSES
} catch {
return DEFAULT_STATUSES
}
})
const setStatus = (id: string, status: ModuleStatus) => {
setStatuses(prev => {
const next = { ...prev, [id]: status }
localStorage.setItem('hotelsync-modules', JSON.stringify(next))
return next
})
}
const isActive = (id: string) => statuses[id] === 'active' || statuses[id] === 'trial'
return (
<ModulesContext.Provider value={{ statuses, setStatus, isActive }}>
{children}
</ModulesContext.Provider>
)
}
export function useModules() {
const ctx = useContext(ModulesContext)
if (!ctx) throw new Error('useModules must be used within ModulesProvider')
return ctx
}