664 lines
25 KiB
Vue
664 lines
25 KiB
Vue
<script setup lang="ts">
|
||
import {
|
||
iconCalendar,
|
||
iconCheck,
|
||
iconCircleInformation,
|
||
iconDownload,
|
||
iconSync,
|
||
iconTriangleWarning,
|
||
iconUserGroup,
|
||
} from '@sit-onyx/icons'
|
||
import { dailyWeather, planDrivers } from '#shared/insights'
|
||
import { addDays, berlinParts, buildStaffing, isInWeek, planWeekStart, STANDARD_VISITORS_PER_STAFF_HOUR } from '#shared/staffing'
|
||
import { SCENARIOS } from '#shared/types'
|
||
import type {
|
||
ContextResponse,
|
||
ForecastResponse,
|
||
MetaResponse,
|
||
Scenario,
|
||
ScenarioPreset,
|
||
Sensor,
|
||
Shift,
|
||
StaffingHour,
|
||
Standard,
|
||
} from '#shared/types'
|
||
import {
|
||
formatDate,
|
||
formatDateTime,
|
||
formatEuro,
|
||
formatNumber,
|
||
formatPercent,
|
||
formatShortDate,
|
||
formatTime,
|
||
formatWeekday,
|
||
weekLabel,
|
||
} from '~/utils/format'
|
||
|
||
useHead({ title: 'Plan next week — PulseCast' })
|
||
|
||
const config = useRuntimeConfig()
|
||
const route = useRoute()
|
||
const demoNow = String(config.public.demoNow)
|
||
const weekStart = planWeekStart(demoNow)
|
||
const weekEnd = addDays(weekStart, 6)
|
||
|
||
function initialScenario(): Scenario {
|
||
const value = route.query.scenario
|
||
return typeof value === 'string' && SCENARIOS.includes(value as Scenario) ? (value as Scenario) : 'base'
|
||
}
|
||
|
||
const scenario = ref<Scenario>(initialScenario())
|
||
const sensorId = ref('hn-stadtgalerie-01')
|
||
const standard = ref<Standard>('standard')
|
||
const selectedDay = ref(addDays(weekStart, 5))
|
||
const approved = ref(false)
|
||
const generating = ref(false)
|
||
const generatedAt = ref('')
|
||
const openAssumptions = ref<PropertyKey[]>([])
|
||
const assumptions = reactive({
|
||
safety_factor: 1.15,
|
||
min_staff: 1,
|
||
shift_length_h: 4,
|
||
labor_cost_eur_h: 16,
|
||
})
|
||
|
||
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: forecast,
|
||
status,
|
||
refresh,
|
||
} = await useFetch<ForecastResponse>('/api/forecast', {
|
||
query: computed(() => ({
|
||
sensor: sensorId.value,
|
||
horizon: '7d',
|
||
scenario: scenario.value,
|
||
})),
|
||
})
|
||
|
||
watch(
|
||
() => route.query.scenario,
|
||
(value) => {
|
||
if (typeof value === 'string' && SCENARIOS.includes(value as Scenario)) {
|
||
scenario.value = value as Scenario
|
||
}
|
||
},
|
||
)
|
||
|
||
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 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' },
|
||
]
|
||
|
||
const build = computed(() =>
|
||
buildStaffing({
|
||
sensor: sensorId.value,
|
||
scenario: scenario.value,
|
||
standard: standard.value,
|
||
points: forecast.value?.points ?? [],
|
||
weekStart,
|
||
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,
|
||
},
|
||
data_version: forecast.value?.data_version ?? meta.value?.data_version ?? '',
|
||
model_version: forecast.value?.model_version ?? meta.value?.model_version ?? '',
|
||
context_version: forecast.value?.context_version ?? meta.value?.context_version ?? '',
|
||
}),
|
||
)
|
||
const plan = computed(() => build.value.response)
|
||
|
||
const why = computed(() =>
|
||
context.value ? planDrivers(plan.value, context.value, weekStart, scenario.value) : [],
|
||
)
|
||
const weekWeather = computed(() => {
|
||
if (!context.value) return []
|
||
return Object.values(dailyWeather(context.value.weather.forecast))
|
||
.filter((day) => isInWeek(day.date, weekStart))
|
||
.sort((a, b) => a.date.localeCompare(b.date))
|
||
})
|
||
|
||
function maxOf<T>(items: T[], score: (item: T) => number): T | undefined {
|
||
let best: T | undefined
|
||
for (const item of items) {
|
||
if (!best || score(item) > score(best)) best = item
|
||
}
|
||
return best
|
||
}
|
||
|
||
const peakHour = computed(() => maxOf(plan.value.hours, (hour) => hour.footfall))
|
||
const peakShift = computed(() => maxOf(plan.value.shifts, (shift) => shift.staff))
|
||
const totalStaffHours = computed(() =>
|
||
plan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0),
|
||
)
|
||
const savingEur = computed(() =>
|
||
Math.max(0, plan.value.summary.flat_schedule_cost_eur - plan.value.summary.cost_eur),
|
||
)
|
||
const savingPct = computed(() => {
|
||
const flat = plan.value.summary.flat_schedule_cost_eur
|
||
return flat > 0 ? (savingEur.value / flat) * 100 : 0
|
||
})
|
||
|
||
interface DaySummary {
|
||
date: string
|
||
shifts: Shift[]
|
||
staffHours: number
|
||
peakStaff: number
|
||
cost: number
|
||
}
|
||
|
||
const daySummaries = computed<DaySummary[]>(() =>
|
||
Object.keys(build.value.byDate)
|
||
.sort()
|
||
.map((date) => {
|
||
const hours = build.value.byDate[date] ?? []
|
||
const shifts = build.value.shiftsByDate[date] ?? []
|
||
const staffHours = hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0)
|
||
return {
|
||
date,
|
||
shifts,
|
||
staffHours,
|
||
peakStaff: maxOf(hours, (hour) => hour.scheduled_staff)?.scheduled_staff ?? 0,
|
||
cost: staffHours * plan.value.assumptions.labor_cost_eur_h,
|
||
}
|
||
}),
|
||
)
|
||
|
||
const dayOptions = computed(() =>
|
||
daySummaries.value.map((day) => ({
|
||
value: day.date,
|
||
label: `${formatWeekday(day.date)} ${formatShortDate(day.date)} · ${day.peakStaff} peak`,
|
||
})),
|
||
)
|
||
const selectedHours = computed<StaffingHour[]>(() => build.value.byDate[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 coverageColor(hour: StaffingHour) {
|
||
if (hour.coverage === 'under') return 'danger' as const
|
||
if (hour.coverage === 'over') return 'warning' as const
|
||
return 'success' as const
|
||
}
|
||
|
||
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'
|
||
}
|
||
|
||
async function generate() {
|
||
generating.value = true
|
||
try {
|
||
await refresh()
|
||
if (import.meta.client) generatedAt.value = formatTime(new Date().toISOString())
|
||
} finally {
|
||
generating.value = false
|
||
}
|
||
}
|
||
|
||
function resetAssumptions() {
|
||
assumptions.safety_factor = 1.15
|
||
assumptions.min_staff = 1
|
||
assumptions.shift_length_h = 4
|
||
assumptions.labor_cost_eur_h = 16
|
||
standard.value = 'standard'
|
||
}
|
||
|
||
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}.csv`
|
||
link.click()
|
||
URL.revokeObjectURL(url)
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="page page-stack">
|
||
<section class="hero" aria-labelledby="plan-headline">
|
||
<div class="hero-grid">
|
||
<div class="hero-copy">
|
||
<p class="eyebrow">Plan · {{ weekLabel(weekStart, weekEnd) }}</p>
|
||
<OnyxHeadline id="plan-headline" is="h1">
|
||
<template v-if="peakShift">
|
||
{{ formatWeekday(peakShift.date) }} peak: {{ peakShift.staff }} staff, {{ peakShift.start }}–{{ peakShift.end }}.
|
||
</template>
|
||
<template v-else>Build next week’s shift plan.</template>
|
||
</OnyxHeadline>
|
||
<p class="lede">
|
||
Forecast for <strong>{{ activeSensor?.name ?? 'Stadtgalerie' }}</strong> needs
|
||
<strong>{{ peakHour?.required_staff ?? '—' }} staff at the busiest hour</strong>. The rest of the week
|
||
runs on {{ totalStaffHours }} staff-hours at {{ formatEuro(plan.summary.cost_eur) }}.
|
||
</p>
|
||
<div class="hero-actions">
|
||
<OnyxButton
|
||
:label="approved ? 'Plan approved' : 'Approve plan'"
|
||
:icon="approved ? iconCheck : iconCalendar"
|
||
color="primary"
|
||
@click="approved = !approved"
|
||
/>
|
||
<OnyxButton label="Export CSV" :icon="iconDownload" mode="outline" @click="exportPlan" />
|
||
<OnyxBadge v-if="approved" color="success">Approved · demo</OnyxBadge>
|
||
<span v-else class="small muted">Draft for manager review</span>
|
||
</div>
|
||
<p class="small muted" style="margin: 0">
|
||
Mock forecast · updated {{ context ? formatDateTime(context.updated_at) : '—' }} · no POS, sales or
|
||
labour-cost feed.
|
||
</p>
|
||
</div>
|
||
|
||
<div class="hero-decision">
|
||
<p class="stat-label">Peak staffing decision</p>
|
||
<p class="hero-decision__value">{{ peakShift?.staff ?? '—' }} staff</p>
|
||
<p class="hero-decision__label">
|
||
<template v-if="peakShift">
|
||
{{ formatWeekday(peakShift.date) }} {{ formatShortDate(peakShift.date) }}, {{ peakShift.start }}–{{ peakShift.end }}<br />
|
||
</template>
|
||
<template v-if="peakHour">
|
||
{{ formatWeekday(berlinParts(peakHour.t).date) }} {{ String(berlinParts(peakHour.t).hour).padStart(2, '0') }}:00
|
||
peak: {{ peakHour.footfall }} est. visitors/hour
|
||
</template>
|
||
</p>
|
||
<OnyxSeparator style="margin-block: var(--onyx-density-sm)" />
|
||
<div class="reading-row">
|
||
<OnyxBadge color="success" density="compact">{{ formatPercent(plan.summary.coverage_pct, 1) }} covered</OnyxBadge>
|
||
<OnyxBadge color="warning" density="compact">{{ plan.summary.overstaffed_hours }} h over</OnyxBadge>
|
||
<OnyxBadge color="success" density="compact">{{ plan.summary.understaffed_hours }} h under</OnyxBadge>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<div v-if="status === 'error'" class="callout callout--warning">
|
||
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
|
||
The mock forecast could not be loaded. Check the Nitro mock routes and reload.
|
||
</div>
|
||
|
||
<section class="summary-grid" aria-label="Plan summary">
|
||
<MetricCard
|
||
label="Coverage"
|
||
:value="formatPercent(plan.summary.coverage_pct, 1)"
|
||
badge="All hours covered"
|
||
badge-color="success"
|
||
:icon="iconCheck"
|
||
hint="Shift blocks cover the block peak, so low hours are intentionally overstaffed."
|
||
/>
|
||
<MetricCard
|
||
label="Labour cost"
|
||
:value="formatEuro(plan.summary.cost_eur)"
|
||
:icon="iconUserGroup"
|
||
:hint="`${totalStaffHours} staff-hours × €${plan.assumptions.labor_cost_eur_h}/h assumption`"
|
||
/>
|
||
<MetricCard
|
||
label="vs flat schedule"
|
||
:value="`−${formatEuro(savingEur)}`"
|
||
:badge="`${formatPercent(savingPct, 0)} lower`"
|
||
badge-color="success"
|
||
:hint="`Flat schedule would cost ${formatEuro(plan.summary.flat_schedule_cost_eur)}.`"
|
||
/>
|
||
<MetricCard
|
||
label="Plan risk"
|
||
:value="`${plan.summary.overstaffed_hours} h over`"
|
||
:badge="`${plan.summary.understaffed_hours} h under`"
|
||
badge-color="success"
|
||
:hint="`${selectedOver} of ${selectedHours.length} selected-day hours are above requirement.`"
|
||
/>
|
||
</section>
|
||
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<div>
|
||
<OnyxHeadline is="h2">Plan inputs</OnyxHeadline>
|
||
<p class="small muted" style="margin: 0">
|
||
Change store, service standard or scenario. The plan recomputes from the mock forecast.
|
||
</p>
|
||
</div>
|
||
<OnyxBadge color="info" density="compact">Mock forecast</OnyxBadge>
|
||
</div>
|
||
|
||
<div class="form-grid">
|
||
<div style="display: grid; gap: var(--onyx-density-md); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr))">
|
||
<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="small muted" style="margin: var(--onyx-density-xs) 0 0">{{ standardLabel }}</p>
|
||
</div>
|
||
<div style="display: flex; align-items: flex-end; gap: var(--onyx-density-sm); flex-wrap: wrap">
|
||
<OnyxButton
|
||
label="Generate plan"
|
||
:icon="iconSync"
|
||
color="primary"
|
||
:loading="generating || status === 'pending'"
|
||
@click="generate"
|
||
/>
|
||
<span v-if="generatedAt" class="small muted">Updated {{ generatedAt }}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<OnyxAccordion v-model="openAssumptions" type="card">
|
||
<OnyxAccordionItem id="assumptions" value="assumptions">
|
||
<template #header>
|
||
<span>
|
||
Assumptions
|
||
<span class="muted 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."
|
||
/>
|
||
<div class="form-actions" style="grid-column: 1 / -1">
|
||
<OnyxButton label="Reset assumptions" mode="outline" @click="resetAssumptions" />
|
||
<span class="small muted">Store hours 10:00–20:00, Europe/Berlin · {{ forecast?.model_version ?? 'mock' }}</span>
|
||
</div>
|
||
</div>
|
||
</OnyxAccordionItem>
|
||
</OnyxAccordion>
|
||
</div>
|
||
</OnyxCard>
|
||
|
||
<div class="split-grid">
|
||
<div class="card-stack">
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<div>
|
||
<OnyxHeadline is="h2">Recommended shifts</OnyxHeadline>
|
||
<p class="small muted" style="margin: 0">2–5 h blocks per day; staff count covers the block peak.</p>
|
||
</div>
|
||
<div class="legend">
|
||
<span class="legend__item"><span class="legend__swatch legend__swatch--over" /> over requirement</span>
|
||
<span class="legend__item"><span class="legend__swatch" /> scheduled staff</span>
|
||
</div>
|
||
</div>
|
||
|
||
<OnyxTable class="desktop-table" striped>
|
||
<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="{ 'peak-row': day.date === peakShift?.date }">
|
||
<th scope="row" style="text-align: left; font-weight: 600">
|
||
{{ formatWeekday(day.date) }}
|
||
<span class="muted" style="font-weight: 400"> {{ formatShortDate(day.date) }}</span>
|
||
<OnyxBadge v-if="day.date === peakShift?.date" color="warning" density="compact" style="margin-left: 0.35rem">peak</OnyxBadge>
|
||
</th>
|
||
<td>
|
||
<div class="shift-tags">
|
||
<OnyxTag
|
||
v-for="shift in day.shifts"
|
||
:key="`${shift.date}-${shift.start}`"
|
||
:label="`${shift.start}–${shift.end} · ${shift.staff}`"
|
||
density="compact"
|
||
color="neutral"
|
||
/>
|
||
</div>
|
||
</td>
|
||
<td>{{ formatNumber(day.staffHours) }}</td>
|
||
<td>{{ day.peakStaff }}</td>
|
||
<td>{{ formatEuro(day.cost) }}</td>
|
||
<td>
|
||
<OnyxButton
|
||
label="Hours"
|
||
mode="plain"
|
||
density="compact"
|
||
@click="selectedDay = day.date"
|
||
/>
|
||
</td>
|
||
</tr>
|
||
</OnyxTable>
|
||
|
||
<div class="day-card-list">
|
||
<OnyxCard v-for="day in daySummaries" :key="day.date" density="compact">
|
||
<div class="day-card__header">
|
||
<p class="day-card__date">
|
||
{{ formatWeekday(day.date) }} <span class="muted">{{ formatShortDate(day.date) }}</span>
|
||
</p>
|
||
<OnyxBadge :color="day.date === peakShift?.date ? 'warning' : 'neutral'" density="compact">
|
||
{{ day.peakStaff }} peak
|
||
</OnyxBadge>
|
||
</div>
|
||
<div class="shift-tags" style="margin-top: var(--onyx-density-xs)">
|
||
<OnyxTag
|
||
v-for="shift in day.shifts"
|
||
:key="`${shift.date}-${shift.start}`"
|
||
:label="`${shift.start}–${shift.end} · ${shift.staff}`"
|
||
density="compact"
|
||
/>
|
||
</div>
|
||
<div class="day-card__metrics">
|
||
<span>{{ formatNumber(day.staffHours) }} staff-hours</span>
|
||
<span>{{ formatEuro(day.cost) }}</span>
|
||
</div>
|
||
<OnyxButton label="View hourly detail" mode="plain" density="compact" @click="selectedDay = day.date" />
|
||
</OnyxCard>
|
||
</div>
|
||
|
||
<p class="small muted table-note">
|
||
Total {{ totalStaffHours }} staff-hours · {{ formatEuro(plan.summary.cost_eur) }} at
|
||
€{{ plan.assumptions.labor_cost_eur_h }}/h · exported CSV has one row per shift block.
|
||
</p>
|
||
</OnyxCard>
|
||
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<div>
|
||
<OnyxHeadline is="h2">Hourly coverage</OnyxHeadline>
|
||
<p class="small muted" style="margin: 0">
|
||
{{ selectedCovered }}/{{ selectedHours.length }} open hours covered · {{ selectedOver }} over requirement
|
||
</p>
|
||
</div>
|
||
<div style="min-width: 13rem">
|
||
<OnyxSelect
|
||
v-model="selectedDay"
|
||
label="Inspect day"
|
||
list-label="Plan days"
|
||
:options="dayOptions"
|
||
density="compact"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<OnyxTable striped with-page-scrolling :table-attrs="{ style: 'min-width: 34rem' }">
|
||
<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" style="text-align: left; font-weight: 600">{{ String(berlinParts(hour.t).hour).padStart(2, '0') }}:00</th>
|
||
<td>{{ formatNumber(hour.footfall) }}</td>
|
||
<td>{{ hour.required_staff }}</td>
|
||
<td>{{ hour.scheduled_staff }}</td>
|
||
<td>
|
||
<OnyxBadge :color="coverageColor(hour)" density="compact">{{ coverageLabel(hour) }}</OnyxBadge>
|
||
</td>
|
||
</tr>
|
||
</OnyxTable>
|
||
<p class="small muted table-note">
|
||
Scheduled staff is constant inside a block. Coverage is <em>at or above</em> the service standard by
|
||
construction; the trade-off is visible as overstaffed hours. Store hours 10:00–20:00 local.
|
||
</p>
|
||
</OnyxCard>
|
||
</div>
|
||
|
||
<aside class="card-stack">
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<OnyxHeadline is="h2">Why this plan</OnyxHeadline>
|
||
<OnyxBadge color="info" density="compact">Context</OnyxBadge>
|
||
</div>
|
||
<ul class="why-list">
|
||
<li v-for="reason in why" :key="reason">
|
||
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
|
||
<span>{{ reason }}</span>
|
||
</li>
|
||
</ul>
|
||
|
||
<OnyxSeparator style="margin-block: var(--onyx-density-md)" />
|
||
<p class="stat-label" style="margin-bottom: var(--onyx-density-xs)">Weather during the plan week</p>
|
||
<WeatherStrip :days="weekWeather" />
|
||
<p v-if="!weekWeather.length" class="small muted table-note">
|
||
Weather forecast does not cover this window in the mock context.
|
||
</p>
|
||
<p class="small muted table-note">
|
||
{{ activeScenario?.description ?? 'Base scenario uses the mock forecast weather.' }}
|
||
</p>
|
||
</OnyxCard>
|
||
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<OnyxHeadline is="h3">Assumptions in this plan</OnyxHeadline>
|
||
</div>
|
||
<dl class="metric-list">
|
||
<div><dt>Service standard</dt><dd>{{ 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>{{ forecast?.model_version ?? meta?.model_version ?? 'mock' }}</dd></div>
|
||
</dl>
|
||
<p class="small muted table-note" style="margin-top: var(--onyx-density-md)">
|
||
No POS, sales, queue or labour-cost data exists. This is decision support with explicit assumptions,
|
||
not a payroll calculation or a precise ROI.
|
||
</p>
|
||
<OnyxButton
|
||
label="Edit assumptions"
|
||
mode="plain"
|
||
density="compact"
|
||
@click="openAssumptions = ['assumptions']"
|
||
/>
|
||
</OnyxCard>
|
||
|
||
<OnyxCard>
|
||
<div class="card-header">
|
||
<OnyxHeadline is="h3">Data and limits</OnyxHeadline>
|
||
</div>
|
||
<p class="small muted" style="margin-top: 0">
|
||
{{ meta?.coverage.sensors ?? 8 }} sensors · {{ meta?.coverage.cadence_min ?? 15 }}-min cadence ·
|
||
coverage {{ meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : '—' }}
|
||
</p>
|
||
<ul class="small muted" style="margin: var(--onyx-density-xs) 0 0; padding-left: 1.1rem">
|
||
<li v-for="limit in meta?.limits ?? []" :key="limit">{{ limit }}</li>
|
||
</ul>
|
||
</OnyxCard>
|
||
</aside>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.peak-row {
|
||
background: var(--onyx-color-base-warning-100);
|
||
}
|
||
</style>
|