feat: initial commit — local services (backend + manager dashboard + waiter PWA)

Includes all work to date:
- local_backend: FastAPI backend with products, orders, tables, shifts, cloud sync
- manager_dashboard: React manager UI with product/category management, reports, settings
- waiter_pwa: React PWA for waiter devices
- Category reparent endpoint and UI
- Waiter domain: local_ip sent on heartbeat, waiter_domain persisted from cloud response
- QR code modal in AppInfoTab for waiter domain
- Product form: number input spinners removed, category pre-selected on new product
- Category row: count badge moved to far right

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 14:04:38 +03:00
commit 8ba8c95ecd
209 changed files with 48017 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
import { useQuery } from '@tanstack/react-query'
import client from '../api/client'
/**
* Polls /api/system/status every 5 minutes to stay in sync with the backend
* heartbeat cycle. Returns a stable object so callers can destructure safely.
*
* Returned shape:
* licensed bool
* locked bool
* lock_pending bool
* lock_reason "admin" | "expired" | null
* expires_at string | null (ISO)
* days_until_expiry number | null (negative = expired)
* grace_expires_at string | null (ISO)
* grace_days_remaining number | null
* sync_failed bool
*
* Derived helpers:
* showExpiryWarning bool — true when 0 < days_until_expiry <= 5
* inGracePeriod bool — true when expired but grace not yet over
* isBlocked bool — locked=true OR (unlicensed AND grace over)
*/
export default function useLicenseStatus() {
const { data } = useQuery({
queryKey: ['license-status'],
queryFn: () => client.get('/api/system/status').then(r => r.data),
staleTime: 0,
refetchInterval: 5 * 60 * 1000,
refetchIntervalInBackground: true,
})
if (!data) {
return {
licensed: true,
locked: false,
lock_pending: false,
lock_reason: null,
expires_at: null,
days_until_expiry: null,
grace_expires_at: null,
grace_days_remaining: null,
sync_failed: false,
showExpiryWarning: false,
inGracePeriod: false,
isBlocked: false,
}
}
const {
licensed = true,
locked = false,
lock_pending = false,
lock_reason = null,
expires_at = null,
days_until_expiry = null,
grace_expires_at = null,
grace_days_remaining = null,
sync_failed = false,
} = data
const showExpiryWarning =
days_until_expiry != null && days_until_expiry >= 0 && days_until_expiry <= 5
const inGracePeriod =
days_until_expiry != null && days_until_expiry < 0 && licensed
const isBlocked = locked || !licensed
return {
licensed,
locked,
lock_pending,
lock_reason,
expires_at,
days_until_expiry,
grace_expires_at,
grace_days_remaining,
sync_failed,
showExpiryWarning,
inGracePeriod,
isBlocked,
}
}