Rebuild the web frontend around the Stitch hero design: new app shell header with responsive navigation and a single / page preserving the Stitch main/footer copy. Remove the legacy Onyx pages, components, composables and CSS. Add bundled Tailwind 3.4.17 and @nuxt/icon with a locally bundled Material Symbols collection; no icon CDN at runtime. Include design notes for claims to reconcile before the pitch and verification screenshots.
1018 lines
36 KiB
Vue
1018 lines
36 KiB
Vue
<script setup lang="ts">
|
||
import {
|
||
iconCalendar,
|
||
iconCheck,
|
||
iconCircleInformation,
|
||
iconDownload,
|
||
iconSync,
|
||
iconTriangleWarning,
|
||
} from '@sit-onyx/icons'
|
||
import { dailyWeather } from '#shared/insights'
|
||
import {
|
||
addDays,
|
||
berlinParts,
|
||
buildStaffing,
|
||
DEFAULT_ASSUMPTIONS,
|
||
isInWeek,
|
||
planWeekStart,
|
||
STANDARD_VISITORS_PER_STAFF_HOUR,
|
||
} from '#shared/staffing'
|
||
import { SCENARIOS } from '#shared/types'
|
||
import type {
|
||
ContextResponse,
|
||
MetaResponse,
|
||
Scenario,
|
||
ScenarioPreset,
|
||
ScenarioState,
|
||
Sensor,
|
||
Shift,
|
||
StaffingHour,
|
||
StaffingResponse,
|
||
Standard,
|
||
} from '#shared/types'
|
||
import {
|
||
formatDate,
|
||
formatDateTime,
|
||
formatEuro,
|
||
formatNumber,
|
||
formatPercent,
|
||
formatShortDate,
|
||
formatTime,
|
||
formatWeekday,
|
||
weekLabel,
|
||
} from '~/utils/format'
|
||
import {
|
||
numberWord,
|
||
peakHourOf,
|
||
peakShiftOf,
|
||
planDays,
|
||
savingOf,
|
||
savingPctOf,
|
||
totalStaffHoursOf,
|
||
} from '~/utils/plan'
|
||
|
||
const config = useRuntimeConfig()
|
||
const route = useRoute()
|
||
const demoNow = String(config.public.demoNow)
|
||
const usingMock = computed(() => {
|
||
const value = config.public.useMock
|
||
return value === true || value === '1' || value === 'true'
|
||
})
|
||
|
||
function initialScenario(): Scenario {
|
||
const value = route.query.scenario
|
||
return typeof value === 'string' && SCENARIOS.includes(value as Scenario) ? (value as Scenario) : 'base'
|
||
}
|
||
|
||
/** Keep Stadtgalerie as the demo default, but follow the API when it differs. */
|
||
function preferredSensor(list: Sensor[] | null | undefined): string {
|
||
return list?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ?? list?.[0]?.id ?? 'hn-stadtgalerie-01'
|
||
}
|
||
|
||
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
|
||
const { data: context } = await useFetch<ContextResponse>('/api/context')
|
||
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
|
||
const { data: presets } = await useFetch<ScenarioPreset[]>('/api/scenarios')
|
||
const { data: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
|
||
const live = useLiveScenario(liveScenarioState.value)
|
||
|
||
const sensorId = ref(preferredSensor(sensors.value))
|
||
const scenario = ref<Scenario>(initialScenario())
|
||
if (!route.query.scenario) scenario.value = live.scenarioId
|
||
const standard = ref<Standard>('standard')
|
||
const approved = ref(false)
|
||
const generating = ref(false)
|
||
const generatedAt = ref('')
|
||
const openAssumptions = ref<PropertyKey[]>([])
|
||
const assumptions = reactive({
|
||
safety_factor: DEFAULT_ASSUMPTIONS.safety_factor,
|
||
min_staff: DEFAULT_ASSUMPTIONS.min_staff,
|
||
shift_length_h: DEFAULT_ASSUMPTIONS.shift_length_h,
|
||
labor_cost_eur_h: DEFAULT_ASSUMPTIONS.labor_cost_eur_h,
|
||
})
|
||
|
||
const EMPTY_PLAN: StaffingResponse = {
|
||
sensor: '',
|
||
scenario: 'base',
|
||
standard: 'standard',
|
||
assumptions: DEFAULT_ASSUMPTIONS,
|
||
hours: [],
|
||
shifts: [],
|
||
summary: {
|
||
coverage_pct: 0,
|
||
cost_eur: 0,
|
||
flat_schedule_cost_eur: 0,
|
||
overstaffed_hours: 0,
|
||
understaffed_hours: 0,
|
||
},
|
||
why: [],
|
||
cached: false,
|
||
data_version: '',
|
||
model_version: '',
|
||
context_version: '',
|
||
}
|
||
|
||
// The Go plan is the source; assumption edits render a local preview only.
|
||
const {
|
||
data: apiPlanData,
|
||
status,
|
||
error,
|
||
refresh,
|
||
} = await useFetch<StaffingResponse>('/api/staffing', {
|
||
query: computed(() => ({
|
||
sensor: sensorId.value,
|
||
scenario: scenario.value,
|
||
standard: standard.value,
|
||
})),
|
||
})
|
||
|
||
watch(
|
||
() => route.query.scenario,
|
||
(value) => {
|
||
if (typeof value === 'string' && SCENARIOS.includes(value as Scenario)) {
|
||
scenario.value = value as Scenario
|
||
}
|
||
},
|
||
)
|
||
|
||
// A scenario event changes the plan. If the enum is unchanged (same scenario,
|
||
// new override/version), the query string does not move, so refresh it here.
|
||
watch(
|
||
() => live.revision,
|
||
() => {
|
||
if (live.scenarioId !== scenario.value) scenario.value = live.scenarioId
|
||
else void refresh()
|
||
},
|
||
)
|
||
|
||
const apiPlan = computed(() => apiPlanData.value ?? EMPTY_PLAN)
|
||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||
const activeScenario = computed(() => presets.value?.find((preset) => preset.id === scenario.value))
|
||
const visitorsPerStaffHour = computed(() => STANDARD_VISITORS_PER_STAFF_HOUR[standard.value])
|
||
|
||
const weekStart = computed(() => {
|
||
const first = apiPlan.value.hours[0]
|
||
return first ? berlinParts(first.t).date : planWeekStart(demoNow)
|
||
})
|
||
const weekEnd = computed(() => addDays(weekStart.value, 6))
|
||
const today = computed(() => berlinParts(demoNow).date)
|
||
const windowIsRolling = computed(() => weekStart.value <= today.value && today.value <= weekEnd.value)
|
||
const windowTag = computed(() => (windowIsRolling.value ? 'Today–Friday' : 'Seven days'))
|
||
const lastUpdated = computed(() => live.scenarioAt || plan.value.context_version)
|
||
|
||
useHead(() => ({
|
||
title: weekStart.value ? `Plan ${weekLabel(weekStart.value, weekEnd.value)} — PulseCast` : 'Plan — PulseCast',
|
||
}))
|
||
|
||
const scenarioOptions = computed(() =>
|
||
(presets.value ?? []).map((preset) => ({ value: preset.id, label: preset.label })),
|
||
)
|
||
const sensorOptions = computed(() =>
|
||
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
|
||
)
|
||
const standardOptions = [
|
||
{ value: 'relaxed', label: 'Relaxed 35' },
|
||
{ value: 'standard', label: 'Standard 25' },
|
||
{ value: 'premium', label: 'Premium 18' },
|
||
]
|
||
const standardLabel = computed(
|
||
() =>
|
||
({
|
||
relaxed: 'relaxed · 35 visitors per staff-hour',
|
||
standard: 'standard · 25 visitors per staff-hour',
|
||
premium: 'premium · 18 visitors per staff-hour',
|
||
})[standard.value],
|
||
)
|
||
const shiftLengthOptions = [
|
||
{ value: 2, label: '2 hours' },
|
||
{ value: 3, label: '3 hours' },
|
||
{ value: 4, label: '4 hours' },
|
||
{ value: 5, label: '5 hours' },
|
||
]
|
||
|
||
/** The /api/staffing contract has no assumption query params. Non-query edits
|
||
* are therefore an explicitly labeled local preview, never a silent swap. */
|
||
const previewActive = computed(() => {
|
||
const api = apiPlan.value.assumptions
|
||
return (
|
||
assumptions.safety_factor !== api.safety_factor ||
|
||
assumptions.min_staff !== api.min_staff ||
|
||
assumptions.shift_length_h !== api.shift_length_h ||
|
||
assumptions.labor_cost_eur_h !== api.labor_cost_eur_h
|
||
)
|
||
})
|
||
|
||
const previewBuild = computed(() =>
|
||
buildStaffing({
|
||
sensor: sensorId.value,
|
||
scenario: scenario.value,
|
||
standard: standard.value,
|
||
points: apiPlan.value.hours.map((hour) => ({ t: hour.t, v: hour.footfall })),
|
||
weekStart: weekStart.value,
|
||
assumptions: {
|
||
visitors_per_staff_hour: visitorsPerStaffHour.value,
|
||
safety_factor: assumptions.safety_factor,
|
||
min_staff: assumptions.min_staff,
|
||
shift_length_h: assumptions.shift_length_h,
|
||
labor_cost_eur_h: assumptions.labor_cost_eur_h,
|
||
store_hours: apiPlan.value.assumptions.store_hours,
|
||
},
|
||
data_version: apiPlan.value.data_version,
|
||
model_version: apiPlan.value.model_version,
|
||
context_version: apiPlan.value.context_version,
|
||
}),
|
||
)
|
||
|
||
const hoursByDate = computed<Record<string, StaffingHour[]>>(() => {
|
||
if (previewActive.value) return previewBuild.value.byDate
|
||
const grouped: Record<string, StaffingHour[]> = {}
|
||
for (const hour of apiPlan.value.hours) {
|
||
const date = berlinParts(hour.t).date
|
||
;(grouped[date] ??= []).push(hour)
|
||
}
|
||
return grouped
|
||
})
|
||
|
||
const shiftsByDate = computed<Record<string, Shift[]>>(() => {
|
||
if (previewActive.value) return previewBuild.value.shiftsByDate
|
||
const grouped: Record<string, Shift[]> = {}
|
||
for (const shift of apiPlan.value.shifts) {
|
||
;(grouped[shift.date] ??= []).push(shift)
|
||
}
|
||
return grouped
|
||
})
|
||
|
||
const plan = computed(() => (previewActive.value ? previewBuild.value.response : apiPlan.value))
|
||
const why = computed(() => apiPlan.value.why)
|
||
const weekWeather = computed(() => {
|
||
if (!context.value) return []
|
||
return Object.values(dailyWeather(context.value.weather.forecast))
|
||
.filter((day) => isInWeek(day.date, weekStart.value))
|
||
.sort((a, b) => a.date.localeCompare(b.date))
|
||
})
|
||
const weatherSummary = computed(() => {
|
||
const days = weekWeather.value
|
||
if (!days.length) return '—'
|
||
return `${Math.round(Math.min(...days.map((day) => day.tempMin)))}–${Math.round(
|
||
Math.max(...days.map((day) => day.tempMax)),
|
||
)} °C · ${days.reduce((sum, day) => sum + day.precipMm, 0).toFixed(1)} mm`
|
||
})
|
||
|
||
const peakHour = computed(() => peakHourOf(plan.value))
|
||
const peakShift = computed(() => peakShiftOf(plan.value))
|
||
const totalStaffHours = computed(() => totalStaffHoursOf(plan.value))
|
||
const savingEur = computed(() => savingOf(plan.value))
|
||
const savingPct = computed(() => savingPctOf(plan.value))
|
||
const daySummaries = computed(() => planDays(plan.value))
|
||
const dayDates = computed(() => daySummaries.value.map((day) => day.date))
|
||
const selectedDay = ref('')
|
||
watch(
|
||
() => dayDates.value.join(','),
|
||
() => {
|
||
if (dayDates.value.includes(selectedDay.value)) return
|
||
const preferred = peakShift.value?.date ?? dayDates.value[5] ?? dayDates.value[0] ?? ''
|
||
selectedDay.value = dayDates.value.includes(preferred) ? preferred : (dayDates.value[0] ?? '')
|
||
},
|
||
{ immediate: true },
|
||
)
|
||
|
||
const selectedDaySummary = computed(() => daySummaries.value.find((day) => day.date === selectedDay.value))
|
||
const dayOptions = computed(() =>
|
||
daySummaries.value.map((day) => ({
|
||
value: day.date,
|
||
label: `${day.weekdayLong} ${day.dayNumber} ${day.month} · ${day.peakStaff} peak`,
|
||
})),
|
||
)
|
||
const selectedHours = computed<StaffingHour[]>(() => hoursByDate.value[selectedDay.value] ?? [])
|
||
const selectedCovered = computed(
|
||
() => selectedHours.value.filter((hour) => hour.scheduled_staff >= hour.required_staff).length,
|
||
)
|
||
const selectedOver = computed(() => selectedHours.value.filter((hour) => hour.coverage === 'over').length)
|
||
|
||
function coverageLabel(hour: StaffingHour) {
|
||
if (hour.coverage === 'under') return `${hour.required_staff - hour.scheduled_staff} short`
|
||
if (hour.coverage === 'over') return `+${hour.scheduled_staff - hour.required_staff} over`
|
||
return 'Covered'
|
||
}
|
||
|
||
function hourLabel(hour: StaffingHour) {
|
||
return `${String(berlinParts(hour.t).hour).padStart(2, '0')}:00`
|
||
}
|
||
|
||
async function generate() {
|
||
generating.value = true
|
||
try {
|
||
await refresh()
|
||
if (!error.value && import.meta.client) generatedAt.value = formatTime(new Date().toISOString())
|
||
} finally {
|
||
generating.value = false
|
||
}
|
||
}
|
||
|
||
function resetAssumptions() {
|
||
assumptions.safety_factor = DEFAULT_ASSUMPTIONS.safety_factor
|
||
assumptions.min_staff = DEFAULT_ASSUMPTIONS.min_staff
|
||
assumptions.shift_length_h = DEFAULT_ASSUMPTIONS.shift_length_h
|
||
assumptions.labor_cost_eur_h = DEFAULT_ASSUMPTIONS.labor_cost_eur_h
|
||
standard.value = 'standard'
|
||
}
|
||
|
||
function useApiPlan() {
|
||
const api = apiPlan.value.assumptions
|
||
assumptions.safety_factor = api.safety_factor
|
||
assumptions.min_staff = api.min_staff
|
||
assumptions.shift_length_h = api.shift_length_h
|
||
assumptions.labor_cost_eur_h = api.labor_cost_eur_h
|
||
}
|
||
|
||
function exportPlan() {
|
||
if (!import.meta.client) return
|
||
const rows = [
|
||
['date', 'shift_start', 'shift_end', 'staff', 'staff_hours'],
|
||
...plan.value.shifts.map((shift) => [
|
||
shift.date,
|
||
shift.start,
|
||
shift.end,
|
||
String(shift.staff),
|
||
String((Number(shift.end.slice(0, 2)) - Number(shift.start.slice(0, 2))) * shift.staff),
|
||
]),
|
||
]
|
||
const csv = rows.map((row) => row.join(',')).join('\n')
|
||
const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv;charset=utf-8' }))
|
||
const link = document.createElement('a')
|
||
link.href = url
|
||
link.download = `pulsecast-plan-${weekStart.value}.csv`
|
||
link.click()
|
||
URL.revokeObjectURL(url)
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="pc-page">
|
||
<section v-if="plan.hours.length" class="pc-hero" aria-labelledby="plan-title">
|
||
<div class="pc-hero__top">
|
||
<div class="pc-meta">
|
||
<span class="pc-tag">{{ windowTag }}</span>
|
||
<span v-if="previewActive" class="pc-tag pc-tag--signal">Local preview</span>
|
||
<span v-if="apiPlan.cached" class="pc-tag">Cached forecast</span>
|
||
</div>
|
||
<div class="pc-meta">
|
||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" compact />
|
||
<span class="pc-small pc-muted">
|
||
Updated {{ lastUpdated ? formatDateTime(lastUpdated) : '—' }} · v{{ live.version || '—' }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="pc-hero__grid">
|
||
<div class="pc-hero__copy">
|
||
<h1 id="plan-title" class="pc-h1">
|
||
<template v-if="peakShift">{{ numberWord(peakShift.staff) }} on {{ formatWeekday(peakShift.date) }}.</template>
|
||
<template v-else>Build the week.</template>
|
||
</h1>
|
||
<p class="pc-hero__shift">
|
||
<template v-if="peakShift">
|
||
<strong>{{ peakShift.start }}–{{ peakShift.end }}</strong> is the peak shift. The week runs on
|
||
<strong>{{ totalStaffHours }} staff-hours</strong> at <strong>{{ formatEuro(plan.summary.cost_eur) }}</strong>.
|
||
</template>
|
||
<template v-else>No shift blocks are available yet.</template>
|
||
</p>
|
||
<p class="pc-small pc-muted">
|
||
<template v-if="usingMock">Demo data · the Go API is not being called.</template>
|
||
<template v-else-if="previewActive">Local assumption preview · the Go API plan is unchanged.</template>
|
||
<template v-else>
|
||
API window {{ weekLabel(weekStart, weekEnd) }} · {{ activeSensor?.name ?? 'Stadtgalerie' }} ·
|
||
{{ activeScenario?.label ?? 'Base week' }}.
|
||
</template>
|
||
</p>
|
||
<div class="pc-actions">
|
||
<OnyxButton
|
||
:label="approved ? 'Approved · demo' : 'Approve the week'"
|
||
:icon="approved ? iconCheck : iconCalendar"
|
||
color="primary"
|
||
:aria-pressed="approved"
|
||
@click="approved = !approved"
|
||
/>
|
||
<OnyxButton label="Export CSV" :icon="iconDownload" mode="outline" @click="exportPlan" />
|
||
<span class="pc-action-note">{{ approved ? 'Local demo state — no payroll write.' : 'Draft for manager review.' }}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="pc-receipt" aria-label="Cost and coverage">
|
||
<div class="pc-receipt__head">
|
||
<div>
|
||
<p class="pc-label">The week, costed</p>
|
||
<p class="pc-receipt__headline">{{ formatEuro(plan.summary.cost_eur) }}</p>
|
||
</div>
|
||
<span class="pc-tag pc-tag--green">{{ formatPercent(plan.summary.coverage_pct, 1) }} covered</span>
|
||
</div>
|
||
<div class="pc-receipt__row">
|
||
<span class="pc-receipt__label">Staff-hours</span>
|
||
<span class="pc-receipt__value">{{ totalStaffHours }}</span>
|
||
</div>
|
||
<div class="pc-receipt__row">
|
||
<span class="pc-receipt__label">Flat schedule</span>
|
||
<span class="pc-receipt__value">{{ formatEuro(plan.summary.flat_schedule_cost_eur) }}</span>
|
||
</div>
|
||
<div class="pc-receipt__row">
|
||
<span class="pc-receipt__label">Saved vs flat</span>
|
||
<span class="pc-receipt__value pc-receipt__value--green">
|
||
{{ formatEuro(savingEur) }} <span class="pc-small">({{ Math.round(savingPct) }}%)</span>
|
||
</span>
|
||
</div>
|
||
<div class="pc-receipt__row">
|
||
<span class="pc-receipt__label">Coverage</span>
|
||
<span class="pc-receipt__value">
|
||
{{ formatPercent(plan.summary.coverage_pct, 1) }} · {{ plan.summary.understaffed_hours }} h short
|
||
</span>
|
||
</div>
|
||
<p class="pc-receipt__note">
|
||
{{ plan.summary.overstaffed_hours }} hours are intentionally over requirement.
|
||
<template v-if="peakHour">Peak forecast {{ formatNumber(peakHour.footfall) }} est. devices/hour.</template>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="pc-board-wrap">
|
||
<div class="pc-board-wrap__head">
|
||
<div>
|
||
<p class="pc-label">The week, block by block</p>
|
||
<p class="pc-board-wrap__hint">
|
||
Staff per shift block · {{ weekLabel(weekStart, weekEnd) }} · {{ windowTag }} API window
|
||
</p>
|
||
</div>
|
||
<p class="pc-board-wrap__hint">Select a day to inspect hourly coverage</p>
|
||
</div>
|
||
<WeekBoard
|
||
:days="daySummaries"
|
||
:peak-date="peakShift?.date"
|
||
:selected-date="selectedDay"
|
||
interactive
|
||
label="Weekly shift board. Select a day to inspect hourly coverage."
|
||
@select="selectedDay = $event"
|
||
/>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
v-else
|
||
class="pc-hero hero-empty"
|
||
:aria-busy="status === 'pending' || status === 'idle'"
|
||
:aria-label="status === 'error' ? 'The plan is unavailable' : 'Loading the staffing plan'"
|
||
>
|
||
<template v-if="status === 'error'">
|
||
<p class="pc-tag pc-tag--danger">Plan unavailable</p>
|
||
<h1 class="pc-h1">The plan is unavailable.</h1>
|
||
<p class="pc-lede">The plan service did not answer. Check the connection and retry.</p>
|
||
<OnyxButton label="Retry" mode="outline" :icon="iconSync" @click="refresh()" />
|
||
</template>
|
||
<template v-else-if="status === 'success' && !plan.hours.length">
|
||
<p class="pc-tag">No shifts</p>
|
||
<h1 class="pc-h1">No open hours in this window.</h1>
|
||
<p class="pc-lede">
|
||
Pick another store or scenario, or check the data window. The API returned no schedulable hours.
|
||
</p>
|
||
<OnyxButton label="Retry" mode="outline" :icon="iconSync" @click="refresh()" />
|
||
</template>
|
||
<template v-else>
|
||
<div class="pc-skeleton" style="width: 42%; height: 1.1rem" />
|
||
<div class="pc-skeleton" style="width: 78%; height: 4.5rem; margin-top: 1.5rem" />
|
||
<div class="pc-skeleton" style="width: 54%; height: 1.2rem; margin-top: 1rem" />
|
||
<div class="pc-skeleton" style="width: 100%; height: 12rem; margin-top: 1.5rem" />
|
||
<p class="pc-small pc-muted" style="margin-top: 1rem">Loading the current plan…</p>
|
||
</template>
|
||
</section>
|
||
|
||
<div v-if="plan.hours.length && status === 'error'" class="pc-alert pc-alert--danger" role="alert">
|
||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="danger" />
|
||
<span>The plan could not be refreshed. Showing the last known plan.</span>
|
||
<OnyxButton label="Retry" mode="outline" density="compact" :icon="iconSync" @click="refresh()" />
|
||
</div>
|
||
|
||
<template v-if="plan.hours.length">
|
||
<dl class="pc-evidence" aria-label="What the plan is built on">
|
||
<div class="pc-evidence__item">
|
||
<dt>Forecast peak <span class="pc-tag">Modelled</span></dt>
|
||
<dd>
|
||
{{ peakHour ? formatNumber(peakHour.footfall) : '—' }}
|
||
<span class="pc-evidence__note">
|
||
est. devices/hour<template v-if="peakHour"> · {{ hourLabel(peakHour) }}</template>
|
||
</span>
|
||
</dd>
|
||
</div>
|
||
<div class="pc-evidence__item">
|
||
<dt>Weather <span class="pc-tag">Modelled</span></dt>
|
||
<dd>
|
||
{{ weatherSummary }}
|
||
<span class="pc-evidence__note">week forecast, not a causal claim</span>
|
||
</dd>
|
||
</div>
|
||
<div class="pc-evidence__item">
|
||
<dt>Service standard <span class="pc-tag">Assumption</span></dt>
|
||
<dd>
|
||
{{ plan.assumptions.visitors_per_staff_hour }}
|
||
<span class="pc-evidence__note">visitors/staff-hour · ×{{ plan.assumptions.safety_factor }} safety</span>
|
||
</dd>
|
||
</div>
|
||
<div class="pc-evidence__item">
|
||
<dt>Model WAPE <span class="pc-tag">Validation</span></dt>
|
||
<dd>
|
||
{{ meta ? formatPercent(meta.metrics.wape, 1) : '—' }}
|
||
<span class="pc-evidence__note">baseline {{ meta ? formatPercent(meta.metrics.baseline_wape, 1) : '—' }}</span>
|
||
</dd>
|
||
</div>
|
||
<div class="pc-evidence__item">
|
||
<dt>Data window <span class="pc-tag">Measured</span></dt>
|
||
<dd>
|
||
{{ weekLabel(weekStart, weekEnd) }}
|
||
<span class="pc-evidence__note">{{ windowTag }} · {{ meta?.coverage.sensors ?? 8 }} sensors · 580 m</span>
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
|
||
<section class="pc-section" aria-labelledby="settings-title">
|
||
<div class="pc-section__head">
|
||
<div>
|
||
<h2 id="settings-title" class="pc-h2">Plan settings</h2>
|
||
<p class="pc-small pc-muted">
|
||
Store, scenario and service standard go to the API. Assumption edits render a local preview.
|
||
</p>
|
||
</div>
|
||
<span class="pc-tag">{{ usingMock ? 'Demo data' : previewActive ? 'Local preview' : 'Live plan' }}</span>
|
||
</div>
|
||
|
||
<div class="pc-settings">
|
||
<div class="pc-settings__controls">
|
||
<OnyxSelect
|
||
v-model="sensorId"
|
||
label="Store / sensor"
|
||
list-label="Inner-city sensors"
|
||
:options="sensorOptions"
|
||
:message="activeSensor ? `${activeSensor.id} · ${activeSensor.mean} mean / ${activeSensor.p95} p95` : undefined"
|
||
/>
|
||
<OnyxSelect
|
||
v-model="scenario"
|
||
label="Scenario"
|
||
list-label="Demo scenarios"
|
||
:options="scenarioOptions"
|
||
:message="activeScenario?.description"
|
||
/>
|
||
<div>
|
||
<p class="stat-label" style="margin-bottom: var(--onyx-density-xs)">Service standard</p>
|
||
<OnyxSegmentedControl
|
||
v-model="standard"
|
||
aria-label="Service standard"
|
||
:options="standardOptions"
|
||
name="service-standard"
|
||
/>
|
||
<p class="pc-small pc-muted" style="margin: var(--onyx-density-xs) 0 0">{{ standardLabel }}</p>
|
||
</div>
|
||
<div class="pc-settings__actions">
|
||
<OnyxButton
|
||
label="Refresh plan"
|
||
:icon="iconSync"
|
||
color="primary"
|
||
:loading="generating || status === 'pending'"
|
||
@click="generate"
|
||
/>
|
||
<span v-if="generatedAt" class="pc-small pc-muted">Updated {{ generatedAt }}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<OnyxAccordion v-model="openAssumptions" type="card">
|
||
<OnyxAccordionItem id="assumptions" value="assumptions">
|
||
<template #header>
|
||
<span>
|
||
Assumptions
|
||
<span class="pc-muted pc-small">
|
||
· {{ visitorsPerStaffHour }} visitors/staff-h · ×{{ assumptions.safety_factor.toFixed(2) }} ·
|
||
min {{ assumptions.min_staff }}
|
||
</span>
|
||
</span>
|
||
</template>
|
||
<div class="assumption-grid">
|
||
<OnyxSlider
|
||
v-model="assumptions.safety_factor"
|
||
label="Safety factor"
|
||
:min="1"
|
||
:max="1.5"
|
||
:step="0.05"
|
||
control="input"
|
||
:message="`Higher values add buffer staff. Current ×${assumptions.safety_factor.toFixed(2)}.`"
|
||
/>
|
||
<OnyxStepper
|
||
v-model="assumptions.min_staff"
|
||
label="Minimum staff"
|
||
:min="1"
|
||
:max="10"
|
||
:step-size="1"
|
||
message="Floor applied to every open hour."
|
||
/>
|
||
<OnyxSelect
|
||
v-model="assumptions.shift_length_h"
|
||
label="Shift block length"
|
||
list-label="Shift lengths"
|
||
:options="shiftLengthOptions"
|
||
message="Blocks are scheduled independently; coverage is checked per hour."
|
||
/>
|
||
<OnyxStepper
|
||
v-model="assumptions.labor_cost_eur_h"
|
||
label="Labour cost (€/hour)"
|
||
:min="8"
|
||
:max="60"
|
||
:step-size="1"
|
||
message="Assumption only. No payroll or POS data exists."
|
||
/>
|
||
<p class="pc-small pc-muted" style="grid-column: 1 / -1; margin: 0">
|
||
These four values are not query inputs of the API plan. Changing them shows a local preview;
|
||
“Use API plan” restores the server values.
|
||
</p>
|
||
<div class="form-actions" style="grid-column: 1 / -1">
|
||
<OnyxButton label="Reset assumptions" mode="outline" @click="resetAssumptions" />
|
||
<OnyxButton v-if="previewActive" label="Use API plan" mode="outline" @click="useApiPlan" />
|
||
<span class="pc-small pc-muted">
|
||
Store hours {{ apiPlan.assumptions.store_hours.open }}–{{ apiPlan.assumptions.store_hours.close }} ·
|
||
Europe/Berlin · {{ apiPlan.model_version || 'API' }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</OnyxAccordionItem>
|
||
</OnyxAccordion>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="pc-section" aria-labelledby="shifts-title">
|
||
<div class="pc-section__head">
|
||
<div>
|
||
<h2 id="shifts-title" class="pc-h2">The week, shift by shift</h2>
|
||
<p class="pc-small pc-muted">Each block is sized to its local peak. Select a day to inspect hourly coverage.</p>
|
||
</div>
|
||
<span class="pc-tag">{{ totalStaffHours }} staff-hours</span>
|
||
</div>
|
||
|
||
<OnyxTable class="desktop-table">
|
||
<template #head>
|
||
<tr>
|
||
<th scope="col">Day</th>
|
||
<th scope="col">Shift blocks (start–end · staff)</th>
|
||
<th scope="col">Staff-hours</th>
|
||
<th scope="col">Peak</th>
|
||
<th scope="col">Labour</th>
|
||
<th scope="col"><span class="onyx-visually-hidden">Inspect</span></th>
|
||
</tr>
|
||
</template>
|
||
<tr
|
||
v-for="day in daySummaries"
|
||
:key="day.date"
|
||
:class="{ 'pc-table-row--selected': day.date === selectedDay }"
|
||
>
|
||
<th scope="row" class="pc-table-day">
|
||
{{ day.weekdayLong }}
|
||
<span class="pc-muted">{{ day.dayNumber }} {{ day.month }}</span>
|
||
<span v-if="day.date === peakShift?.date" class="pc-tag pc-tag--signal">Peak</span>
|
||
</th>
|
||
<td>
|
||
<span class="pc-shift-tags">
|
||
<span v-for="shift in day.shifts" :key="`${shift.date}-${shift.start}`" class="pc-shiftblock">
|
||
<strong>{{ shift.staff }}</strong> · {{ shift.start }}–{{ shift.end }}
|
||
</span>
|
||
</span>
|
||
</td>
|
||
<td class="pc-num">{{ day.staffHours }}</td>
|
||
<td class="pc-num">{{ day.peakStaff }}</td>
|
||
<td class="pc-num">{{ formatEuro(day.cost) }}</td>
|
||
<td>
|
||
<OnyxButton label="Hours" mode="plain" density="compact" @click="selectedDay = day.date" />
|
||
</td>
|
||
</tr>
|
||
</OnyxTable>
|
||
|
||
<div class="pc-daylist">
|
||
<button
|
||
v-for="day in daySummaries"
|
||
:key="day.date"
|
||
type="button"
|
||
class="pc-daylist__row"
|
||
:class="{ 'pc-daylist__row--selected': day.date === selectedDay }"
|
||
:aria-pressed="day.date === selectedDay"
|
||
@click="selectedDay = day.date"
|
||
>
|
||
<span class="pc-daylist__day">
|
||
<strong>{{ day.weekday }}</strong>
|
||
<span>{{ day.dayNumber }} {{ day.month }}</span>
|
||
<span v-if="day.date === peakShift?.date" class="pc-tag pc-tag--signal">Peak</span>
|
||
</span>
|
||
<span class="pc-daylist__blocks">
|
||
<span v-for="shift in day.shifts" :key="`${shift.date}-${shift.start}`" class="pc-shiftblock">
|
||
<strong>{{ shift.staff }}</strong> · {{ shift.start }}–{{ shift.end }}
|
||
</span>
|
||
</span>
|
||
<span class="pc-daylist__numbers">
|
||
<span>{{ day.staffHours }} staff-hours</span>
|
||
<span>{{ formatEuro(day.cost) }}</span>
|
||
</span>
|
||
</button>
|
||
</div>
|
||
|
||
<p class="pc-small pc-muted" style="margin: 0.7rem 0 0">
|
||
Total {{ totalStaffHours }} staff-hours · {{ formatEuro(plan.summary.cost_eur) }} at
|
||
€{{ plan.assumptions.labor_cost_eur_h }}/h · CSV exports one row per shift block.
|
||
</p>
|
||
</section>
|
||
|
||
<section class="pc-section" aria-labelledby="hours-title">
|
||
<div class="pc-section__head">
|
||
<div>
|
||
<h2 id="hours-title" class="pc-h2">
|
||
Hourly coverage
|
||
<template v-if="selectedDaySummary">
|
||
· {{ selectedDaySummary.weekdayLong }} {{ selectedDaySummary.dayNumber }}
|
||
</template>
|
||
</h2>
|
||
<p class="pc-small pc-muted">
|
||
{{ selectedCovered }}/{{ selectedHours.length }} open hours covered · {{ selectedOver }} over requirement
|
||
</p>
|
||
</div>
|
||
<div style="min-width: 14rem">
|
||
<OnyxSelect
|
||
v-model="selectedDay"
|
||
label="Inspect day"
|
||
list-label="Plan days"
|
||
:options="dayOptions"
|
||
density="compact"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<OnyxTable class="desktop-table">
|
||
<template #head>
|
||
<tr>
|
||
<th scope="col">Hour</th>
|
||
<th scope="col">Forecast footfall</th>
|
||
<th scope="col">Required</th>
|
||
<th scope="col">Scheduled</th>
|
||
<th scope="col">Coverage</th>
|
||
</tr>
|
||
</template>
|
||
<tr v-for="hour in selectedHours" :key="hour.t">
|
||
<th scope="row" class="pc-table-day">{{ hourLabel(hour) }}</th>
|
||
<td class="pc-num">{{ formatNumber(hour.footfall) }}</td>
|
||
<td class="pc-num">{{ hour.required_staff }}</td>
|
||
<td class="pc-num">{{ hour.scheduled_staff }}</td>
|
||
<td>
|
||
<span
|
||
class="pc-tag"
|
||
:class="{
|
||
'pc-tag--green': hour.coverage === 'ok',
|
||
'pc-tag--signal': hour.coverage === 'over',
|
||
'pc-tag--danger': hour.coverage === 'under',
|
||
}"
|
||
>
|
||
{{ coverageLabel(hour) }}
|
||
</span>
|
||
</td>
|
||
</tr>
|
||
</OnyxTable>
|
||
|
||
<div class="pc-hourlist">
|
||
<div v-for="hour in selectedHours" :key="hour.t" class="pc-hourlist__row">
|
||
<span class="pc-hourlist__hour">{{ hourLabel(hour) }}</span>
|
||
<span class="pc-hourlist__data">
|
||
<strong>{{ hour.scheduled_staff }}</strong> scheduled · {{ hour.required_staff }} required ·
|
||
{{ formatNumber(hour.footfall) }} est./h
|
||
</span>
|
||
<span
|
||
class="pc-tag"
|
||
:class="{
|
||
'pc-tag--green': hour.coverage === 'ok',
|
||
'pc-tag--signal': hour.coverage === 'over',
|
||
'pc-tag--danger': hour.coverage === 'under',
|
||
}"
|
||
>
|
||
{{ coverageLabel(hour) }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="pc-small pc-muted" style="margin: 0.7rem 0 0">
|
||
Scheduled staff is constant inside a block. Coverage is at or above the service standard by construction;
|
||
the trade-off is visible as overstaffed hours. Store hours 10:00–20:00 local.
|
||
</p>
|
||
</section>
|
||
|
||
<div class="pc-split">
|
||
<section class="pc-panel" aria-labelledby="why-title">
|
||
<div class="pc-panel__head">
|
||
<h2 id="why-title" class="pc-h3">Why these numbers</h2>
|
||
<span class="pc-tag">API reasons</span>
|
||
</div>
|
||
<p v-if="activeScenario?.description" class="pc-small pc-muted" style="margin: 0 0 0.6rem">
|
||
{{ activeScenario.description }} The list below includes the API’s base-week weather context.
|
||
</p>
|
||
<ul class="why-list">
|
||
<li v-for="reason in why" :key="reason">
|
||
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
|
||
<span>{{ reason }}</span>
|
||
</li>
|
||
</ul>
|
||
<p v-if="previewActive" class="pc-small pc-muted" style="margin: 0.7rem 0 0">
|
||
This explains the API plan; the assumption preview above is local.
|
||
</p>
|
||
</section>
|
||
|
||
<section class="pc-panel" aria-labelledby="assumptions-title">
|
||
<div class="pc-panel__head">
|
||
<h2 id="assumptions-title" class="pc-h3">Assumptions in this plan</h2>
|
||
<span class="pc-tag">Declared</span>
|
||
</div>
|
||
<dl class="metric-list">
|
||
<div><dt>Service standard</dt><dd>{{ plan.standard }}</dd></div>
|
||
<div><dt>Visitors / staff-hour</dt><dd>{{ plan.assumptions.visitors_per_staff_hour }}</dd></div>
|
||
<div><dt>Safety factor</dt><dd>×{{ plan.assumptions.safety_factor }}</dd></div>
|
||
<div><dt>Minimum staff</dt><dd>{{ plan.assumptions.min_staff }}</dd></div>
|
||
<div><dt>Shift block</dt><dd>{{ plan.assumptions.shift_length_h }} h</dd></div>
|
||
<div><dt>Labour cost</dt><dd>{{ formatEuro(plan.assumptions.labor_cost_eur_h) }}/h</dd></div>
|
||
<div><dt>Store hours</dt><dd>{{ plan.assumptions.store_hours.open }}–{{ plan.assumptions.store_hours.close }}</dd></div>
|
||
<div><dt>Model / data</dt><dd>{{ plan.model_version || meta?.model_version || '—' }}</dd></div>
|
||
</dl>
|
||
<p class="pc-small pc-muted" style="margin: 0.8rem 0 0">
|
||
No POS, sales, queue or labour-cost feed exists. This is decision support with explicit assumptions,
|
||
not a payroll calculation or a precise ROI.
|
||
</p>
|
||
<p class="pc-small" style="margin: 0.6rem 0 0">
|
||
<NuxtLink to="/about">Method, metrics and limits</NuxtLink> ·
|
||
coverage {{ meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : '—' }}
|
||
</p>
|
||
</section>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.hero-empty {
|
||
display: flex;
|
||
min-height: 24rem;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
align-items: flex-start;
|
||
gap: 0.8rem;
|
||
}
|
||
|
||
.pc-meta {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 0.55rem;
|
||
}
|
||
|
||
.pc-meta:last-child {
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.pc-table-row--selected {
|
||
background: var(--pc-paper-2);
|
||
}
|
||
|
||
.pc-table-day {
|
||
color: var(--pc-ink);
|
||
font-weight: 750;
|
||
text-align: left;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.pc-table-day .pc-muted {
|
||
font-weight: 400;
|
||
}
|
||
|
||
.pc-table-day .pc-tag {
|
||
margin-inline-start: 0.45rem;
|
||
}
|
||
|
||
.pc-shift-tags {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.3rem;
|
||
}
|
||
|
||
.pc-shiftblock {
|
||
display: inline-flex;
|
||
align-items: baseline;
|
||
gap: 0.15rem;
|
||
padding: 0.12rem 0.35rem;
|
||
border: 1px solid var(--pc-line);
|
||
font-size: 0.72rem;
|
||
font-variant-numeric: tabular-nums;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.pc-shiftblock strong {
|
||
font-weight: 800;
|
||
}
|
||
|
||
.pc-daylist {
|
||
display: none;
|
||
border-top: 2px solid var(--pc-ink);
|
||
}
|
||
|
||
.pc-daylist__row {
|
||
display: grid;
|
||
width: 100%;
|
||
grid-template-columns: 1fr;
|
||
gap: 0.35rem;
|
||
padding: 0.7rem 0.15rem;
|
||
border: 0;
|
||
border-bottom: 1px solid var(--pc-line);
|
||
background: transparent;
|
||
color: var(--pc-ink);
|
||
font: inherit;
|
||
text-align: left;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.pc-daylist__row:hover {
|
||
background: var(--pc-paper-2);
|
||
}
|
||
|
||
.pc-daylist__row--selected {
|
||
background: var(--pc-paper-2);
|
||
box-shadow: inset 3px 0 0 var(--pc-signal);
|
||
}
|
||
|
||
.pc-daylist__day {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: baseline;
|
||
gap: 0.4rem;
|
||
}
|
||
|
||
.pc-daylist__day strong {
|
||
font-size: 1rem;
|
||
font-weight: 800;
|
||
}
|
||
|
||
.pc-daylist__day > span:not(.pc-tag) {
|
||
color: var(--pc-ink-2);
|
||
font-size: 0.8rem;
|
||
}
|
||
|
||
.pc-daylist__blocks {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.25rem;
|
||
}
|
||
|
||
.pc-daylist__numbers {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: space-between;
|
||
gap: 0.4rem;
|
||
color: var(--pc-ink-2);
|
||
font-size: 0.75rem;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-hourlist {
|
||
display: none;
|
||
border-top: 2px solid var(--pc-ink);
|
||
}
|
||
|
||
.pc-hourlist__row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 0.4rem;
|
||
padding: 0.55rem 0.15rem;
|
||
border-bottom: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.pc-hourlist__hour {
|
||
min-width: 3.5rem;
|
||
font-weight: 800;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-hourlist__data {
|
||
flex: 1 1 12rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.78rem;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-hourlist__data strong {
|
||
color: var(--pc-ink);
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.pc-daylist,
|
||
.pc-hourlist {
|
||
display: block;
|
||
}
|
||
|
||
.pc-meta:last-child {
|
||
justify-content: flex-start;
|
||
}
|
||
}
|
||
</style>
|