ci / check (push) Successful in 50s
- replace default Onyx surfaces with paper/ink, signal orange and Archivo - make /plan answer peak, staff-hours, cost vs flat and coverage above the fold - add the weekly shift board, shared plan helpers and a pulse line - rebuild /live as a phone-first dark board and /stage as a full-bleed projector - label the real 14-20 Nov window; remove 'next week' claims - keep Onyx components, SSR, live scenario updates and accessible states
583 lines
15 KiB
Vue
583 lines
15 KiB
Vue
<script setup lang="ts">
|
||
import { iconArrowRight, iconTriangleWarning } from '@sit-onyx/icons'
|
||
import { addDays, berlinParts, planWeekStart } from '#shared/staffing'
|
||
import type { MetaResponse, ScenarioState, Sensor, SeriesResponse, StaffingResponse } from '#shared/types'
|
||
import {
|
||
formatDateTime,
|
||
formatEuro,
|
||
formatNumber,
|
||
formatPercent,
|
||
formatTime,
|
||
formatWeekday,
|
||
weekLabel,
|
||
} from '~/utils/format'
|
||
import {
|
||
numberWord,
|
||
peakHourOf,
|
||
peakShiftOf,
|
||
planDays,
|
||
savingOf,
|
||
savingPctOf,
|
||
totalStaffHoursOf,
|
||
} from '~/utils/plan'
|
||
|
||
const config = useRuntimeConfig()
|
||
const demoNow = String(config.public.demoNow)
|
||
|
||
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
|
||
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
|
||
const { data: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
|
||
const live = useLiveScenario(liveScenarioState.value)
|
||
|
||
const sensorId = ref(
|
||
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
|
||
sensors.value?.[0]?.id ??
|
||
'hn-stadtgalerie-01',
|
||
)
|
||
const { data: series } = await useFetch<SeriesResponse>('/api/series', {
|
||
query: computed(() => ({ sensor: sensorId.value, step: '1h' })),
|
||
})
|
||
|
||
const { data: planData, status, refresh } = await useFetch<StaffingResponse>('/api/staffing', {
|
||
query: computed(() => ({ sensor: sensorId.value, scenario: live.scenarioId, standard: 'standard' })),
|
||
})
|
||
|
||
let lastScenarioId = live.scenarioId
|
||
watch(
|
||
() => live.revision,
|
||
() => {
|
||
if (live.scenarioId === lastScenarioId) void refresh()
|
||
lastScenarioId = live.scenarioId
|
||
},
|
||
)
|
||
|
||
const plan = computed(() => planData.value ?? null)
|
||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||
const peakShift = computed(() => peakShiftOf(plan.value))
|
||
const peakHour = computed(() => peakHourOf(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 weekStart = computed(() => {
|
||
const first = plan.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 windowTag = computed(() => {
|
||
if (!plan.value) return 'No plan'
|
||
return weekStart.value <= today.value && today.value <= weekEnd.value ? 'Today–Friday' : 'Seven days'
|
||
})
|
||
const windowLabel = computed(() => (plan.value ? weekLabel(weekStart.value, weekEnd.value) : 'Window unavailable'))
|
||
|
||
const lastPoint = computed(() => series.value?.points.at(-1))
|
||
const lastMeasured = computed(() => (lastPoint.value ? formatDateTime(lastPoint.value.t) : '—'))
|
||
const latestReading = computed(() => (lastPoint.value ? formatNumber(lastPoint.value.v) : '—'))
|
||
|
||
useHead(() => ({
|
||
title: peakShift.value
|
||
? `${numberWord(peakShift.value.staff)} on ${formatWeekday(peakShift.value.date)} — PulseCast`
|
||
: 'PulseCast — footfall to shifts',
|
||
}))
|
||
</script>
|
||
|
||
<template>
|
||
<div class="pc-page landing">
|
||
<section class="landing__hero" aria-labelledby="landing-title">
|
||
<div class="landing__copy">
|
||
<div class="landing__meta">
|
||
<span class="pc-tag">{{ windowTag }}</span>
|
||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" compact />
|
||
</div>
|
||
|
||
<h1 id="landing-title" class="landing__title">
|
||
<template v-if="peakShift">{{ numberWord(peakShift.staff) }} on {{ formatWeekday(peakShift.date) }}.</template>
|
||
<template v-else>The week, shifted.</template>
|
||
</h1>
|
||
|
||
<p class="landing__lede">
|
||
<template v-if="plan">
|
||
PulseCast turns inner-city footfall into a shift plan you can defend.
|
||
This window: <strong>{{ totalStaffHours }} staff-hours</strong>,
|
||
<strong>{{ formatEuro(plan.summary.cost_eur) }}</strong>,
|
||
<strong>{{ formatPercent(plan.summary.coverage_pct, 1) }} coverage</strong>.
|
||
</template>
|
||
<template v-else>
|
||
PulseCast turns inner-city footfall into a transparent shift plan for the week.
|
||
</template>
|
||
</p>
|
||
|
||
<div class="landing__actions">
|
||
<OnyxButton label="Open the plan" link="/plan" color="primary" :icon="iconArrowRight" icon-position="right" />
|
||
<OnyxButton label="See the forecast" link="/forecast" mode="outline" />
|
||
</div>
|
||
|
||
<ol class="landing__chain" aria-label="How the plan is made">
|
||
<li><span>Measured</span> footfall</li>
|
||
<li><span>Modelled</span> forecast</li>
|
||
<li><span>Declared</span> assumptions</li>
|
||
<li><span>Shift</span> plan</li>
|
||
</ol>
|
||
|
||
<dl class="landing__proof" aria-label="What the plan is built on">
|
||
<div>
|
||
<dt>Latest reading</dt>
|
||
<dd>
|
||
{{ latestReading }} <span>est. devices/hour</span>
|
||
<small>{{ activeSensor?.name ?? 'Stadtgalerie' }} · last point {{ lastMeasured }}</small>
|
||
</dd>
|
||
</div>
|
||
<div>
|
||
<dt>Modelled peak</dt>
|
||
<dd>
|
||
{{ peakHour ? formatNumber(peakHour.footfall) : '—' }} <span>est. devices/hour</span>
|
||
<small>{{ peakHour ? `${formatWeekday(berlinParts(peakHour.t).date)} ${formatTime(peakHour.t)}` : 'waiting for the forecast' }}</small>
|
||
</dd>
|
||
</div>
|
||
<div>
|
||
<dt>Assumed</dt>
|
||
<dd>
|
||
{{ plan?.assumptions.labor_cost_eur_h ?? 16 }} <span>€/staff-hour</span>
|
||
<small>{{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors/staff-h · ×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety</small>
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
</div>
|
||
|
||
<aside class="landing__board" aria-label="Live weekly shift board">
|
||
<div class="landing__board-head">
|
||
<div>
|
||
<p class="pc-label">The week, block by block</p>
|
||
<p class="landing__board-window">{{ windowLabel }} · {{ windowTag }}</p>
|
||
</div>
|
||
<span class="pc-tag pc-tag--signal">Live plan</span>
|
||
</div>
|
||
|
||
<template v-if="plan && daySummaries.length">
|
||
<WeekBoard
|
||
:days="daySummaries"
|
||
:peak-date="peakShift?.date"
|
||
show-pulse
|
||
label="Live weekly shift board"
|
||
/>
|
||
|
||
<div class="landing__board-receipt">
|
||
<div>
|
||
<span class="pc-label">Peak shift</span>
|
||
<strong>
|
||
<template v-if="peakShift">
|
||
{{ peakShift.staff }} staff · {{ peakShift.start }}–{{ peakShift.end }}
|
||
</template>
|
||
<template v-else>—</template>
|
||
</strong>
|
||
</div>
|
||
<div>
|
||
<span class="pc-label">Cost vs flat</span>
|
||
<strong>{{ formatEuro(plan.summary.cost_eur) }} <span>vs {{ formatEuro(plan.summary.flat_schedule_cost_eur) }}</span></strong>
|
||
<small>{{ formatEuro(savingEur) }} saved · {{ Math.round(savingPct) }}% lower</small>
|
||
</div>
|
||
<div>
|
||
<span class="pc-label">Coverage</span>
|
||
<strong>{{ formatPercent(plan.summary.coverage_pct, 1) }}</strong>
|
||
<small>{{ plan.summary.understaffed_hours }} h short · {{ plan.summary.overstaffed_hours }} h over</small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="landing__board-foot">
|
||
<span>{{ totalStaffHours }} staff-hours · {{ plan.assumptions.shift_length_h }} h blocks</span>
|
||
<NuxtLink to="/plan">Open the plan <span aria-hidden="true">→</span></NuxtLink>
|
||
</div>
|
||
</template>
|
||
|
||
<div v-else-if="status === 'error'" class="landing__board-empty" role="alert">
|
||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
|
||
<p>The live plan is unavailable. Retry when the connection is back.</p>
|
||
<OnyxButton label="Retry" mode="outline" density="compact" @click="refresh()" />
|
||
</div>
|
||
|
||
<div v-else class="landing__board-empty" aria-busy="true">
|
||
<div class="pc-skeleton" style="width: 100%; height: 9rem" />
|
||
<div class="pc-skeleton" style="width: 76%; height: 1.1rem; margin-top: 0.8rem" />
|
||
<p class="pc-small pc-muted">Loading the current plan…</p>
|
||
</div>
|
||
|
||
<div class="landing__board-note">
|
||
<span>Live demo plan · not a city-wide claim.</span>
|
||
<span>{{ meta?.coverage.sensors ?? 8 }} sensors · 580 m · no POS data</span>
|
||
</div>
|
||
</aside>
|
||
</section>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.landing {
|
||
min-height: calc(100dvh - 8rem);
|
||
justify-content: space-between;
|
||
gap: 1.25rem;
|
||
}
|
||
|
||
.landing__hero {
|
||
display: grid;
|
||
grid-template-columns: minmax(0, 1.02fr) minmax(26rem, 0.98fr);
|
||
gap: clamp(1.5rem, 4vw, 4rem);
|
||
align-items: stretch;
|
||
padding-block: clamp(0.5rem, 2vw, 1.5rem);
|
||
}
|
||
|
||
.landing__copy {
|
||
display: flex;
|
||
min-width: 0;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
gap: 1.1rem;
|
||
}
|
||
|
||
.landing__meta {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 0.55rem;
|
||
}
|
||
|
||
.landing__title {
|
||
max-width: 10ch;
|
||
margin: 0;
|
||
font-size: clamp(3.6rem, 7.1vw, 6.7rem);
|
||
font-stretch: 76%;
|
||
font-weight: 850;
|
||
line-height: 0.84;
|
||
letter-spacing: -0.04em;
|
||
text-wrap: balance;
|
||
}
|
||
|
||
.landing__lede {
|
||
max-width: 48ch;
|
||
margin: 0;
|
||
color: var(--pc-ink-2);
|
||
font-size: clamp(1.05rem, 1.35vw, 1.22rem);
|
||
line-height: 1.45;
|
||
}
|
||
|
||
.landing__lede strong {
|
||
font-weight: 780;
|
||
}
|
||
|
||
.landing__actions {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.6rem;
|
||
}
|
||
|
||
.landing__chain {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.35rem;
|
||
margin: 0;
|
||
padding: 0.65rem 0;
|
||
border-block: 1px solid var(--pc-line);
|
||
list-style: none;
|
||
counter-reset: none;
|
||
}
|
||
|
||
.landing__chain li {
|
||
display: inline-flex;
|
||
align-items: baseline;
|
||
gap: 0.3rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.72rem;
|
||
font-weight: 600;
|
||
letter-spacing: 0.02em;
|
||
}
|
||
|
||
.landing__chain li + li::before {
|
||
content: "→";
|
||
margin-inline-end: 0.2rem;
|
||
color: var(--pc-signal-text);
|
||
}
|
||
|
||
.landing__chain li span {
|
||
color: var(--pc-ink);
|
||
font-weight: 750;
|
||
text-transform: uppercase;
|
||
}
|
||
|
||
.landing__chain li span::after {
|
||
content: "";
|
||
}
|
||
|
||
.landing__proof {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||
gap: 0;
|
||
margin: 0;
|
||
border-top: 2px solid var(--pc-ink);
|
||
}
|
||
|
||
.landing__proof > div {
|
||
min-width: 0;
|
||
padding: 0.7rem 0.75rem 0;
|
||
border-inline-end: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.landing__proof > div:first-child {
|
||
padding-inline-start: 0;
|
||
}
|
||
|
||
.landing__proof > div:last-child {
|
||
border-inline-end: 0;
|
||
padding-inline-end: 0;
|
||
}
|
||
|
||
.landing__proof dt {
|
||
margin: 0;
|
||
color: var(--pc-muted);
|
||
font-size: 0.62rem;
|
||
font-weight: 700;
|
||
letter-spacing: 0.1em;
|
||
text-transform: uppercase;
|
||
}
|
||
|
||
.landing__proof dd {
|
||
margin: 0.25rem 0 0;
|
||
font-size: 1.35rem;
|
||
font-weight: 800;
|
||
letter-spacing: -0.02em;
|
||
line-height: 1;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.landing__proof dd span {
|
||
display: block;
|
||
margin-top: 0.15rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.62rem;
|
||
font-weight: 500;
|
||
letter-spacing: 0.02em;
|
||
}
|
||
|
||
.landing__proof dd small {
|
||
display: block;
|
||
margin-top: 0.35rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.65rem;
|
||
font-weight: 450;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.landing__board {
|
||
display: flex;
|
||
min-width: 0;
|
||
flex-direction: column;
|
||
border: 2px solid var(--pc-ink);
|
||
background: var(--pc-paper);
|
||
}
|
||
|
||
.landing__board-head {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: flex-start;
|
||
justify-content: space-between;
|
||
gap: 0.5rem;
|
||
padding: 0.85rem 0.85rem 0.55rem;
|
||
}
|
||
|
||
.landing__board-head p {
|
||
margin: 0;
|
||
}
|
||
|
||
.landing__board-window {
|
||
margin-top: 0.2rem !important;
|
||
color: var(--pc-muted);
|
||
font-size: 0.78rem;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.landing__board .pc-board {
|
||
border-inline: 0;
|
||
}
|
||
|
||
.landing__board-receipt {
|
||
display: grid;
|
||
grid-template-columns: 1.1fr 1.6fr 0.8fr;
|
||
gap: 0;
|
||
border-top: 2px solid var(--pc-ink);
|
||
border-bottom: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.landing__board-receipt > div {
|
||
min-width: 0;
|
||
padding: 0.7rem 0.75rem;
|
||
border-inline-end: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.landing__board-receipt > div:last-child {
|
||
border-inline-end: 0;
|
||
}
|
||
|
||
.landing__board-receipt .pc-label {
|
||
display: block;
|
||
margin-bottom: 0.25rem;
|
||
font-size: 0.58rem;
|
||
}
|
||
|
||
.landing__board-receipt strong {
|
||
display: block;
|
||
font-size: 0.95rem;
|
||
font-weight: 800;
|
||
line-height: 1.2;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.landing__board-receipt strong span {
|
||
color: var(--pc-muted);
|
||
font-size: 0.72rem;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.landing__board-receipt small {
|
||
display: block;
|
||
margin-top: 0.2rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.62rem;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.landing__board-foot {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 0.5rem;
|
||
padding: 0.55rem 0.85rem;
|
||
color: var(--pc-muted);
|
||
font-size: 0.68rem;
|
||
}
|
||
|
||
.landing__board-foot a {
|
||
color: var(--pc-ink);
|
||
font-weight: 750;
|
||
text-decoration-color: var(--pc-signal-text);
|
||
}
|
||
|
||
.landing__board-note {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: space-between;
|
||
gap: 0.35rem;
|
||
margin-top: auto;
|
||
padding: 0.45rem 0.85rem;
|
||
border-top: 1px solid var(--pc-line);
|
||
color: var(--pc-muted);
|
||
font-size: 0.6rem;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.landing__board-empty {
|
||
display: flex;
|
||
flex: 1;
|
||
min-height: 16rem;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
gap: 0.6rem;
|
||
padding: 1rem;
|
||
}
|
||
|
||
.landing__board-empty p {
|
||
margin: 0;
|
||
}
|
||
|
||
@media (max-width: 1100px) {
|
||
.landing__hero {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 1.2rem;
|
||
}
|
||
|
||
.landing__copy {
|
||
display: contents;
|
||
}
|
||
|
||
.landing__meta {
|
||
order: 1;
|
||
}
|
||
|
||
.landing__title {
|
||
order: 2;
|
||
max-width: 14ch;
|
||
}
|
||
|
||
.landing__lede {
|
||
order: 3;
|
||
}
|
||
|
||
.landing__actions {
|
||
order: 4;
|
||
}
|
||
|
||
.landing__board {
|
||
order: 5;
|
||
max-width: 46rem;
|
||
}
|
||
|
||
.landing__chain {
|
||
order: 6;
|
||
}
|
||
|
||
.landing__proof {
|
||
order: 7;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 640px) {
|
||
.landing {
|
||
min-height: 0;
|
||
}
|
||
|
||
.landing__title {
|
||
max-width: 11ch;
|
||
font-size: clamp(3rem, 14vw, 4rem);
|
||
}
|
||
|
||
.landing__proof {
|
||
grid-template-columns: minmax(0, 1fr);
|
||
}
|
||
|
||
.landing__proof > div {
|
||
display: grid;
|
||
grid-template-columns: 7rem minmax(0, 1fr);
|
||
gap: 0.4rem;
|
||
padding: 0.55rem 0;
|
||
border-inline-end: 0;
|
||
border-bottom: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.landing__proof > div:last-child {
|
||
border-bottom: 0;
|
||
}
|
||
|
||
.landing__proof dd {
|
||
font-size: 1.1rem;
|
||
}
|
||
|
||
.landing__proof dd small {
|
||
margin-top: 0.15rem;
|
||
}
|
||
|
||
.landing__board-receipt {
|
||
grid-template-columns: minmax(0, 1fr);
|
||
}
|
||
|
||
.landing__board-receipt > div {
|
||
border-inline-end: 0;
|
||
border-bottom: 1px solid var(--pc-line);
|
||
}
|
||
|
||
.landing__board-receipt > div:last-child {
|
||
border-bottom: 0;
|
||
}
|
||
}
|
||
</style>
|