- Lead with purpose and exact local/CI commands. - Remove local absolute paths, stale auth notes and unverified claims. - Keep comments to the reason or invariant they protect.
800 lines
31 KiB
Vue
800 lines
31 KiB
Vue
<script setup lang="ts">
|
||
import {
|
||
iconCalendar,
|
||
iconCheck,
|
||
iconCircleInformation,
|
||
iconDownload,
|
||
iconSync,
|
||
iconTriangleWarning,
|
||
iconUserGroup,
|
||
} 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'
|
||
|
||
useHead({ title: 'Plan next week — PulseCast' })
|
||
|
||
const config = useRuntimeConfig()
|
||
const route = useRoute()
|
||
const demoNow = String(config.public.demoNow)
|
||
const usingMock = computed(
|
||
() =>
|
||
config.public.useMock === true ||
|
||
config.public.useMock === '1' ||
|
||
config.public.useMock === '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())
|
||
// The stage scenario wins unless the URL explicitly asks for another one.
|
||
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 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 plan = computed(() => (previewActive.value ? previewBuild.value.response : apiPlan.value))
|
||
|
||
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 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))
|
||
})
|
||
|
||
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(hoursByDate.value)
|
||
.sort()
|
||
.map((date) => {
|
||
const hours = hoursByDate.value[date] ?? []
|
||
const shifts = shiftsByDate.value[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 dayDates = computed(() => daySummaries.value.map((day) => day.date))
|
||
const selectedDay = ref('')
|
||
watch(
|
||
() => dayDates.value.join(','),
|
||
() => {
|
||
if (dayDates.value.includes(selectedDay.value)) return
|
||
const preferred = addDays(weekStart.value, 5)
|
||
selectedDay.value = dayDates.value.includes(preferred) ? preferred : (dayDates.value[0] ?? '')
|
||
},
|
||
{ immediate: true },
|
||
)
|
||
|
||
const dayOptions = computed(() =>
|
||
daySummaries.value.map((day) => ({
|
||
value: day.date,
|
||
label: `${formatWeekday(day.date)} ${formatShortDate(day.date)} · ${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 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 (!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="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 ?? apiPlan.sensor ?? 'the selected store' }}</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" />
|
||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
|
||
<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">
|
||
<template v-if="usingMock">Mock mode · NUXT_PUBLIC_USE_MOCK=1 · no Go API call.</template>
|
||
<template v-else-if="previewActive">
|
||
Local preview · the Go API plan is unchanged.
|
||
</template>
|
||
<template v-else>
|
||
Go /api/staffing · scenario v{{ live.version }} · broadcast
|
||
{{ live.scenarioAt ? formatDateTime(live.scenarioAt) : '—' }} · no POS, sales or labour-cost feed.
|
||
</template>
|
||
</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>
|
||
<OnyxBadge v-if="apiPlan.cached" color="warning" density="compact">cached forecast</OnyxBadge>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<div v-if="status === 'error'" class="callout callout--warning">
|
||
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
|
||
The staffing API could not be loaded. Check that the Go API is running and that NUXT_API_INTERNAL_BASE points
|
||
to it. <span v-if="error" class="muted">{{ error.statusMessage }}</span>
|
||
</div>
|
||
<div v-else-if="status === 'success' && !apiPlan.hours.length" class="callout callout--warning">
|
||
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
|
||
No open hours are available for this store and scenario yet. Pick another sensor or check the data window.
|
||
</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">
|
||
Store, service standard and scenario are sent to Go /api/staffing. Local assumption edits render a
|
||
preview from the API forecast.
|
||
</p>
|
||
</div>
|
||
<OnyxBadge :color="usingMock ? 'warning' : previewActive ? 'warning' : 'success'" density="compact">
|
||
{{ usingMock ? 'Mock mode' : previewActive ? 'Local preview' : 'Go API' }}
|
||
</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."
|
||
/>
|
||
<p class="small muted" style="grid-column: 1 / -1; margin: 0">
|
||
These four values are not query inputs of Go /api/staffing. 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="small muted">Store hours 10:00–20:00, Europe/Berlin · {{ apiPlan.model_version || 'API' }}</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">{{ usingMock ? 'Mock mode' : 'Go API' }}</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">
|
||
The weather forecast from /api/context does not cover this plan window yet.
|
||
</p>
|
||
<p class="small muted table-note">
|
||
{{ activeScenario?.description ?? 'Base scenario uses the API forecast weather.' }}
|
||
</p>
|
||
<p v-if="previewActive" class="small muted table-note">
|
||
This card explains the API plan; the assumption preview above is local.
|
||
</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>{{ plan.model_version || meta?.model_version || '—' }}</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>
|