Add advanced parameter editing across all 3 layouts
Make hardcoded model parameters (vehicle lengths, delivery days, simulation interval, delivery profiles) runtime-editable. Add shared ParameterEditor components with theme support for Webapp, Rebel Excel, and DMI Cockpit layouts. Support adding custom functions, vehicles, and distributions with reset-to-defaults. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
654a69a485
commit
2c471a6628
@@ -0,0 +1,755 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo, useState } from 'react';
|
||||
import {
|
||||
VEHICLES,
|
||||
DISTRIBUTIONS,
|
||||
FUNCTIONS,
|
||||
DELIVERY_PROFILES,
|
||||
PROFILE_METADATA,
|
||||
PERIODS,
|
||||
SIM_PARAMS,
|
||||
getDefaultVehicleLengths,
|
||||
getDefaultDeliveryDays,
|
||||
getDefaultDeliveryProfiles,
|
||||
} from '@/lib/model-data';
|
||||
import type { SimulationState } from '@/lib/use-simulation-state';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Theme types
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type ParameterTheme = 'rebel' | 'dmi' | 'webapp';
|
||||
|
||||
interface ThemeColors {
|
||||
bg: string;
|
||||
cardBg: string;
|
||||
headerBg: string;
|
||||
headerColor: string;
|
||||
border: string;
|
||||
text: string;
|
||||
textMuted: string;
|
||||
accent: string;
|
||||
accentText: string;
|
||||
inputBorder: string;
|
||||
inputBg: string;
|
||||
changedBg: string;
|
||||
warningBg: string;
|
||||
warningBorder: string;
|
||||
fontFamily: string;
|
||||
}
|
||||
|
||||
function getThemeColors(theme: ParameterTheme): ThemeColors {
|
||||
if (theme === 'rebel') {
|
||||
return {
|
||||
bg: '#2d2d2d',
|
||||
cardBg: '#ffffff',
|
||||
headerBg: '#c0504d',
|
||||
headerColor: '#ffffff',
|
||||
border: '#e0e0e0',
|
||||
text: '#333333',
|
||||
textMuted: '#666666',
|
||||
accent: '#c0504d',
|
||||
accentText: '#ffffff',
|
||||
inputBorder: '#e0e0e0',
|
||||
inputBg: '#ffffff',
|
||||
changedBg: '#fff8e1',
|
||||
warningBg: '#fff3e0',
|
||||
warningBorder: '#ff9800',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
};
|
||||
}
|
||||
// dmi / webapp share DMI palette
|
||||
return {
|
||||
bg: '#f5f7fa',
|
||||
cardBg: '#ffffff',
|
||||
headerBg: '#003366',
|
||||
headerColor: '#ffffff',
|
||||
border: '#d4dce8',
|
||||
text: '#1a1a2e',
|
||||
textMuted: '#6b7b8d',
|
||||
accent: '#003366',
|
||||
accentText: '#ffffff',
|
||||
inputBorder: '#d4dce8',
|
||||
inputBg: '#ffffff',
|
||||
changedBg: '#fffde7',
|
||||
warningBg: '#fff3e0',
|
||||
warningBorder: '#ff9800',
|
||||
fontFamily: 'var(--font-ibm-plex-sans), sans-serif',
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const defaultLengths = getDefaultVehicleLengths();
|
||||
const defaultDays = getDefaultDeliveryDays();
|
||||
const defaultProfiles = getDefaultDeliveryProfiles();
|
||||
|
||||
function isChanged(current: number, defaultVal: number | undefined): boolean {
|
||||
return defaultVal !== undefined && current !== defaultVal;
|
||||
}
|
||||
|
||||
function periodDistSum(dist: number[]): number {
|
||||
return dist.reduce((s, v) => s + v, 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// AlgemeenEditor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function AlgemeenEditor({
|
||||
state,
|
||||
theme,
|
||||
}: {
|
||||
state: SimulationState;
|
||||
theme: ParameterTheme;
|
||||
}) {
|
||||
const tc = getThemeColors(theme);
|
||||
|
||||
const cellStyle: React.CSSProperties = {
|
||||
padding: '6px 10px',
|
||||
borderBottom: `1px solid ${tc.border}`,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.8rem',
|
||||
color: tc.text,
|
||||
};
|
||||
|
||||
const headerCellStyle: React.CSSProperties = {
|
||||
...cellStyle,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.7rem',
|
||||
textTransform: 'uppercase' as const,
|
||||
backgroundColor: tc.headerBg,
|
||||
color: tc.headerColor,
|
||||
borderBottom: 'none',
|
||||
};
|
||||
|
||||
const inputStyle = (changed: boolean): React.CSSProperties => ({
|
||||
width: '80px',
|
||||
padding: '4px 8px',
|
||||
border: `1px solid ${tc.inputBorder}`,
|
||||
borderRadius: '3px',
|
||||
fontSize: '0.8rem',
|
||||
fontFamily: tc.fontFamily,
|
||||
color: tc.text,
|
||||
textAlign: 'center' as const,
|
||||
outline: 'none',
|
||||
backgroundColor: changed ? tc.changedBg : tc.inputBg,
|
||||
});
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
||||
{/* Vehicle Lengths */}
|
||||
<div>
|
||||
<h4 style={{ fontFamily: tc.fontFamily, fontWeight: 700, fontSize: '0.85rem', color: tc.text, marginBottom: '8px' }}>
|
||||
Voertuigtypen & Lengte
|
||||
</h4>
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'left' }}>Voertuigtype</th>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'center' }}>Lengte (m)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{state.allVehicles.map((v) => {
|
||||
const isCustom = !VEHICLES.find((dv) => dv.id === v.id);
|
||||
const changed = isChanged(state.vehicleLengths[v.id] ?? v.length, defaultLengths[v.id]);
|
||||
return (
|
||||
<tr key={v.id}>
|
||||
<td style={cellStyle}>
|
||||
{isCustom ? (
|
||||
<input
|
||||
type="text"
|
||||
value={v.name}
|
||||
onChange={(e) => state.handleCustomVehicleNameChange(v.id, e.target.value)}
|
||||
style={{ ...inputStyle(false), width: '200px', textAlign: 'left' }}
|
||||
/>
|
||||
) : (
|
||||
v.name
|
||||
)}
|
||||
</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.5}
|
||||
value={state.vehicleLengths[v.id] ?? v.length}
|
||||
onChange={(e) => state.handleVehicleLengthChange(v.id, parseFloat(e.target.value) || 0)}
|
||||
style={inputStyle(changed)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
{state.allVehicles.length < 7 && (
|
||||
<button
|
||||
onClick={state.handleAddVehicle}
|
||||
style={{
|
||||
marginTop: '8px',
|
||||
padding: '5px 14px',
|
||||
border: `1px dashed ${tc.border}`,
|
||||
backgroundColor: 'transparent',
|
||||
color: tc.textMuted,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
+ Voertuigtype toevoegen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Distribution Delivery Days */}
|
||||
<div>
|
||||
<h4 style={{ fontFamily: tc.fontFamily, fontWeight: 700, fontSize: '0.85rem', color: tc.text, marginBottom: '8px' }}>
|
||||
Distributietypen & Leveringsdagen
|
||||
</h4>
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'left' }}>Distributietype</th>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'center' }}>Leveringsdagen/week</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{state.allDistributions.map((d) => {
|
||||
const isCustom = !DISTRIBUTIONS.find((dd) => dd.id === d.id);
|
||||
const changed = isChanged(state.deliveryDays[d.id] ?? d.deliveryDays, defaultDays[d.id]);
|
||||
return (
|
||||
<tr key={d.id}>
|
||||
<td style={cellStyle}>
|
||||
{isCustom ? (
|
||||
<input
|
||||
type="text"
|
||||
value={d.name}
|
||||
onChange={(e) => state.handleCustomDistributionNameChange(d.id, e.target.value)}
|
||||
style={{ ...inputStyle(false), width: '200px', textAlign: 'left' }}
|
||||
/>
|
||||
) : (
|
||||
d.name
|
||||
)}
|
||||
</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={7}
|
||||
value={state.deliveryDays[d.id] ?? d.deliveryDays}
|
||||
onChange={(e) => state.handleDeliveryDaysChange(d.id, parseInt(e.target.value, 10) || 1)}
|
||||
style={inputStyle(changed)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
{state.allDistributions.length < 18 && (
|
||||
<button
|
||||
onClick={state.handleAddDistribution}
|
||||
style={{
|
||||
marginTop: '8px',
|
||||
padding: '5px 14px',
|
||||
border: `1px dashed ${tc.border}`,
|
||||
backgroundColor: 'transparent',
|
||||
color: tc.textMuted,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
+ Distributietype toevoegen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Simulation Interval */}
|
||||
<div>
|
||||
<h4 style={{ fontFamily: tc.fontFamily, fontWeight: 700, fontSize: '0.85rem', color: tc.text, marginBottom: '8px' }}>
|
||||
Simulatie-interval
|
||||
</h4>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={60}
|
||||
value={state.intervalMinutes}
|
||||
onChange={(e) => state.handleIntervalMinutesChange(parseInt(e.target.value, 10) || 10)}
|
||||
style={inputStyle(state.intervalMinutes !== SIM_PARAMS.intervalMinutes)}
|
||||
/>
|
||||
<span style={{ fontFamily: tc.fontFamily, fontSize: '0.8rem', color: tc.textMuted }}>minuten</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Functions list with add button */}
|
||||
<div>
|
||||
<h4 style={{ fontFamily: tc.fontFamily, fontWeight: 700, fontSize: '0.85rem', color: tc.text, marginBottom: '8px' }}>
|
||||
Functies
|
||||
</h4>
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'left' }}>Functie</th>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'left' }}>Eenheid</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{state.allFunctions.map((f) => {
|
||||
const isCustom = !FUNCTIONS.find((df) => df.id === f.id);
|
||||
return (
|
||||
<tr key={f.id}>
|
||||
<td style={cellStyle}>
|
||||
{isCustom ? (
|
||||
<input
|
||||
type="text"
|
||||
value={f.name}
|
||||
onChange={(e) => state.handleCustomFunctionNameChange(f.id, e.target.value)}
|
||||
style={{ ...inputStyle(false), width: '200px', textAlign: 'left' }}
|
||||
/>
|
||||
) : (
|
||||
f.name
|
||||
)}
|
||||
</td>
|
||||
<td style={cellStyle}>{f.unit}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
{state.allFunctions.length < 15 && (
|
||||
<button
|
||||
onClick={state.handleAddFunction}
|
||||
style={{
|
||||
marginTop: '8px',
|
||||
padding: '5px 14px',
|
||||
border: `1px dashed ${tc.border}`,
|
||||
backgroundColor: 'transparent',
|
||||
color: tc.textMuted,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
+ Functie toevoegen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Reset button */}
|
||||
{state.hasAdvancedOverrides && (
|
||||
<button
|
||||
onClick={state.handleResetAdvancedParams}
|
||||
style={{
|
||||
padding: '8px 20px',
|
||||
backgroundColor: tc.accent,
|
||||
color: tc.accentText,
|
||||
border: 'none',
|
||||
borderRadius: '4px',
|
||||
fontFamily: tc.fontFamily,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.8rem',
|
||||
cursor: 'pointer',
|
||||
alignSelf: 'flex-start',
|
||||
}}
|
||||
>
|
||||
Reset naar standaardwaarden
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DeliveryProfileEditor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function DeliveryProfileEditor({
|
||||
state,
|
||||
theme,
|
||||
functionId,
|
||||
onBack,
|
||||
}: {
|
||||
state: SimulationState;
|
||||
theme: ParameterTheme;
|
||||
functionId: string;
|
||||
onBack: () => void;
|
||||
}) {
|
||||
const tc = getThemeColors(theme);
|
||||
const func = state.allFunctions.find((f) => f.id === functionId);
|
||||
if (!func) return null;
|
||||
|
||||
const vehicles = state.allVehicles;
|
||||
const numVehicles = vehicles.length;
|
||||
|
||||
// Find all profile keys for this function (existing + potential for all distributions)
|
||||
const profileEntries = useMemo(() => {
|
||||
const entries: { profileKey: string; distName: string; distId: string }[] = [];
|
||||
for (const dist of state.allDistributions) {
|
||||
const key = `${functionId}_${dist.id}`;
|
||||
const profile = state.deliveryProfiles[key];
|
||||
// Show if profile exists (has data) or is in default set
|
||||
if (profile || DELIVERY_PROFILES[key]) {
|
||||
entries.push({ profileKey: key, distName: dist.name, distId: dist.id });
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}, [functionId, state.allDistributions, state.deliveryProfiles]);
|
||||
|
||||
// Distributions that don't have a profile yet (for "add" button)
|
||||
const availableDistributions = useMemo(() => {
|
||||
return state.allDistributions.filter((d) => {
|
||||
const key = `${functionId}_${d.id}`;
|
||||
return !state.deliveryProfiles[key] && !DELIVERY_PROFILES[key];
|
||||
});
|
||||
}, [functionId, state.allDistributions, state.deliveryProfiles]);
|
||||
|
||||
const cellStyle: React.CSSProperties = {
|
||||
padding: '4px 6px',
|
||||
borderBottom: `1px solid ${tc.border}`,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
color: tc.text,
|
||||
verticalAlign: 'middle',
|
||||
};
|
||||
|
||||
const headerCellStyle: React.CSSProperties = {
|
||||
...cellStyle,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.65rem',
|
||||
textTransform: 'uppercase' as const,
|
||||
backgroundColor: tc.headerBg,
|
||||
color: tc.headerColor,
|
||||
borderBottom: 'none',
|
||||
whiteSpace: 'nowrap' as const,
|
||||
};
|
||||
|
||||
const smallInputStyle = (changed: boolean): React.CSSProperties => ({
|
||||
width: '65px',
|
||||
padding: '3px 5px',
|
||||
border: `1px solid ${tc.inputBorder}`,
|
||||
borderRadius: '2px',
|
||||
fontSize: '0.75rem',
|
||||
fontFamily: tc.fontFamily,
|
||||
color: tc.text,
|
||||
textAlign: 'center' as const,
|
||||
outline: 'none',
|
||||
backgroundColor: changed ? tc.changedBg : tc.inputBg,
|
||||
});
|
||||
|
||||
const periodHeaders = PERIODS.map((p) => p.name);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Back button + title */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '12px', marginBottom: '16px' }}>
|
||||
<button
|
||||
onClick={onBack}
|
||||
style={{
|
||||
padding: '5px 12px',
|
||||
border: `1px solid ${tc.border}`,
|
||||
backgroundColor: tc.cardBg,
|
||||
color: tc.text,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
← Terug
|
||||
</button>
|
||||
<h4 style={{ fontFamily: tc.fontFamily, fontWeight: 700, fontSize: '1rem', color: tc.text, margin: 0 }}>
|
||||
Beleveringsprofiel: {func.name}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
{profileEntries.length === 0 && (
|
||||
<p style={{ fontFamily: tc.fontFamily, fontSize: '0.8rem', color: tc.textMuted }}>
|
||||
Geen beleveringsprofielen voor deze functie.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{profileEntries.map(({ profileKey, distName }) => {
|
||||
const profile = state.deliveryProfiles[profileKey] ?? DELIVERY_PROFILES[profileKey];
|
||||
if (!profile) return null;
|
||||
|
||||
const defaultProfile = defaultProfiles[profileKey];
|
||||
const meta = PROFILE_METADATA[profileKey];
|
||||
|
||||
return (
|
||||
<div key={profileKey} style={{ marginBottom: '24px' }}>
|
||||
{/* Distribution section header */}
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
backgroundColor: tc.accent,
|
||||
color: tc.accentText,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.8rem',
|
||||
marginBottom: '2px',
|
||||
}}
|
||||
>
|
||||
{distName}
|
||||
</div>
|
||||
|
||||
{/* Description + remarks */}
|
||||
{meta && (meta.description || meta.remarks) && (
|
||||
<div
|
||||
style={{
|
||||
padding: '6px 12px',
|
||||
backgroundColor: theme === 'rebel' ? '#f0f8ff' : '#f0f4ff',
|
||||
borderLeft: `3px solid ${tc.accent}`,
|
||||
marginBottom: '8px',
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
color: tc.textMuted,
|
||||
}}
|
||||
>
|
||||
{meta.description && <span>{meta.description}</span>}
|
||||
{meta.remarks && <span style={{ marginLeft: '8px', fontStyle: 'italic' }}>({meta.remarks})</span>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'left', minWidth: '140px' }}>Voertuigtype</th>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'center' }}>Stops/week</th>
|
||||
<th style={{ ...headerCellStyle, textAlign: 'center' }}>Duur (min)</th>
|
||||
{periodHeaders.map((ph) => (
|
||||
<th key={ph} style={{ ...headerCellStyle, textAlign: 'center' }}>{ph}</th>
|
||||
))}
|
||||
<th style={{ ...headerCellStyle, textAlign: 'center' }}>Totaal %</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{vehicles.map((v, vi) => {
|
||||
const stops = profile.stopsPerWeekPerUnit[vi] ?? 0;
|
||||
const dur = profile.duration[vi] ?? 0;
|
||||
const pDist = profile.periodDistribution[vi] ?? [0, 0, 0, 0];
|
||||
const isInactive = stops === 0 && dur === 0 && pDist.every((p) => p === 0);
|
||||
|
||||
const defStops = defaultProfile?.stopsPerWeekPerUnit[vi] ?? 0;
|
||||
const defDur = defaultProfile?.duration[vi] ?? 0;
|
||||
const defPDist = defaultProfile?.periodDistribution[vi] ?? [0, 0, 0, 0];
|
||||
|
||||
const pDistPercent = pDist.map((p) => Math.round(p * 100 * 100) / 100);
|
||||
const pDistSum = periodDistSum(pDist);
|
||||
const pDistSumPct = Math.round(pDistSum * 100 * 100) / 100;
|
||||
const hasWarning = !isInactive && pDistSum > 0 && Math.abs(pDistSum - 1) > 0.02;
|
||||
|
||||
if (isInactive) {
|
||||
return (
|
||||
<tr key={v.id}>
|
||||
<td style={{ ...cellStyle, color: tc.textMuted }}>{v.name}</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={stops}
|
||||
onChange={(e) => state.handleProfileFieldChange(profileKey, 'stopsPerWeekPerUnit', vi, parseFloat(e.target.value) || 0)}
|
||||
style={smallInputStyle(false)}
|
||||
/>
|
||||
</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={dur}
|
||||
onChange={(e) => state.handleProfileFieldChange(profileKey, 'duration', vi, parseFloat(e.target.value) || 0)}
|
||||
style={smallInputStyle(false)}
|
||||
/>
|
||||
</td>
|
||||
{[0, 1, 2, 3].map((pi) => (
|
||||
<td key={pi} style={{ ...cellStyle, textAlign: 'center', color: tc.textMuted }}>-</td>
|
||||
))}
|
||||
<td style={{ ...cellStyle, textAlign: 'center', color: tc.textMuted }}>-</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<tr key={v.id}>
|
||||
<td style={cellStyle}>{v.name}</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={stops}
|
||||
onChange={(e) => state.handleProfileFieldChange(profileKey, 'stopsPerWeekPerUnit', vi, parseFloat(e.target.value) || 0)}
|
||||
style={smallInputStyle(isChanged(stops, defStops))}
|
||||
/>
|
||||
</td>
|
||||
<td style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={dur}
|
||||
onChange={(e) => state.handleProfileFieldChange(profileKey, 'duration', vi, parseFloat(e.target.value) || 0)}
|
||||
style={smallInputStyle(isChanged(dur, defDur))}
|
||||
/>
|
||||
</td>
|
||||
{[0, 1, 2, 3].map((pi) => (
|
||||
<td key={pi} style={{ ...cellStyle, textAlign: 'center' }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={100}
|
||||
step={1}
|
||||
value={pDistPercent[pi]}
|
||||
onChange={(e) => {
|
||||
const pctVal = parseFloat(e.target.value) || 0;
|
||||
state.handleProfilePeriodDistChange(profileKey, vi, pi, pctVal / 100);
|
||||
}}
|
||||
style={{
|
||||
...smallInputStyle(isChanged(pDist[pi], defPDist[pi])),
|
||||
width: '55px',
|
||||
}}
|
||||
/>
|
||||
</td>
|
||||
))}
|
||||
<td
|
||||
style={{
|
||||
...cellStyle,
|
||||
textAlign: 'center',
|
||||
fontWeight: 600,
|
||||
color: hasWarning ? '#e65100' : tc.text,
|
||||
backgroundColor: hasWarning ? tc.warningBg : 'transparent',
|
||||
}}
|
||||
>
|
||||
{pDistSumPct}%
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{/* Warning */}
|
||||
{vehicles.some((_, vi) => {
|
||||
const pDist = profile.periodDistribution[vi] ?? [0, 0, 0, 0];
|
||||
const isInactive = (profile.stopsPerWeekPerUnit[vi] ?? 0) === 0;
|
||||
const sum = periodDistSum(pDist);
|
||||
return !isInactive && sum > 0 && Math.abs(sum - 1) > 0.02;
|
||||
}) && (
|
||||
<div
|
||||
style={{
|
||||
padding: '6px 12px',
|
||||
backgroundColor: tc.warningBg,
|
||||
borderLeft: `3px solid ${tc.warningBorder}`,
|
||||
marginTop: '4px',
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
color: '#e65100',
|
||||
}}
|
||||
>
|
||||
Let op: periodeVerdeling telt niet op tot 100%. Controleer de percentages.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Add profile for another distribution */}
|
||||
{availableDistributions.length > 0 && (
|
||||
<div style={{ marginTop: '12px' }}>
|
||||
<AddProfileButton
|
||||
availableDistributions={availableDistributions}
|
||||
functionId={functionId}
|
||||
numVehicles={numVehicles}
|
||||
state={state}
|
||||
tc={tc}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AddProfileButton({
|
||||
availableDistributions,
|
||||
functionId,
|
||||
numVehicles,
|
||||
state,
|
||||
tc,
|
||||
}: {
|
||||
availableDistributions: { id: string; name: string }[];
|
||||
functionId: string;
|
||||
numVehicles: number;
|
||||
state: SimulationState;
|
||||
tc: ThemeColors;
|
||||
}) {
|
||||
const [showSelect, setShowSelect] = useState(false);
|
||||
|
||||
if (!showSelect) {
|
||||
return (
|
||||
<button
|
||||
onClick={() => setShowSelect(true)}
|
||||
style={{
|
||||
padding: '5px 14px',
|
||||
border: `1px dashed ${tc.border}`,
|
||||
backgroundColor: 'transparent',
|
||||
color: tc.textMuted,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
+ Profiel toevoegen voor andere distributie
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<select
|
||||
onChange={(e) => {
|
||||
if (e.target.value) {
|
||||
state.handleEnsureProfile(`${functionId}_${e.target.value}`, numVehicles);
|
||||
setShowSelect(false);
|
||||
}
|
||||
}}
|
||||
defaultValue=""
|
||||
style={{
|
||||
padding: '4px 8px',
|
||||
border: `1px solid ${tc.inputBorder}`,
|
||||
borderRadius: '3px',
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
}}
|
||||
>
|
||||
<option value="" disabled>Kies distributie...</option>
|
||||
{availableDistributions.map((d) => (
|
||||
<option key={d.id} value={d.id}>{d.name}</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
onClick={() => setShowSelect(false)}
|
||||
style={{
|
||||
padding: '4px 8px',
|
||||
border: `1px solid ${tc.border}`,
|
||||
backgroundColor: 'transparent',
|
||||
color: tc.textMuted,
|
||||
fontFamily: tc.fontFamily,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
borderRadius: '3px',
|
||||
}}
|
||||
>
|
||||
Annuleren
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -18,8 +18,11 @@ import {
|
||||
import { Slider } from '@/components/ui/slider';
|
||||
import { VEHICLES, FUNCTIONS } from '@/lib/model-data';
|
||||
import type { SimulationState, LayoutType } from '@/lib/use-simulation-state';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_LOGOS } from '@/lib/content';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_SECTIONS, CONTACT, CASUS_GERARD_DOUSTRAAT } from '@/lib/content';
|
||||
import { HandleidingDiagram } from '@/components/HandleidingDiagrams';
|
||||
import { HandleidingTableRenderer } from '@/components/HandleidingTable';
|
||||
import LayoutSwitcher from '@/components/LayoutSwitcher';
|
||||
import { AlgemeenEditor, DeliveryProfileEditor } from '@/components/ParameterEditor';
|
||||
import {
|
||||
DMI,
|
||||
PERIOD_COLORS,
|
||||
@@ -168,7 +171,7 @@ function EmptyState({ message }: { message: string }) {
|
||||
// Main Layout Component
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type DmiNavMode = 'cockpit' | 'cover' | 'handleiding';
|
||||
type DmiNavMode = 'cockpit' | 'cover' | 'handleiding' | 'casus' | 'parameters';
|
||||
|
||||
export default function DmiCockpitLayout({
|
||||
state,
|
||||
@@ -180,6 +183,8 @@ export default function DmiCockpitLayout({
|
||||
onLayoutChange: (layout: LayoutType) => void;
|
||||
}) {
|
||||
const [navMode, setNavMode] = useState<DmiNavMode>('cockpit');
|
||||
const [extendedSim, setExtendedSim] = useState(false);
|
||||
const [paramView, setParamView] = useState<'algemeen' | string>('algemeen');
|
||||
|
||||
// --- Computed values ---
|
||||
const chosenServiceLevel = useMemo(() => {
|
||||
@@ -271,12 +276,12 @@ export default function DmiCockpitLayout({
|
||||
margin: '4px 0 0 0',
|
||||
}}
|
||||
>
|
||||
{navMode === 'cockpit' ? 'Cockpit' : navMode === 'cover' ? 'Cover' : 'Handleiding'}
|
||||
{navMode === 'cockpit' ? 'Cockpit' : navMode === 'cover' ? 'Cover' : navMode === 'casus' ? 'Casus' : navMode === 'parameters' ? 'Parameters' : 'Handleiding'}
|
||||
</p>
|
||||
</div>
|
||||
{/* Nav buttons */}
|
||||
<div style={{ display: 'flex', gap: '4px' }}>
|
||||
{(['cover', 'handleiding', 'cockpit'] as DmiNavMode[]).map((mode) => (
|
||||
{(['cover', 'handleiding', 'casus', 'cockpit', 'parameters'] as DmiNavMode[]).map((mode) => (
|
||||
<button
|
||||
key={mode}
|
||||
onClick={() => setNavMode(mode)}
|
||||
@@ -305,8 +310,8 @@ export default function DmiCockpitLayout({
|
||||
<Image
|
||||
src="/dmi-logo-diap.png"
|
||||
alt="DMI Logo"
|
||||
width={120}
|
||||
height={40}
|
||||
width={200}
|
||||
height={64}
|
||||
style={{ objectFit: 'contain' }}
|
||||
priority
|
||||
/>
|
||||
@@ -367,44 +372,33 @@ export default function DmiCockpitLayout({
|
||||
{COVER.description}
|
||||
</p>
|
||||
|
||||
{/* Partner logos grid */}
|
||||
<div
|
||||
style={{
|
||||
borderTop: `1px solid ${DMI.blueTint2}`,
|
||||
paddingTop: '32px',
|
||||
}}
|
||||
>
|
||||
<p style={{ ...labelMono, marginBottom: '20px' }}>Partners</p>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'center',
|
||||
gap: '32px',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{PARTNER_LOGOS.map((logo) => (
|
||||
<div
|
||||
key={logo.src}
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={100}
|
||||
height={50}
|
||||
style={{ objectFit: 'contain', maxHeight: '50px' }}
|
||||
/>
|
||||
<span style={{ ...bodyText, fontSize: '0.65rem', color: DMI.darkGray }}>
|
||||
{logo.organization}
|
||||
</span>
|
||||
{/* Partner logos — grouped by role */}
|
||||
<div style={{ borderTop: `1px solid ${DMI.blueTint2}`, paddingTop: '32px' }}>
|
||||
{PARTNER_SECTIONS.map((section) => (
|
||||
<div key={section.label} style={{ marginBottom: '24px' }}>
|
||||
<p style={{ ...bodyText, fontSize: '0.75rem', fontStyle: 'italic', color: DMI.darkGray, marginBottom: '12px' }}>
|
||||
{section.label}
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: '32px', alignItems: 'center' }}>
|
||||
{section.logos.map((logo) => (
|
||||
<Image
|
||||
key={logo.src}
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={110}
|
||||
height={50}
|
||||
style={{ objectFit: 'contain', maxHeight: '50px' }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div style={{ borderTop: `1px solid ${DMI.blueTint2}`, paddingTop: '16px', marginTop: '8px' }}>
|
||||
<p style={{ ...labelMono, marginBottom: '4px' }}>{CONTACT.label}</p>
|
||||
{CONTACT.lines.map((line) => (
|
||||
<p key={line} style={{ ...bodyText, fontSize: '0.75rem', color: DMI.darkGray, margin: 0, lineHeight: 1.6 }}>
|
||||
{line}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -456,6 +450,12 @@ export default function DmiCockpitLayout({
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.tables?.map((table, ti) => (
|
||||
<HandleidingTableRenderer key={ti} table={table} />
|
||||
))}
|
||||
{section.diagrams?.map((key) => (
|
||||
<HandleidingDiagram key={key} diagramKey={key} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -480,6 +480,153 @@ export default function DmiCockpitLayout({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ================================================================
|
||||
CASUS VIEW
|
||||
================================================================ */}
|
||||
{navMode === 'casus' && (
|
||||
<div style={{ padding: '32px', maxWidth: '900px', margin: '0 auto' }}>
|
||||
<h2 style={{ ...heading, fontSize: '1.6rem', marginBottom: '8px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.title}
|
||||
</h2>
|
||||
<p style={{ ...bodyText, fontSize: '0.95rem', color: DMI.mediumBlue, marginBottom: '20px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.subtitle}
|
||||
</p>
|
||||
<p style={{ ...bodyText, fontSize: '0.9rem', lineHeight: 1.7, marginBottom: '28px', color: DMI.darkGray }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.intro}
|
||||
</p>
|
||||
|
||||
{CASUS_GERARD_DOUSTRAAT.sections.map((section, sIdx) => (
|
||||
<div
|
||||
key={sIdx}
|
||||
style={{
|
||||
backgroundColor: DMI.white,
|
||||
borderRadius: '8px',
|
||||
padding: '20px 24px',
|
||||
marginBottom: '16px',
|
||||
boxShadow: '0 1px 3px rgba(0,0,0,0.06)',
|
||||
}}
|
||||
>
|
||||
<h3 style={{ ...heading, fontSize: '1.1rem', marginBottom: '12px' }}>
|
||||
{section.title}
|
||||
</h3>
|
||||
{section.paragraphs.map((p, pIdx) => (
|
||||
<p key={pIdx} style={{ ...bodyText, fontSize: '0.85rem', lineHeight: 1.7, whiteSpace: 'pre-line', marginBottom: '8px' }}>
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.images && section.images.map((img, iIdx) => (
|
||||
<figure key={iIdx} style={{ margin: '12px 0 0 0' }}>
|
||||
<img
|
||||
src={img.src}
|
||||
alt={img.alt}
|
||||
style={{ width: '100%', borderRadius: '6px', border: `1px solid ${DMI.blueTint2}` }}
|
||||
/>
|
||||
{img.caption && (
|
||||
<figcaption style={{ ...bodyText, fontSize: '0.7rem', color: DMI.darkGray, marginTop: '6px', fontStyle: 'italic' }}>
|
||||
{img.caption}
|
||||
</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: DMI.white,
|
||||
borderRadius: '8px',
|
||||
padding: '20px 24px',
|
||||
marginBottom: '16px',
|
||||
boxShadow: '0 1px 3px rgba(0,0,0,0.06)',
|
||||
}}
|
||||
>
|
||||
<h3 style={{ ...heading, fontSize: '1.1rem', marginBottom: '12px' }}>
|
||||
Probeer het zelf
|
||||
</h3>
|
||||
<p style={{ ...bodyText, fontSize: '0.85rem', lineHeight: 1.7, marginBottom: '16px' }}>
|
||||
Laad de invoerwaarden van de Gerard Doustraat casus in het model, of begin met een leeg model.
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
onClick={() => { state.resetToGerardDoustraat(); setNavMode('cockpit'); }}
|
||||
style={{
|
||||
padding: '8px 16px', borderRadius: '4px', border: 'none',
|
||||
backgroundColor: DMI.yellow, color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontWeight: 700, fontSize: '0.8rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Laad Casus Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { state.resetToBlank(); setNavMode('cockpit'); }}
|
||||
style={{
|
||||
padding: '8px 16px', borderRadius: '4px',
|
||||
border: `2px solid ${DMI.darkBlue}`, backgroundColor: 'transparent',
|
||||
color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontWeight: 700, fontSize: '0.8rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Begin met leeg model
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ================================================================
|
||||
PARAMETERS VIEW
|
||||
================================================================ */}
|
||||
{navMode === 'parameters' && (
|
||||
<div style={{ padding: '32px', maxWidth: '1100px', margin: '0 auto' }}>
|
||||
{paramView === 'algemeen' ? (
|
||||
<>
|
||||
<Panel title="Algemene Parameters">
|
||||
<AlgemeenEditor state={state} theme="dmi" />
|
||||
</Panel>
|
||||
<div style={{ marginTop: '16px' }}>
|
||||
<Panel title="Beleveringsprofielen">
|
||||
<p style={{ ...bodyText, fontSize: '0.85rem', marginBottom: '16px', color: DMI.darkGray }}>
|
||||
Selecteer een functie om het beleveringsprofiel te bewerken.
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
||||
{state.allFunctions.map((func) => (
|
||||
<button
|
||||
key={func.id}
|
||||
onClick={() => setParamView(func.id)}
|
||||
style={{
|
||||
padding: '5px 14px',
|
||||
borderRadius: '4px',
|
||||
border: `1px solid ${DMI.blueTint2}`,
|
||||
backgroundColor: DMI.blueTint3,
|
||||
color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontWeight: 500,
|
||||
fontSize: '0.75rem',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
{func.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Panel title="Beleveringsprofiel">
|
||||
<DeliveryProfileEditor
|
||||
state={state}
|
||||
theme="dmi"
|
||||
functionId={paramView}
|
||||
onBack={() => setParamView('algemeen')}
|
||||
/>
|
||||
</Panel>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ================================================================
|
||||
COCKPIT VIEW (existing content)
|
||||
================================================================ */}
|
||||
@@ -547,6 +694,30 @@ export default function DmiCockpitLayout({
|
||||
>
|
||||
{/* Panel 1: Inventarisatie Functies */}
|
||||
<Panel title="Inventarisatie Functies">
|
||||
<div style={{ display: 'flex', gap: '6px', marginBottom: '12px' }}>
|
||||
<button
|
||||
onClick={state.resetToGerardDoustraat}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: '4px', border: `1px solid ${DMI.blueTint1}`,
|
||||
backgroundColor: DMI.blueTint3, color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans), sans-serif',
|
||||
fontWeight: 500, fontSize: '0.65rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={state.resetToBlank}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: '4px', border: `1px solid ${DMI.blueTint1}`,
|
||||
backgroundColor: DMI.blueTint3, color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans), sans-serif',
|
||||
fontWeight: 500, fontSize: '0.65rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Leeg model
|
||||
</button>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '16px' }}>
|
||||
{/* Left: function inputs with mini bars */}
|
||||
<div style={{ flex: '1 1 55%', maxHeight: '440px', overflowY: 'auto' }}>
|
||||
@@ -993,11 +1164,27 @@ export default function DmiCockpitLayout({
|
||||
<p style={{ ...labelMono, marginBottom: '6px' }}>Simulaties: {state.numSimulations.toLocaleString('nl-NL')}</p>
|
||||
<Slider
|
||||
min={100}
|
||||
max={5000}
|
||||
step={100}
|
||||
max={extendedSim ? 50000 : 5000}
|
||||
step={extendedSim ? 500 : 100}
|
||||
value={[state.numSimulations]}
|
||||
onValueChange={(vals) => state.setNumSimulations(vals[0])}
|
||||
/>
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '4px' }}>
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '6px', cursor: 'pointer', userSelect: 'none' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={extendedSim}
|
||||
onChange={(e) => {
|
||||
setExtendedSim(e.target.checked);
|
||||
if (!e.target.checked && state.numSimulations > 5000) {
|
||||
state.setNumSimulations(5000);
|
||||
}
|
||||
}}
|
||||
style={{ accentColor: DMI.darkBlue }}
|
||||
/>
|
||||
<span style={{ ...labelMono, fontSize: '0.65rem' }}>Uitgebreid (max 50.000)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={state.handleRun}
|
||||
|
||||
@@ -8,7 +8,10 @@ import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip as RechartsTooltip,
|
||||
import { Loader2, Play } from 'lucide-react';
|
||||
import { Slider } from '@/components/ui/slider';
|
||||
import LayoutSwitcher from '@/components/LayoutSwitcher';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_LOGOS } from '@/lib/content';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_SECTIONS, CONTACT, CASUS_GERARD_DOUSTRAAT } from '@/lib/content';
|
||||
import { HandleidingDiagram } from '@/components/HandleidingDiagrams';
|
||||
import { HandleidingTableRenderer } from '@/components/HandleidingTable';
|
||||
import { AlgemeenEditor, DeliveryProfileEditor } from '@/components/ParameterEditor';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Rebel Color Scheme
|
||||
@@ -59,6 +62,7 @@ const CLUSTER_COLORS: Record<number, string> = {
|
||||
const TABS = [
|
||||
{ id: 'cover', label: 'Cover' },
|
||||
{ id: 'handleiding', label: 'Handleiding' },
|
||||
{ id: 'casus', label: 'Casus' },
|
||||
{ id: 'cockpit', label: 'Cockpit' },
|
||||
{ id: 'inputs', label: 'Inputs' },
|
||||
{ id: 'algemeen', label: 'Algemeen' },
|
||||
@@ -72,7 +76,7 @@ type TabId = (typeof TABS)[number]['id'];
|
||||
function RebelLogo() {
|
||||
return (
|
||||
<Image
|
||||
src="/rebel-logo.png"
|
||||
src="/logos/rebel-badge.png"
|
||||
alt="Rebel"
|
||||
width={44}
|
||||
height={44}
|
||||
@@ -234,6 +238,7 @@ export default function RebelExcelLayout({
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabId>('cockpit');
|
||||
const [selectedFunction, setSelectedFunction] = useState<string | null>('algemeen');
|
||||
const [extendedSim, setExtendedSim] = useState(false);
|
||||
|
||||
// --- Derived data for charts ---
|
||||
|
||||
@@ -393,37 +398,49 @@ export default function RebelExcelLayout({
|
||||
{COVER.description}
|
||||
</p>
|
||||
<div style={{ borderTop: `2px solid ${REBEL.coral}`, paddingTop: '24px' }}>
|
||||
<p
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 700,
|
||||
color: REBEL.coral,
|
||||
textTransform: 'uppercase',
|
||||
letterSpacing: '0.05em',
|
||||
marginBottom: '16px',
|
||||
}}
|
||||
>
|
||||
Partners
|
||||
</p>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'center',
|
||||
gap: '24px',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{PARTNER_LOGOS.map((logo) => (
|
||||
<Image
|
||||
key={logo.src}
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={80}
|
||||
height={40}
|
||||
style={{ objectFit: 'contain', maxHeight: '40px' }}
|
||||
/>
|
||||
{PARTNER_SECTIONS.map((section) => (
|
||||
<div key={section.label} style={{ marginBottom: '20px' }}>
|
||||
<p
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.7rem',
|
||||
fontStyle: 'italic',
|
||||
color: REBEL.tabInactive,
|
||||
marginBottom: '10px',
|
||||
}}
|
||||
>
|
||||
{section.label}
|
||||
</p>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'center',
|
||||
gap: '24px',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{section.logos.map((logo) => (
|
||||
<Image
|
||||
key={logo.src}
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={100}
|
||||
height={44}
|
||||
style={{ objectFit: 'contain', maxHeight: '44px' }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div style={{ marginTop: '16px', borderTop: `1px solid ${REBEL.border}`, paddingTop: '12px' }}>
|
||||
<p style={{ fontFamily: 'Calibri, Arial, sans-serif', fontSize: '0.7rem', fontWeight: 700, color: REBEL.textDark, marginBottom: '4px' }}>
|
||||
{CONTACT.label}
|
||||
</p>
|
||||
{CONTACT.lines.map((line) => (
|
||||
<p key={line} style={{ fontFamily: 'Calibri, Arial, sans-serif', fontSize: '0.7rem', color: REBEL.tabInactive, margin: 0, lineHeight: 1.6 }}>
|
||||
{line}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -461,6 +478,12 @@ export default function RebelExcelLayout({
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.tables?.map((table, ti) => (
|
||||
<HandleidingTableRenderer key={ti} table={table} theme="rebel" />
|
||||
))}
|
||||
{section.diagrams?.map((key) => (
|
||||
<HandleidingDiagram key={key} diagramKey={key} theme="rebel" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -514,6 +537,98 @@ export default function RebelExcelLayout({
|
||||
);
|
||||
}
|
||||
|
||||
function renderCasusTab() {
|
||||
return (
|
||||
<div style={{ padding: '24px', maxWidth: '900px', margin: '0 auto' }}>
|
||||
<h2 style={{ fontFamily: 'Calibri, sans-serif', fontSize: '1.5rem', fontWeight: 700, color: REBEL.coral, marginBottom: '6px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.title}
|
||||
</h2>
|
||||
<p style={{ fontFamily: 'Calibri, sans-serif', fontSize: '0.95rem', color: REBEL.textDark, marginBottom: '16px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.subtitle}
|
||||
</p>
|
||||
<p style={{ fontFamily: 'Calibri, sans-serif', fontSize: '0.9rem', color: REBEL.textDark, lineHeight: 1.7, marginBottom: '24px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.intro}
|
||||
</p>
|
||||
|
||||
{CASUS_GERARD_DOUSTRAAT.sections.map((section, sIdx) => (
|
||||
<div
|
||||
key={sIdx}
|
||||
style={{
|
||||
backgroundColor: REBEL.white,
|
||||
border: `1px solid ${REBEL.border}`,
|
||||
borderRadius: '4px',
|
||||
padding: '16px 20px',
|
||||
marginBottom: '12px',
|
||||
}}
|
||||
>
|
||||
<h3 style={{ fontFamily: 'Calibri, sans-serif', fontSize: '1.1rem', fontWeight: 700, color: REBEL.coral, marginBottom: '10px' }}>
|
||||
{section.title}
|
||||
</h3>
|
||||
{section.paragraphs.map((p, pIdx) => (
|
||||
<p key={pIdx} style={{ fontFamily: 'Calibri, sans-serif', fontSize: '0.85rem', color: REBEL.textDark, lineHeight: 1.7, whiteSpace: 'pre-line', marginBottom: '8px' }}>
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.images && section.images.map((img, iIdx) => (
|
||||
<figure key={iIdx} style={{ margin: '12px 0 0 0' }}>
|
||||
<img
|
||||
src={img.src}
|
||||
alt={img.alt}
|
||||
style={{ width: '100%', borderRadius: '4px', border: `1px solid ${REBEL.border}` }}
|
||||
/>
|
||||
{img.caption && (
|
||||
<figcaption style={{ fontFamily: 'Calibri, sans-serif', fontSize: '0.75rem', color: REBEL.tabInactive, marginTop: '6px', fontStyle: 'italic' }}>
|
||||
{img.caption}
|
||||
</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: REBEL.white,
|
||||
border: `1px solid ${REBEL.border}`,
|
||||
borderRadius: '4px',
|
||||
padding: '16px 20px',
|
||||
marginBottom: '12px',
|
||||
}}
|
||||
>
|
||||
<h3 style={{ fontFamily: 'Calibri, sans-serif', fontSize: '1.1rem', fontWeight: 700, color: REBEL.coral, marginBottom: '10px' }}>
|
||||
Probeer het zelf
|
||||
</h3>
|
||||
<p style={{ fontFamily: 'Calibri, sans-serif', fontSize: '0.85rem', color: REBEL.textDark, lineHeight: 1.7, marginBottom: '14px' }}>
|
||||
Laad de invoerwaarden van de Gerard Doustraat casus in het model, of begin met een leeg model.
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
onClick={() => { state.resetToGerardDoustraat(); setActiveTab('cockpit' as TabId); }}
|
||||
style={{
|
||||
padding: '8px 16px', borderRadius: '4px', border: 'none',
|
||||
backgroundColor: REBEL.coral, color: REBEL.white,
|
||||
fontFamily: 'Calibri, sans-serif', fontWeight: 700, fontSize: '0.85rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Laad Casus Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { state.resetToBlank(); setActiveTab('cockpit' as TabId); }}
|
||||
style={{
|
||||
padding: '8px 16px', borderRadius: '4px',
|
||||
border: `2px solid ${REBEL.coral}`, backgroundColor: 'transparent',
|
||||
color: REBEL.coral,
|
||||
fontFamily: 'Calibri, sans-serif', fontWeight: 700, fontSize: '0.85rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Begin met leeg model
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function renderCockpitTab() {
|
||||
return (
|
||||
<div style={{ padding: '16px' }}>
|
||||
@@ -1119,11 +1234,29 @@ export default function RebelExcelLayout({
|
||||
</p>
|
||||
<Slider
|
||||
min={100}
|
||||
max={5000}
|
||||
step={100}
|
||||
max={extendedSim ? 50000 : 5000}
|
||||
step={extendedSim ? 500 : 100}
|
||||
value={[numSimulations]}
|
||||
onValueChange={(vals) => setNumSimulations(vals[0])}
|
||||
/>
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '3px' }}>
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '4px', cursor: 'pointer', userSelect: 'none' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={extendedSim}
|
||||
onChange={(e) => {
|
||||
setExtendedSim(e.target.checked);
|
||||
if (!e.target.checked && numSimulations > 5000) {
|
||||
setNumSimulations(5000);
|
||||
}
|
||||
}}
|
||||
style={{ accentColor: REBEL.coral }}
|
||||
/>
|
||||
<span style={{ fontFamily: 'Calibri, Arial, sans-serif', fontSize: '0.55rem', color: REBEL.textDark }}>
|
||||
Uitgebreid (max 50.000)
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleRun}
|
||||
@@ -1631,6 +1764,32 @@ export default function RebelExcelLayout({
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{/* Reset buttons */}
|
||||
<div style={{ display: 'flex', gap: '8px', marginBottom: '12px' }}>
|
||||
<button
|
||||
onClick={state.resetToGerardDoustraat}
|
||||
style={{
|
||||
padding: '6px 14px', border: `1px solid ${REBEL.border}`,
|
||||
backgroundColor: REBEL.offWhite, color: REBEL.textDark,
|
||||
fontFamily: 'Calibri, Arial, sans-serif', fontWeight: 600, fontSize: '0.75rem',
|
||||
cursor: 'pointer', borderRadius: '2px',
|
||||
}}
|
||||
>
|
||||
Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={state.resetToBlank}
|
||||
style={{
|
||||
padding: '6px 14px', border: `1px solid ${REBEL.border}`,
|
||||
backgroundColor: REBEL.offWhite, color: REBEL.textDark,
|
||||
fontFamily: 'Calibri, Arial, sans-serif', fontWeight: 600, fontSize: '0.75rem',
|
||||
cursor: 'pointer', borderRadius: '2px',
|
||||
}}
|
||||
>
|
||||
Leeg model
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Buttons row */}
|
||||
<div style={{ marginBottom: '12px' }}>
|
||||
<p
|
||||
@@ -1644,22 +1803,38 @@ export default function RebelExcelLayout({
|
||||
>
|
||||
Algemene Inputs
|
||||
</p>
|
||||
<button
|
||||
onClick={() => setSelectedFunction('algemeen')}
|
||||
style={{
|
||||
padding: '8px 20px',
|
||||
backgroundColor: selectedFunction === 'algemeen' ? REBEL.coral : REBEL.darkBg2,
|
||||
color: REBEL.white,
|
||||
border: 'none',
|
||||
fontSize: '0.8rem',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
marginBottom: '16px',
|
||||
}}
|
||||
>
|
||||
Algemene Inputs
|
||||
</button>
|
||||
<div style={{ display: 'flex', gap: '6px', marginBottom: '16px' }}>
|
||||
<button
|
||||
onClick={() => setSelectedFunction('algemeen')}
|
||||
style={{
|
||||
padding: '8px 20px',
|
||||
backgroundColor: selectedFunction === 'algemeen' ? REBEL.coral : REBEL.darkBg2,
|
||||
color: REBEL.white,
|
||||
border: 'none',
|
||||
fontSize: '0.8rem',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Aantal per Functie
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setSelectedFunction('parameters')}
|
||||
style={{
|
||||
padding: '8px 20px',
|
||||
backgroundColor: selectedFunction === 'parameters' ? REBEL.coral : REBEL.darkBg2,
|
||||
color: REBEL.white,
|
||||
border: 'none',
|
||||
fontSize: '0.8rem',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Parameters
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p
|
||||
style={{
|
||||
@@ -1673,7 +1848,7 @@ export default function RebelExcelLayout({
|
||||
Beleveringsprofielen
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}>
|
||||
{FUNCTIONS.map((func) => (
|
||||
{state.allFunctions.map((func) => (
|
||||
<button
|
||||
key={func.id}
|
||||
onClick={() => setSelectedFunction(func.id)}
|
||||
@@ -1716,125 +1891,24 @@ export default function RebelExcelLayout({
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
padding: '8px 10px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
fontSize: '0.7rem',
|
||||
textTransform: 'uppercase',
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Functie
|
||||
</th>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
padding: '8px 10px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
fontSize: '0.7rem',
|
||||
textTransform: 'uppercase',
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Omschrijving
|
||||
</th>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
padding: '8px 10px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
fontSize: '0.7rem',
|
||||
textTransform: 'uppercase',
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Eenheid
|
||||
</th>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '8px 10px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
fontSize: '0.7rem',
|
||||
textTransform: 'uppercase',
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Aantal
|
||||
</th>
|
||||
<th style={{ textAlign: 'left', padding: '8px 10px', borderBottom: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.textDark, fontSize: '0.7rem', textTransform: 'uppercase', backgroundColor: REBEL.offWhite }}>Functie</th>
|
||||
<th style={{ textAlign: 'left', padding: '8px 10px', borderBottom: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.textDark, fontSize: '0.7rem', textTransform: 'uppercase', backgroundColor: REBEL.offWhite }}>Omschrijving</th>
|
||||
<th style={{ textAlign: 'left', padding: '8px 10px', borderBottom: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.textDark, fontSize: '0.7rem', textTransform: 'uppercase', backgroundColor: REBEL.offWhite }}>Eenheid</th>
|
||||
<th style={{ textAlign: 'center', padding: '8px 10px', borderBottom: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.textDark, fontSize: '0.7rem', textTransform: 'uppercase', backgroundColor: REBEL.offWhite }}>Aantal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{FUNCTIONS.map((func, idx) => (
|
||||
<tr
|
||||
key={func.id}
|
||||
style={{
|
||||
backgroundColor: idx % 2 === 0 ? REBEL.white : REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
<td
|
||||
style={{
|
||||
padding: '6px 10px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
fontWeight: 600,
|
||||
color: REBEL.textDark,
|
||||
}}
|
||||
>
|
||||
{func.name}
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
padding: '6px 10px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
color: REBEL.tabInactive,
|
||||
fontSize: '0.75rem',
|
||||
}}
|
||||
>
|
||||
{func.description}
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
padding: '6px 10px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
color: REBEL.textDark,
|
||||
fontSize: '0.75rem',
|
||||
}}
|
||||
>
|
||||
{func.unit}
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '6px 10px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
}}
|
||||
>
|
||||
{state.allFunctions.map((func, idx) => (
|
||||
<tr key={func.id} style={{ backgroundColor: idx % 2 === 0 ? REBEL.white : REBEL.offWhite }}>
|
||||
<td style={{ padding: '6px 10px', borderBottom: `1px solid ${REBEL.gridLine}`, fontWeight: 600, color: REBEL.textDark }}>{func.name}</td>
|
||||
<td style={{ padding: '6px 10px', borderBottom: `1px solid ${REBEL.gridLine}`, color: REBEL.tabInactive, fontSize: '0.75rem' }}>{func.description}</td>
|
||||
<td style={{ padding: '6px 10px', borderBottom: `1px solid ${REBEL.gridLine}`, color: REBEL.textDark, fontSize: '0.75rem' }}>{func.unit}</td>
|
||||
<td style={{ textAlign: 'center', padding: '6px 10px', borderBottom: `1px solid ${REBEL.gridLine}` }}>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
type="number" min={0}
|
||||
value={functionCounts[func.id] ?? 0}
|
||||
onChange={(e) => handleFunctionCountChange(func.id, e.target.value)}
|
||||
style={{
|
||||
width: '80px',
|
||||
padding: '4px 8px',
|
||||
border: `1px solid ${REBEL.border}`,
|
||||
fontSize: '0.8rem',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
color: REBEL.greenDark,
|
||||
fontWeight: 700,
|
||||
textAlign: 'center',
|
||||
outline: 'none',
|
||||
}}
|
||||
style={{ width: '80px', padding: '4px 8px', border: `1px solid ${REBEL.border}`, fontSize: '0.8rem', fontFamily: 'Calibri, Arial, sans-serif', color: REBEL.greenDark, fontWeight: 700, textAlign: 'center', outline: 'none' }}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1842,349 +1916,28 @@ export default function RebelExcelLayout({
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td
|
||||
colSpan={3}
|
||||
style={{
|
||||
padding: '8px 10px',
|
||||
borderTop: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
}}
|
||||
>
|
||||
Totaal Functies
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '8px 10px',
|
||||
borderTop: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
color: REBEL.greenDark,
|
||||
fontSize: '1rem',
|
||||
}}
|
||||
>
|
||||
{totalFunctions.toLocaleString('nl-NL')}
|
||||
</td>
|
||||
<td colSpan={3} style={{ padding: '8px 10px', borderTop: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.textDark }}>Totaal Functies</td>
|
||||
<td style={{ textAlign: 'center', padding: '8px 10px', borderTop: `2px solid ${REBEL.coral}`, fontWeight: 700, color: REBEL.greenDark, fontSize: '1rem' }}>{totalFunctions.toLocaleString('nl-NL')}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</ExcelPanel>
|
||||
)}
|
||||
|
||||
{selectedFunction && selectedFunction !== 'algemeen' && (
|
||||
<ExcelPanel title={`Beleveringsprofiel: ${FUNCTIONS.find((f) => f.id === selectedFunction)?.name ?? selectedFunction}`}>
|
||||
{(() => {
|
||||
const func = FUNCTIONS.find((f) => f.id === selectedFunction);
|
||||
if (!func) return <p>Functie niet gevonden</p>;
|
||||
{selectedFunction === 'parameters' && (
|
||||
<ExcelPanel title="Parameters">
|
||||
<AlgemeenEditor state={state} theme="rebel" />
|
||||
</ExcelPanel>
|
||||
)}
|
||||
|
||||
const count = functionCounts[func.id] ?? 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Function count input */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '12px',
|
||||
marginBottom: '16px',
|
||||
padding: '10px 14px',
|
||||
backgroundColor: REBEL.offWhite,
|
||||
border: `1px solid ${REBEL.border}`,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: REBEL.textDark,
|
||||
}}
|
||||
>
|
||||
Aantal {func.unit}:
|
||||
</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={count}
|
||||
onChange={(e) => handleFunctionCountChange(func.id, e.target.value)}
|
||||
style={{
|
||||
width: '100px',
|
||||
padding: '6px 10px',
|
||||
border: `1px solid ${REBEL.border}`,
|
||||
fontSize: '0.9rem',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
color: REBEL.greenDark,
|
||||
fontWeight: 700,
|
||||
textAlign: 'center',
|
||||
outline: 'none',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<div
|
||||
style={{
|
||||
marginBottom: '16px',
|
||||
padding: '10px 14px',
|
||||
backgroundColor: '#f0f8ff',
|
||||
border: `1px solid #4bacc6`,
|
||||
borderLeft: `4px solid #4bacc6`,
|
||||
}}
|
||||
>
|
||||
<p
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.8rem',
|
||||
color: REBEL.textDark,
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
{func.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Vehicle arrivals summary for this function */}
|
||||
<p
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
marginBottom: '8px',
|
||||
textTransform: 'uppercase',
|
||||
}}
|
||||
>
|
||||
Voertuigbewegingen per Week per Eenheid
|
||||
</p>
|
||||
<table
|
||||
style={{
|
||||
width: '100%',
|
||||
borderCollapse: 'collapse',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.75rem',
|
||||
}}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
padding: '6px 8px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.65rem',
|
||||
textTransform: 'uppercase',
|
||||
color: REBEL.textDark,
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Voertuigtype
|
||||
</th>
|
||||
{VEHICLES.map((v) => (
|
||||
<th
|
||||
key={v.id}
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '6px 6px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.6rem',
|
||||
textTransform: 'uppercase',
|
||||
color: REBEL.textDark,
|
||||
backgroundColor: REBEL.offWhite,
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{v.name.length > 15 ? v.name.substring(0, 12) + '...' : v.name}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(() => {
|
||||
// Find all delivery profiles for this function
|
||||
const profileKeys = Object.keys(
|
||||
(() => {
|
||||
const profiles: Record<string, typeof import('@/lib/model-data').DELIVERY_PROFILES[string]> = {};
|
||||
const { DELIVERY_PROFILES } = require('@/lib/model-data');
|
||||
for (const key of Object.keys(DELIVERY_PROFILES)) {
|
||||
if (key.startsWith(`${func.id}_`)) {
|
||||
profiles[key] = DELIVERY_PROFILES[key];
|
||||
}
|
||||
}
|
||||
return profiles;
|
||||
})()
|
||||
);
|
||||
|
||||
if (profileKeys.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={VEHICLES.length + 1}
|
||||
style={{
|
||||
padding: '12px 8px',
|
||||
textAlign: 'center',
|
||||
color: REBEL.tabInactive,
|
||||
}}
|
||||
>
|
||||
Geen beleveringsprofielen beschikbaar
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
// We need the import at the module level, using dynamic import instead
|
||||
const { DELIVERY_PROFILES, DISTRIBUTIONS } = require('@/lib/model-data');
|
||||
|
||||
return profileKeys.map((profileKey) => {
|
||||
const profile = DELIVERY_PROFILES[profileKey];
|
||||
const distId = profileKey.split('_')[1];
|
||||
const dist = DISTRIBUTIONS.find((d: { id: string }) => d.id === distId);
|
||||
const distName = dist ? dist.name : distId;
|
||||
|
||||
return (
|
||||
<tr key={profileKey}>
|
||||
<td
|
||||
style={{
|
||||
padding: '5px 8px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
fontWeight: 600,
|
||||
color: REBEL.textDark,
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{distName}
|
||||
</td>
|
||||
{VEHICLES.map((v, vi) => (
|
||||
<td
|
||||
key={v.id}
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '5px 6px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
color: profile.stopsPerWeekPerUnit[vi] > 0 ? REBEL.greenDark : REBEL.tabInactive,
|
||||
fontWeight: profile.stopsPerWeekPerUnit[vi] > 0 ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{profile.stopsPerWeekPerUnit[vi] > 0
|
||||
? profile.stopsPerWeekPerUnit[vi].toLocaleString('nl-NL', { maximumFractionDigits: 3 })
|
||||
: '-'}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
})()}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{/* Stop durations */}
|
||||
<p
|
||||
style={{
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 700,
|
||||
color: REBEL.textDark,
|
||||
marginTop: '16px',
|
||||
marginBottom: '8px',
|
||||
textTransform: 'uppercase',
|
||||
}}
|
||||
>
|
||||
Stopduur (minuten) per Voertuig
|
||||
</p>
|
||||
<table
|
||||
style={{
|
||||
width: '100%',
|
||||
borderCollapse: 'collapse',
|
||||
fontFamily: 'Calibri, Arial, sans-serif',
|
||||
fontSize: '0.75rem',
|
||||
}}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
padding: '6px 8px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.65rem',
|
||||
textTransform: 'uppercase',
|
||||
color: REBEL.textDark,
|
||||
backgroundColor: REBEL.offWhite,
|
||||
}}
|
||||
>
|
||||
Distributie
|
||||
</th>
|
||||
{VEHICLES.map((v) => (
|
||||
<th
|
||||
key={v.id}
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '6px 6px',
|
||||
borderBottom: `2px solid ${REBEL.coral}`,
|
||||
fontWeight: 700,
|
||||
fontSize: '0.6rem',
|
||||
textTransform: 'uppercase',
|
||||
color: REBEL.textDark,
|
||||
backgroundColor: REBEL.offWhite,
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{v.name.length > 15 ? v.name.substring(0, 12) + '...' : v.name}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(() => {
|
||||
const { DELIVERY_PROFILES, DISTRIBUTIONS } = require('@/lib/model-data');
|
||||
const profileKeys = Object.keys(DELIVERY_PROFILES).filter((k: string) =>
|
||||
k.startsWith(`${func.id}_`)
|
||||
);
|
||||
|
||||
return profileKeys.map((profileKey: string) => {
|
||||
const profile = DELIVERY_PROFILES[profileKey];
|
||||
const distId = profileKey.split('_')[1];
|
||||
const dist = DISTRIBUTIONS.find((d: { id: string }) => d.id === distId);
|
||||
const distName = dist ? dist.name : distId;
|
||||
|
||||
return (
|
||||
<tr key={profileKey}>
|
||||
<td
|
||||
style={{
|
||||
padding: '5px 8px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
fontWeight: 600,
|
||||
color: REBEL.textDark,
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{distName}
|
||||
</td>
|
||||
{VEHICLES.map((v, vi) => (
|
||||
<td
|
||||
key={v.id}
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '5px 6px',
|
||||
borderBottom: `1px solid ${REBEL.gridLine}`,
|
||||
color: profile.duration[vi] > 0 ? REBEL.textDark : REBEL.tabInactive,
|
||||
}}
|
||||
>
|
||||
{profile.duration[vi] > 0 ? profile.duration[vi] : '-'}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
})()}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
{selectedFunction && selectedFunction !== 'algemeen' && selectedFunction !== 'parameters' && (
|
||||
<ExcelPanel title={`Beleveringsprofiel: ${state.allFunctions.find((f) => f.id === selectedFunction)?.name ?? selectedFunction}`}>
|
||||
<DeliveryProfileEditor
|
||||
state={state}
|
||||
theme="rebel"
|
||||
functionId={selectedFunction}
|
||||
onBack={() => setSelectedFunction('algemeen')}
|
||||
/>
|
||||
</ExcelPanel>
|
||||
)}
|
||||
</div>
|
||||
@@ -2259,6 +2012,7 @@ export default function RebelExcelLayout({
|
||||
>
|
||||
{activeTab === 'cover' && renderCoverTab()}
|
||||
{activeTab === 'handleiding' && renderHandleidingTab()}
|
||||
{activeTab === 'casus' && renderCasusTab()}
|
||||
{activeTab === 'cockpit' && renderCockpitTab()}
|
||||
{activeTab === 'inputs' && renderInputsTab()}
|
||||
{activeTab === 'algemeen' && renderAlgemeenTab()}
|
||||
|
||||
@@ -5,13 +5,16 @@ import type { SimulationState, LayoutType } from '@/lib/use-simulation-state';
|
||||
import { VEHICLES, FUNCTIONS } from '@/lib/model-data';
|
||||
import { DMI, PERIOD_COLORS, FUNCTION_COLORS, CLUSTER_COLORS, CLUSTER_NAMES, SERVICE_LEVEL_OPTIONS, MAX_CLUSTERS, heading, bodyText, labelMono } from '@/lib/dmi-theme';
|
||||
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip as RechartsTooltip, ResponsiveContainer, Cell, PieChart, Pie, Legend } from 'recharts';
|
||||
import { Loader2, Play, LayoutDashboard, ClipboardList, Network, BarChart3, ChevronDown, ChevronUp, Info, BookOpen } from 'lucide-react';
|
||||
import { Loader2, Play, LayoutDashboard, ClipboardList, Network, BarChart3, ChevronDown, ChevronUp, Info, BookOpen, MapPin, RotateCcw, Settings } from 'lucide-react';
|
||||
import { Slider } from '@/components/ui/slider';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import LayoutSwitcher from '@/components/LayoutSwitcher';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_LOGOS } from '@/lib/content';
|
||||
import { COVER, HANDLEIDING_SECTIONS, PARTNER_SECTIONS, CONTACT, CASUS_GERARD_DOUSTRAAT } from '@/lib/content';
|
||||
import { HandleidingDiagram } from '@/components/HandleidingDiagrams';
|
||||
import { HandleidingTableRenderer } from '@/components/HandleidingTable';
|
||||
import { AlgemeenEditor, DeliveryProfileEditor } from '@/components/ParameterEditor';
|
||||
|
||||
type WebappTab = 'info' | 'dashboard' | 'invoer' | 'clustering' | 'resultaten';
|
||||
type WebappTab = 'cover' | 'handleiding' | 'casus' | 'dashboard' | 'invoer' | 'parameters' | 'clustering' | 'resultaten';
|
||||
|
||||
const TICK_STYLE = { fontFamily: 'var(--font-ibm-plex-sans), sans-serif', fill: DMI.darkGray } as const;
|
||||
const TICK_SM = { ...TICK_STYLE, fontSize: 10 } as const;
|
||||
@@ -83,6 +86,8 @@ export default function WebappLayout({
|
||||
onLayoutChange: (layout: LayoutType) => void;
|
||||
}) {
|
||||
const [activeTab, setActiveTab] = useState<WebappTab>('dashboard');
|
||||
const [extendedSim, setExtendedSim] = useState(false);
|
||||
const [paramView, setParamView] = useState<'algemeen' | string>('algemeen');
|
||||
|
||||
const activeFunctionCount = useMemo(() => {
|
||||
return Object.entries(state.functionCounts).filter(([, count]) => count > 0).length;
|
||||
@@ -133,9 +138,12 @@ export default function WebappLayout({
|
||||
}, [state.results]);
|
||||
|
||||
const tabs: { id: WebappTab; label: string; icon: React.ReactNode }[] = [
|
||||
{ id: 'info', label: 'Info', icon: <BookOpen size={18} /> },
|
||||
{ id: 'cover', label: 'Info', icon: <Info size={18} /> },
|
||||
{ id: 'handleiding', label: 'Handleiding', icon: <BookOpen size={18} /> },
|
||||
{ id: 'casus', label: 'Casus', icon: <MapPin size={18} /> },
|
||||
{ id: 'dashboard', label: 'Dashboard', icon: <LayoutDashboard size={18} /> },
|
||||
{ id: 'invoer', label: 'Invoer', icon: <ClipboardList size={18} /> },
|
||||
{ id: 'parameters', label: 'Parameters', icon: <Settings size={18} /> },
|
||||
{ id: 'clustering', label: 'Clustering', icon: <Network size={18} /> },
|
||||
{ id: 'resultaten', label: 'Resultaten', icon: <BarChart3 size={18} /> },
|
||||
];
|
||||
@@ -164,7 +172,7 @@ export default function WebappLayout({
|
||||
>
|
||||
{/* Left: Logo */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '16px', minWidth: '160px' }}>
|
||||
<Image src="/dmi-logo.png" alt="DMI" width={120} height={40} style={{ objectFit: 'contain' }} />
|
||||
<Image src="/dmi-logo.png" alt="DMI" width={200} height={64} style={{ objectFit: 'contain' }} />
|
||||
</div>
|
||||
|
||||
{/* Center: Tab buttons */}
|
||||
@@ -235,11 +243,10 @@ export default function WebappLayout({
|
||||
<main style={{ maxWidth: '1280px', margin: '0 auto', padding: '32px 24px 64px' }}>
|
||||
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* INFO TAB (Cover + Handleiding) */}
|
||||
{/* COVER TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{activeTab === 'info' && (
|
||||
{activeTab === 'cover' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '32px' }}>
|
||||
{/* Cover section */}
|
||||
<WCard>
|
||||
<div style={{ textAlign: 'center', padding: '24px 0' }}>
|
||||
<h1 style={{ ...heading, fontSize: '2rem', marginBottom: '12px' }}>
|
||||
@@ -269,46 +276,46 @@ export default function WebappLayout({
|
||||
{COVER.description}
|
||||
</p>
|
||||
|
||||
{/* Partner logos */}
|
||||
{/* Partner logos — grouped by role */}
|
||||
<div style={{ borderTop: `1px solid ${DMI.blueTint2}`, paddingTop: '24px' }}>
|
||||
<p style={{ ...labelMono, marginBottom: '16px' }}>Partners</p>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'center',
|
||||
gap: '28px',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{PARTNER_LOGOS.map((logo) => (
|
||||
<div
|
||||
key={logo.src}
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={90}
|
||||
height={45}
|
||||
style={{ objectFit: 'contain', maxHeight: '45px' }}
|
||||
/>
|
||||
<span style={{ ...bodyText, fontSize: '0.6rem', color: DMI.darkGray }}>
|
||||
{logo.organization}
|
||||
</span>
|
||||
{PARTNER_SECTIONS.map((section) => (
|
||||
<div key={section.label} style={{ marginBottom: '20px' }}>
|
||||
<p style={{ ...bodyText, fontSize: '0.72rem', fontStyle: 'italic', color: DMI.darkGray, marginBottom: '10px' }}>
|
||||
{section.label}
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: '28px', alignItems: 'center' }}>
|
||||
{section.logos.map((logo) => (
|
||||
<Image
|
||||
key={logo.src}
|
||||
src={logo.src}
|
||||
alt={logo.alt}
|
||||
width={100}
|
||||
height={45}
|
||||
style={{ objectFit: 'contain', maxHeight: '45px' }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div style={{ borderTop: `1px solid ${DMI.blueTint2}`, paddingTop: '12px', marginTop: '8px' }}>
|
||||
<p style={{ ...labelMono, marginBottom: '4px' }}>{CONTACT.label}</p>
|
||||
{CONTACT.lines.map((line) => (
|
||||
<p key={line} style={{ ...bodyText, fontSize: '0.72rem', color: DMI.darkGray, margin: 0, lineHeight: 1.6 }}>
|
||||
{line}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</WCard>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Handleiding sections */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* HANDLEIDING TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{activeTab === 'handleiding' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '32px' }}>
|
||||
<div>
|
||||
<h2 style={{ ...heading, fontSize: '1.4rem', marginBottom: '16px' }}>
|
||||
Handleiding
|
||||
@@ -329,6 +336,12 @@ export default function WebappLayout({
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.tables?.map((table, ti) => (
|
||||
<HandleidingTableRenderer key={ti} table={table} />
|
||||
))}
|
||||
{section.diagrams?.map((key) => (
|
||||
<HandleidingDiagram key={key} diagramKey={key} />
|
||||
))}
|
||||
</WCard>
|
||||
))}
|
||||
</div>
|
||||
@@ -336,6 +349,84 @@ export default function WebappLayout({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* CASUS TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{activeTab === 'casus' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '32px', maxWidth: '900px' }}>
|
||||
<div>
|
||||
<h1 style={{ ...heading, fontSize: '1.8rem', marginBottom: '8px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.title}
|
||||
</h1>
|
||||
<p style={{ ...bodyText, fontSize: '1rem', color: DMI.mediumBlue, marginBottom: '16px' }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.subtitle}
|
||||
</p>
|
||||
<p style={{ ...bodyText, fontSize: '0.95rem', lineHeight: 1.7, color: DMI.darkGray }}>
|
||||
{CASUS_GERARD_DOUSTRAAT.intro}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{CASUS_GERARD_DOUSTRAAT.sections.map((section, sIdx) => (
|
||||
<WCard key={sIdx} title={section.title}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
||||
{section.paragraphs.map((p, pIdx) => (
|
||||
<p key={pIdx} style={{ ...bodyText, fontSize: '0.9rem', lineHeight: 1.7, whiteSpace: 'pre-line', margin: 0 }}>
|
||||
{p}
|
||||
</p>
|
||||
))}
|
||||
{section.images && section.images.map((img, iIdx) => (
|
||||
<figure key={iIdx} style={{ margin: '16px 0 0 0' }}>
|
||||
<img
|
||||
src={img.src}
|
||||
alt={img.alt}
|
||||
style={{ width: '100%', borderRadius: '8px', border: `1px solid ${DMI.blueTint2}` }}
|
||||
/>
|
||||
{img.caption && (
|
||||
<figcaption style={{ ...bodyText, fontSize: '0.75rem', color: DMI.darkGray, marginTop: '8px', fontStyle: 'italic' }}>
|
||||
{img.caption}
|
||||
</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
</WCard>
|
||||
))}
|
||||
|
||||
<WCard title="Probeer het zelf">
|
||||
<p style={{ ...bodyText, fontSize: '0.9rem', lineHeight: 1.7, marginBottom: '16px' }}>
|
||||
Laad de invoerwaarden van de Gerard Doustraat casus in het model om de resultaten zelf te verkennen, of begin met een leeg model.
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
onClick={() => { state.resetToGerardDoustraat(); setActiveTab('invoer'); }}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: '8px',
|
||||
padding: '10px 20px', borderRadius: '8px', border: 'none',
|
||||
backgroundColor: DMI.darkBlue, color: DMI.white,
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontWeight: 600, fontSize: '0.9rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
<MapPin size={16} /> Laad Casus Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { state.resetToBlank(); setActiveTab('invoer'); }}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: '8px',
|
||||
padding: '10px 20px', borderRadius: '8px',
|
||||
border: `2px solid ${DMI.darkBlue}`, backgroundColor: 'transparent',
|
||||
color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontWeight: 600, fontSize: '0.9rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
<RotateCcw size={16} /> Begin met leeg model
|
||||
</button>
|
||||
</div>
|
||||
</WCard>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* DASHBOARD TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
@@ -372,6 +463,12 @@ export default function WebappLayout({
|
||||
unit="meter"
|
||||
accent={DMI.themeAreaDev}
|
||||
/>
|
||||
<KpiCard
|
||||
label="Benodigde Oppervlakte"
|
||||
value={state.results ? `${Math.round(state.results.totalSpaceM2 * 3 * 10) / 10}` : '--'}
|
||||
unit="m²"
|
||||
accent={DMI.themeLogistics}
|
||||
/>
|
||||
<KpiCard
|
||||
label="Actieve Clusters"
|
||||
value={clusterCount}
|
||||
@@ -511,14 +608,42 @@ export default function WebappLayout({
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{activeTab === 'invoer' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '32px' }}>
|
||||
<div>
|
||||
<h1 style={{ ...heading, fontSize: '1.5rem', marginBottom: '8px' }}>
|
||||
Inventarisatie Functies
|
||||
</h1>
|
||||
<p style={{ ...bodyText, fontSize: '0.9rem', maxWidth: '640px', lineHeight: 1.6 }}>
|
||||
Geef het aantal eenheden per functie op voor het plangebied. Deze aantallen
|
||||
bepalen het verwachte verkeer en de bijbehorende ruimtebehoefte.
|
||||
</p>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', flexWrap: 'wrap', gap: '16px' }}>
|
||||
<div>
|
||||
<h1 style={{ ...heading, fontSize: '1.5rem', marginBottom: '8px' }}>
|
||||
Inventarisatie Functies
|
||||
</h1>
|
||||
<p style={{ ...bodyText, fontSize: '0.9rem', maxWidth: '640px', lineHeight: 1.6 }}>
|
||||
Geef het aantal eenheden per functie op voor het plangebied. Deze aantallen
|
||||
bepalen het verwachte verkeer en de bijbehorende ruimtebehoefte.
|
||||
</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '8px', flexShrink: 0 }}>
|
||||
<button
|
||||
onClick={state.resetToGerardDoustraat}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: '6px',
|
||||
padding: '8px 14px', borderRadius: '6px', border: `1px solid ${DMI.blueTint1}`,
|
||||
backgroundColor: DMI.blueTint3, color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans), sans-serif',
|
||||
fontWeight: 500, fontSize: '0.8rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
<MapPin size={14} /> Gerard Doustraat
|
||||
</button>
|
||||
<button
|
||||
onClick={state.resetToBlank}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: '6px',
|
||||
padding: '8px 14px', borderRadius: '6px', border: `1px solid ${DMI.blueTint1}`,
|
||||
backgroundColor: DMI.blueTint3, color: DMI.darkBlue,
|
||||
fontFamily: 'var(--font-ibm-plex-sans), sans-serif',
|
||||
fontWeight: 500, fontSize: '0.8rem', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
<RotateCcw size={14} /> Leeg model
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Function inputs grid */}
|
||||
@@ -684,6 +809,59 @@ export default function WebappLayout({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* PARAMETERS TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{activeTab === 'parameters' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
||||
{paramView === 'algemeen' ? (
|
||||
<>
|
||||
<WCard title="Algemene Parameters">
|
||||
<AlgemeenEditor state={state} theme="webapp" />
|
||||
</WCard>
|
||||
<WCard title="Beleveringsprofielen">
|
||||
<p style={{ ...bodyText, fontSize: '0.85rem', marginBottom: '16px', color: DMI.darkGray }}>
|
||||
Selecteer een functie om het beleveringsprofiel te bewerken.
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
||||
{state.allFunctions.map((func) => (
|
||||
<button
|
||||
key={func.id}
|
||||
onClick={() => setParamView(func.id)}
|
||||
style={{
|
||||
padding: '6px 14px',
|
||||
backgroundColor: DMI.blueTint3,
|
||||
color: DMI.darkBlue,
|
||||
border: `1px solid ${DMI.blueTint2}`,
|
||||
borderRadius: '6px',
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontSize: '0.8rem',
|
||||
fontWeight: 500,
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.15s ease',
|
||||
}}
|
||||
onMouseEnter={(e) => { (e.currentTarget as HTMLButtonElement).style.backgroundColor = DMI.blueTint2; }}
|
||||
onMouseLeave={(e) => { (e.currentTarget as HTMLButtonElement).style.backgroundColor = DMI.blueTint3; }}
|
||||
>
|
||||
{func.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</WCard>
|
||||
</>
|
||||
) : (
|
||||
<WCard>
|
||||
<DeliveryProfileEditor
|
||||
state={state}
|
||||
theme="webapp"
|
||||
functionId={paramView}
|
||||
onBack={() => setParamView('algemeen')}
|
||||
/>
|
||||
</WCard>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ---------------------------------------------------------- */}
|
||||
{/* CLUSTERING TAB */}
|
||||
{/* ---------------------------------------------------------- */}
|
||||
@@ -902,7 +1080,7 @@ export default function WebappLayout({
|
||||
<WCard title="Simulatie Instellingen">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '32px', flexWrap: 'wrap' }}>
|
||||
<div style={{ flex: 1, minWidth: '300px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '8px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '8px' }}>
|
||||
<span style={{ ...labelMono }}>Aantal Simulaties</span>
|
||||
<span
|
||||
style={{
|
||||
@@ -912,20 +1090,40 @@ export default function WebappLayout({
|
||||
fontSize: '0.9rem',
|
||||
}}
|
||||
>
|
||||
{state.numSimulations}
|
||||
{state.numSimulations.toLocaleString('nl-NL')}
|
||||
</span>
|
||||
</div>
|
||||
<Slider
|
||||
min={100}
|
||||
max={5000}
|
||||
step={100}
|
||||
max={extendedSim ? 50000 : 5000}
|
||||
step={extendedSim ? 500 : 100}
|
||||
value={[state.numSimulations]}
|
||||
onValueChange={([val]) => state.setNumSimulations(val)}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: '4px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: '4px' }}>
|
||||
<span style={{ ...bodyText, fontSize: '0.7rem', color: DMI.darkGray }}>100</span>
|
||||
<span style={{ ...bodyText, fontSize: '0.7rem', color: DMI.darkGray }}>5000</span>
|
||||
<label
|
||||
style={{ display: 'flex', alignItems: 'center', gap: '6px', cursor: 'pointer', userSelect: 'none' }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={extendedSim}
|
||||
onChange={(e) => {
|
||||
setExtendedSim(e.target.checked);
|
||||
if (!e.target.checked && state.numSimulations > 5000) {
|
||||
state.setNumSimulations(5000);
|
||||
}
|
||||
}}
|
||||
style={{ accentColor: DMI.darkBlue }}
|
||||
/>
|
||||
<span style={{ ...bodyText, fontSize: '0.7rem', color: DMI.darkGray }}>
|
||||
Uitgebreid (max 50.000)
|
||||
</span>
|
||||
</label>
|
||||
<span style={{ ...bodyText, fontSize: '0.7rem', color: DMI.darkGray }}>
|
||||
{extendedSim ? '50.000' : '5.000'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -974,7 +1172,8 @@ export default function WebappLayout({
|
||||
<span style={{ fontSize: '1.2rem' }}>✓</span>
|
||||
<span style={{ ...bodyText, fontSize: '0.9rem', color: DMI.darkBlue }}>
|
||||
Simulatie voltooid. Totale benodigde ruimte:{' '}
|
||||
<strong>{Math.round(state.results.totalSpaceM2 * 10) / 10} meter</strong>
|
||||
<strong>{Math.round(state.results.totalSpaceM2 * 10) / 10} meter</strong>{' '}
|
||||
({Math.round(state.results.totalSpaceM2 * 3 * 10) / 10} m²)
|
||||
</span>
|
||||
<button
|
||||
onClick={() => setActiveTab('resultaten')}
|
||||
@@ -1049,11 +1248,17 @@ export default function WebappLayout({
|
||||
{/* KPI summary row */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: '20px' }}>
|
||||
<KpiCard
|
||||
label="Totale Ruimte"
|
||||
label="Totale Lengte"
|
||||
value={Math.round(state.results.totalSpaceM2 * 10) / 10}
|
||||
unit="meter"
|
||||
accent={DMI.darkBlue}
|
||||
/>
|
||||
<KpiCard
|
||||
label="Totale Oppervlakte"
|
||||
value={Math.round(state.results.totalSpaceM2 * 3 * 10) / 10}
|
||||
unit="m²"
|
||||
accent={DMI.themeLogistics}
|
||||
/>
|
||||
<KpiCard
|
||||
label="Voertuigen per Dag"
|
||||
value={state.computedTotalVehicles !== null ? Math.round(state.computedTotalVehicles) : 0}
|
||||
@@ -1592,34 +1797,66 @@ export default function WebappLayout({
|
||||
Som van alle clusters op hun respectievelijke service levels
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
padding: '16px 32px',
|
||||
borderRadius: '10px',
|
||||
backgroundColor: DMI.darkBlue,
|
||||
color: DMI.white,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', gap: '16px' }}>
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-mono), monospace',
|
||||
fontWeight: 700,
|
||||
fontSize: '2rem',
|
||||
lineHeight: 1,
|
||||
padding: '16px 32px',
|
||||
borderRadius: '10px',
|
||||
backgroundColor: DMI.darkBlue,
|
||||
color: DMI.white,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
{Math.round(state.results.totalSpaceM2 * 10) / 10}
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-mono), monospace',
|
||||
fontWeight: 700,
|
||||
fontSize: '2rem',
|
||||
lineHeight: 1,
|
||||
}}
|
||||
>
|
||||
{Math.round(state.results.totalSpaceM2 * 10) / 10}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontSize: '0.8rem',
|
||||
marginTop: '4px',
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
meter
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontSize: '0.8rem',
|
||||
marginTop: '4px',
|
||||
opacity: 0.8,
|
||||
padding: '16px 32px',
|
||||
borderRadius: '10px',
|
||||
backgroundColor: DMI.themeLogistics,
|
||||
color: DMI.darkBlue,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
meter
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-mono), monospace',
|
||||
fontWeight: 700,
|
||||
fontSize: '2rem',
|
||||
lineHeight: 1,
|
||||
}}
|
||||
>
|
||||
{Math.round(state.results.totalSpaceM2 * 3 * 10) / 10}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontFamily: 'var(--font-ibm-plex-sans-condensed), sans-serif',
|
||||
fontSize: '0.8rem',
|
||||
marginTop: '4px',
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
m²
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -464,6 +464,80 @@ export const DELIVERY_PROFILES: Record<string, DeliveryProfile> = {
|
||||
},
|
||||
};
|
||||
|
||||
// Capacity limits (matching Excel)
|
||||
export const MAX_FUNCTIONS = 15;
|
||||
export const MAX_VEHICLES = 7;
|
||||
export const MAX_DISTRIBUTIONS = 18;
|
||||
|
||||
// Default-value getters for reset capability
|
||||
export function getDefaultVehicleLengths(): Record<string, number> {
|
||||
const lengths: Record<string, number> = {};
|
||||
for (const v of VEHICLES) lengths[v.id] = v.length;
|
||||
return lengths;
|
||||
}
|
||||
|
||||
export function getDefaultDeliveryDays(): Record<string, number> {
|
||||
const days: Record<string, number> = {};
|
||||
for (const d of DISTRIBUTIONS) days[d.id] = d.deliveryDays;
|
||||
return days;
|
||||
}
|
||||
|
||||
export function getDefaultDeliveryProfiles(): Record<string, DeliveryProfile> {
|
||||
const result: Record<string, DeliveryProfile> = {};
|
||||
for (const [key, profile] of Object.entries(DELIVERY_PROFILES)) {
|
||||
result[key] = {
|
||||
stopsPerWeekPerUnit: [...profile.stopsPerWeekPerUnit],
|
||||
duration: [...profile.duration],
|
||||
periodDistribution: profile.periodDistribution.map((pd) => [...pd]),
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Profile metadata: description and remarks per F×D profile (extracted from xlsm BP sheets)
|
||||
export const PROFILE_METADATA: Record<string, { description: string; remarks: string }> = {
|
||||
'F1_D7': { description: 'Pakketleveringen aan woningen', remarks: 'Eén bestelwagen per afleveradres.' },
|
||||
'F1_D10': { description: 'Service & onderhoud aan woningen', remarks: 'Loodgieter, elektricien, etc.' },
|
||||
'F1_D13': { description: 'Thuisbezorging boodschappen', remarks: 'Online supermarkt bestellingen.' },
|
||||
'F1_D14': { description: 'Tweemans thuisbelevering', remarks: 'Grote items (meubels, witgoed).' },
|
||||
'F2_D10': { description: 'Service & onderhoud supermarkt', remarks: '' },
|
||||
'F2_D12': { description: 'Supermarktleveringen', remarks: 'Reguliere bevoorrading.' },
|
||||
'F3_D10': { description: 'Service & onderhoud retail food', remarks: '' },
|
||||
'F3_D11': { description: 'Specialisten retail food', remarks: 'Versproducten, bakkerij, etc.' },
|
||||
'F4_D8': { description: 'Retail keten bevoorrading', remarks: '' },
|
||||
'F4_D10': { description: 'Service & onderhoud retail keten', remarks: '' },
|
||||
'F5_D7': { description: 'Pakketleveringen retail onafh.', remarks: 'Profiel zonder actieve voertuigen.' },
|
||||
'F5_D9': { description: 'Retail onafhankelijk bevoorrading', remarks: '' },
|
||||
'F5_D10': { description: 'Service & onderhoud retail onafh.', remarks: '' },
|
||||
'F6_D6': { description: 'Horeca/groothandel restaurant high-end', remarks: '' },
|
||||
'F6_D10': { description: 'Service & onderhoud restaurant high-end', remarks: '' },
|
||||
'F6_D11': { description: 'Specialisten restaurant high-end', remarks: '' },
|
||||
'F7_D6': { description: 'Horeca/groothandel restaurant basis', remarks: '' },
|
||||
'F7_D10': { description: 'Service & onderhoud restaurant basis', remarks: '' },
|
||||
'F7_D11': { description: 'Specialisten restaurant basis', remarks: '' },
|
||||
'F8_D6': { description: 'Horeca/groothandel café', remarks: '' },
|
||||
'F8_D10': { description: 'Service & onderhoud café', remarks: '' },
|
||||
'F8_D11': { description: 'Specialisten café', remarks: 'Profiel zonder actieve voertuigen.' },
|
||||
'F9_D6': { description: 'Horeca/groothandel hotel', remarks: '' },
|
||||
'F9_D7': { description: 'Pakketleveringen hotel', remarks: '' },
|
||||
'F9_D10': { description: 'Service & onderhoud hotel', remarks: '' },
|
||||
'F9_D11': { description: 'Specialisten hotel', remarks: '' },
|
||||
'F10_D5': { description: 'Facilitair kantoor klein', remarks: '' },
|
||||
'F10_D7': { description: 'Pakketleveringen kantoor klein', remarks: '' },
|
||||
'F10_D10': { description: 'Service & onderhoud kantoor klein', remarks: '' },
|
||||
'F10_D11': { description: 'Specialisten kantoor klein', remarks: '' },
|
||||
'F11_D5': { description: 'Facilitair kantoor middel', remarks: '' },
|
||||
'F11_D6': { description: 'Horeca/groothandel kantoor middel', remarks: '' },
|
||||
'F11_D7': { description: 'Pakketleveringen kantoor middel', remarks: '' },
|
||||
'F11_D10': { description: 'Service & onderhoud kantoor middel', remarks: '' },
|
||||
'F11_D11': { description: 'Specialisten kantoor middel', remarks: '' },
|
||||
'F12_D5': { description: 'Facilitair kantoor groot', remarks: '' },
|
||||
'F12_D6': { description: 'Horeca/groothandel kantoor groot', remarks: '' },
|
||||
'F12_D7': { description: 'Pakketleveringen kantoor groot', remarks: '' },
|
||||
'F12_D10': { description: 'Service & onderhoud kantoor groot', remarks: '' },
|
||||
'F12_D11': { description: 'Specialisten kantoor groot', remarks: '' },
|
||||
};
|
||||
|
||||
// Default function counts (from the example scenario in the Excel)
|
||||
export const DEFAULT_FUNCTION_COUNTS: Record<string, number> = {
|
||||
F1: 362, // Woningen
|
||||
|
||||
+79
-17
@@ -34,6 +34,29 @@ import {
|
||||
type DeliveryProfile,
|
||||
} from './model-data';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Types for custom entries
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface VehicleDef {
|
||||
id: string;
|
||||
name: string;
|
||||
length: number;
|
||||
}
|
||||
|
||||
export interface FunctionDef {
|
||||
id: string;
|
||||
name: string;
|
||||
unit: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface DistributionDef {
|
||||
id: string;
|
||||
name: string;
|
||||
deliveryDays: number;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Types
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -47,6 +70,22 @@ export interface SimulationInput {
|
||||
clusterServiceLevels: Record<number, number>;
|
||||
/** Number of Monte Carlo iterations (default 1000) */
|
||||
numSimulations?: number;
|
||||
|
||||
// --- Advanced overrides ---
|
||||
/** Full list of vehicles (built-in + custom). If provided, replaces VEHICLES. */
|
||||
vehicles?: VehicleDef[];
|
||||
/** Full list of functions (built-in + custom). If provided, replaces FUNCTIONS. */
|
||||
functions?: FunctionDef[];
|
||||
/** Full list of distributions (built-in + custom). If provided, replaces DISTRIBUTIONS. */
|
||||
distributions?: DistributionDef[];
|
||||
/** Override vehicle lengths by vehicle ID */
|
||||
vehicleLengths?: Record<string, number>;
|
||||
/** Override delivery days by distribution ID */
|
||||
deliveryDays?: Record<string, number>;
|
||||
/** Override delivery profiles (merged with defaults) */
|
||||
deliveryProfiles?: Record<string, DeliveryProfile>;
|
||||
/** Override simulation interval in minutes */
|
||||
intervalMinutes?: number;
|
||||
}
|
||||
|
||||
export interface SimulationResult {
|
||||
@@ -105,7 +144,29 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
numSimulations = SIM_PARAMS.numSimulations,
|
||||
} = input;
|
||||
|
||||
const intervalMinutes = SIM_PARAMS.intervalMinutes;
|
||||
// --- Merge overrides with defaults ---
|
||||
const localVehicles: VehicleDef[] = (input.vehicles ?? VEHICLES).map((v) => ({
|
||||
id: v.id,
|
||||
name: v.name,
|
||||
length: input.vehicleLengths?.[v.id] ?? v.length,
|
||||
}));
|
||||
const localFunctions: FunctionDef[] = (input.functions ?? FUNCTIONS).map((f) => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
unit: f.unit,
|
||||
description: f.description,
|
||||
}));
|
||||
const localDistributions: DistributionDef[] = (input.distributions ?? DISTRIBUTIONS).map((d) => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
deliveryDays: input.deliveryDays?.[d.id] ?? d.deliveryDays,
|
||||
}));
|
||||
const localProfiles: Record<string, DeliveryProfile> = {
|
||||
...DELIVERY_PROFILES,
|
||||
...input.deliveryProfiles,
|
||||
};
|
||||
const intervalMinutes = input.intervalMinutes ?? SIM_PARAMS.intervalMinutes;
|
||||
const numVehicles = localVehicles.length;
|
||||
|
||||
// Total intervals in a day: sum of intervals per period
|
||||
// Each period has (periodHours * 60 / intervalMinutes) intervals
|
||||
@@ -128,21 +189,21 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
// For each vehicle index (0..5), collect all F×D combinations that produce
|
||||
// arrivals for that vehicle type.
|
||||
|
||||
const vehicleArrivalSpecs: ArrivalSpec[][] = VEHICLES.map(() => []);
|
||||
const vehicleArrivalSpecs: ArrivalSpec[][] = localVehicles.map(() => []);
|
||||
/** Deterministic expected arrivals per day per vehicle type */
|
||||
const expectedArrivalsPerDay: number[] = new Array(VEHICLES.length).fill(0);
|
||||
const expectedArrivalsPerDay: number[] = new Array(numVehicles).fill(0);
|
||||
|
||||
for (const func of FUNCTIONS) {
|
||||
for (const func of localFunctions) {
|
||||
const numUnits = functionCounts[func.id] ?? 0;
|
||||
if (numUnits === 0) continue;
|
||||
|
||||
for (const dist of DISTRIBUTIONS) {
|
||||
for (const dist of localDistributions) {
|
||||
const profileKey = `${func.id}_${dist.id}`;
|
||||
const profile: DeliveryProfile | undefined = DELIVERY_PROFILES[profileKey];
|
||||
const profile: DeliveryProfile | undefined = localProfiles[profileKey];
|
||||
if (!profile) continue;
|
||||
|
||||
for (let v = 0; v < VEHICLES.length; v++) {
|
||||
const stopsPerWeekPerUnit = profile.stopsPerWeekPerUnit[v];
|
||||
for (let v = 0; v < numVehicles; v++) {
|
||||
const stopsPerWeekPerUnit = profile.stopsPerWeekPerUnit[v] ?? 0;
|
||||
if (stopsPerWeekPerUnit === 0) continue;
|
||||
|
||||
const periodDist = profile.periodDistribution[v];
|
||||
@@ -188,16 +249,17 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// For each vehicle type, store the peak simultaneous vehicles per iteration.
|
||||
const peakPerIteration: number[][] = VEHICLES.map(() => new Array(numSimulations));
|
||||
const peakPerIteration: number[][] = localVehicles.map(() => new Array(numSimulations));
|
||||
|
||||
// Pre-compute cluster mapping and vehicle indices per cluster
|
||||
const clusterMap = new Map<number, { vehicleIds: string[], vehicleIndices: number[] }>();
|
||||
for (const veh of VEHICLES) {
|
||||
for (let vi = 0; vi < numVehicles; vi++) {
|
||||
const veh = localVehicles[vi];
|
||||
const cid = clusterAssignments[veh.id] ?? 1;
|
||||
if (!clusterMap.has(cid)) clusterMap.set(cid, { vehicleIds: [], vehicleIndices: [] });
|
||||
const cluster = clusterMap.get(cid)!;
|
||||
cluster.vehicleIds.push(veh.id);
|
||||
cluster.vehicleIndices.push(VEHICLES.indexOf(veh));
|
||||
cluster.vehicleIndices.push(vi);
|
||||
}
|
||||
|
||||
// Flat arrays for percentile computation (Excel-matching approach):
|
||||
@@ -213,9 +275,9 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
|
||||
for (let sim = 0; sim < numSimulations; sim++) {
|
||||
// Track present vehicles per type at each interval for cluster aggregation
|
||||
const vehiclePresentAtInterval: number[][] = VEHICLES.map(() => new Array(totalIntervals).fill(0));
|
||||
const vehiclePresentAtInterval: number[][] = localVehicles.map(() => new Array(totalIntervals).fill(0));
|
||||
|
||||
for (let v = 0; v < VEHICLES.length; v++) {
|
||||
for (let v = 0; v < numVehicles; v++) {
|
||||
const specs = vehicleArrivalSpecs[v];
|
||||
if (specs.length === 0) {
|
||||
peakPerIteration[v][sim] = 0;
|
||||
@@ -261,7 +323,7 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
let space = 0;
|
||||
let vehicles = 0;
|
||||
for (const vi of vehicleIndices) {
|
||||
space += vehiclePresentAtInterval[vi][t] * VEHICLES[vi].length;
|
||||
space += vehiclePresentAtInterval[vi][t] * localVehicles[vi].length;
|
||||
vehicles += vehiclePresentAtInterval[vi][t];
|
||||
}
|
||||
clusterPeriodSpace.get(clusterId)![period].push(space);
|
||||
@@ -269,8 +331,8 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
}
|
||||
|
||||
let overallSpace = 0;
|
||||
for (let v = 0; v < VEHICLES.length; v++) {
|
||||
overallSpace += vehiclePresentAtInterval[v][t] * VEHICLES[v].length;
|
||||
for (let v = 0; v < numVehicles; v++) {
|
||||
overallSpace += vehiclePresentAtInterval[v][t] * localVehicles[v].length;
|
||||
}
|
||||
overallPeriodSpace[period].push(overallSpace);
|
||||
}
|
||||
@@ -311,7 +373,7 @@ export function runSimulation(input: SimulationInput): SimulationResult {
|
||||
const serviceLevelsArray = Array.from(allServiceLevels).sort((a, b) => a - b);
|
||||
|
||||
// Build vehicle results
|
||||
const vehicleResults: SimulationResult['vehicleResults'] = VEHICLES.map((veh, v) => {
|
||||
const vehicleResults: SimulationResult['vehicleResults'] = localVehicles.map((veh, v) => {
|
||||
const clusterId = clusterAssignments[veh.id] ?? 1;
|
||||
const clusterSL = clusterServiceLevels[clusterId] ?? 0.95;
|
||||
|
||||
|
||||
@@ -4,12 +4,27 @@ import { useState, useCallback, useMemo } from 'react';
|
||||
import {
|
||||
VEHICLES,
|
||||
FUNCTIONS,
|
||||
DISTRIBUTIONS,
|
||||
DEFAULT_FUNCTION_COUNTS,
|
||||
DEFAULT_CLUSTERS,
|
||||
DEFAULT_CLUSTER_SERVICE_LEVELS,
|
||||
SIM_PARAMS,
|
||||
DELIVERY_PROFILES,
|
||||
MAX_FUNCTIONS,
|
||||
MAX_VEHICLES,
|
||||
MAX_DISTRIBUTIONS,
|
||||
getDefaultVehicleLengths,
|
||||
getDefaultDeliveryDays,
|
||||
getDefaultDeliveryProfiles,
|
||||
type DeliveryProfile,
|
||||
} from '@/lib/model-data';
|
||||
import { runSimulation, type SimulationResult } from '@/lib/simulation';
|
||||
import {
|
||||
runSimulation,
|
||||
type SimulationResult,
|
||||
type VehicleDef,
|
||||
type FunctionDef,
|
||||
type DistributionDef,
|
||||
} from '@/lib/simulation';
|
||||
|
||||
export type LayoutType = 'rebel' | 'dmi' | 'webapp';
|
||||
|
||||
@@ -30,6 +45,19 @@ export interface SimulationState {
|
||||
totalFunctions: number;
|
||||
computedTotalVehicles: number | null;
|
||||
|
||||
// Advanced parameter state
|
||||
vehicleLengths: Record<string, number>;
|
||||
deliveryDays: Record<string, number>;
|
||||
deliveryProfiles: Record<string, DeliveryProfile>;
|
||||
intervalMinutes: number;
|
||||
customFunctions: FunctionDef[];
|
||||
customVehicles: VehicleDef[];
|
||||
customDistributions: DistributionDef[];
|
||||
allFunctions: FunctionDef[];
|
||||
allVehicles: VehicleDef[];
|
||||
allDistributions: DistributionDef[];
|
||||
hasAdvancedOverrides: boolean;
|
||||
|
||||
// Handlers
|
||||
handleFunctionCountChange: (funcId: string, value: string) => void;
|
||||
handleClusterMatrixChange: (vehicleId: string, clusterId: number) => void;
|
||||
@@ -37,12 +65,41 @@ export interface SimulationState {
|
||||
handleRun: () => void;
|
||||
toggleCluster: (clusterId: number) => void;
|
||||
setNumSimulations: (n: number) => void;
|
||||
resetToBlank: () => void;
|
||||
resetToGerardDoustraat: () => void;
|
||||
|
||||
// Advanced parameter handlers
|
||||
handleVehicleLengthChange: (vehicleId: string, value: number) => void;
|
||||
handleDeliveryDaysChange: (distId: string, value: number) => void;
|
||||
handleIntervalMinutesChange: (value: number) => void;
|
||||
handleProfileFieldChange: (profileKey: string, field: 'stopsPerWeekPerUnit' | 'duration', vehicleIdx: number, value: number) => void;
|
||||
handleProfilePeriodDistChange: (profileKey: string, vehicleIdx: number, periodIdx: number, value: number) => void;
|
||||
handleResetAdvancedParams: () => void;
|
||||
handleAddFunction: () => void;
|
||||
handleAddVehicle: () => void;
|
||||
handleAddDistribution: () => void;
|
||||
handleCustomFunctionNameChange: (funcId: string, name: string) => void;
|
||||
handleCustomVehicleNameChange: (vehicleId: string, name: string) => void;
|
||||
handleCustomDistributionNameChange: (distId: string, name: string) => void;
|
||||
handleEnsureProfile: (profileKey: string, numVehicles: number) => void;
|
||||
}
|
||||
|
||||
function getUniqueClusterIds(assignments: Record<string, number>): number[] {
|
||||
return [...new Set(Object.values(assignments))].sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
function deepCloneProfiles(profiles: Record<string, DeliveryProfile>): Record<string, DeliveryProfile> {
|
||||
const result: Record<string, DeliveryProfile> = {};
|
||||
for (const [key, profile] of Object.entries(profiles)) {
|
||||
result[key] = {
|
||||
stopsPerWeekPerUnit: [...profile.stopsPerWeekPerUnit],
|
||||
duration: [...profile.duration],
|
||||
periodDistribution: profile.periodDistribution.map((pd) => [...pd]),
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function useSimulationState(): SimulationState {
|
||||
const [functionCounts, setFunctionCounts] = useState<Record<string, number>>(
|
||||
() => ({ ...DEFAULT_FUNCTION_COUNTS })
|
||||
@@ -58,6 +115,75 @@ export function useSimulationState(): SimulationState {
|
||||
const [results, setResults] = useState<SimulationResult | null>(null);
|
||||
const [expandedClusters, setExpandedClusters] = useState<Record<number, boolean>>({});
|
||||
|
||||
// Advanced parameter state
|
||||
const [vehicleLengths, setVehicleLengths] = useState<Record<string, number>>(getDefaultVehicleLengths);
|
||||
const [deliveryDays, setDeliveryDays] = useState<Record<string, number>>(getDefaultDeliveryDays);
|
||||
const [deliveryProfiles, setDeliveryProfiles] = useState<Record<string, DeliveryProfile>>(getDefaultDeliveryProfiles);
|
||||
const [intervalMinutes, setIntervalMinutes] = useState(SIM_PARAMS.intervalMinutes);
|
||||
const [customFunctions, setCustomFunctions] = useState<FunctionDef[]>([]);
|
||||
const [customVehicles, setCustomVehicles] = useState<VehicleDef[]>([]);
|
||||
const [customDistributions, setCustomDistributions] = useState<DistributionDef[]>([]);
|
||||
|
||||
// Merged lists
|
||||
const allFunctions: FunctionDef[] = useMemo(
|
||||
() => [
|
||||
...FUNCTIONS.map((f) => ({ id: f.id, name: f.name, unit: f.unit, description: f.description })),
|
||||
...customFunctions,
|
||||
],
|
||||
[customFunctions]
|
||||
);
|
||||
|
||||
const allVehicles: VehicleDef[] = useMemo(
|
||||
() => [
|
||||
...VEHICLES.map((v) => ({ id: v.id, name: v.name, length: vehicleLengths[v.id] ?? v.length })),
|
||||
...customVehicles.map((v) => ({ ...v, length: vehicleLengths[v.id] ?? v.length })),
|
||||
],
|
||||
[customVehicles, vehicleLengths]
|
||||
);
|
||||
|
||||
const allDistributions: DistributionDef[] = useMemo(
|
||||
() => [
|
||||
...DISTRIBUTIONS.map((d) => ({ id: d.id, name: d.name, deliveryDays: deliveryDays[d.id] ?? d.deliveryDays })),
|
||||
...customDistributions.map((d) => ({ ...d, deliveryDays: deliveryDays[d.id] ?? d.deliveryDays })),
|
||||
],
|
||||
[customDistributions, deliveryDays]
|
||||
);
|
||||
|
||||
// Check if any advanced parameters differ from defaults
|
||||
const hasAdvancedOverrides = useMemo(() => {
|
||||
if (intervalMinutes !== SIM_PARAMS.intervalMinutes) return true;
|
||||
if (customFunctions.length > 0 || customVehicles.length > 0 || customDistributions.length > 0) return true;
|
||||
const defLengths = getDefaultVehicleLengths();
|
||||
for (const [k, v] of Object.entries(vehicleLengths)) {
|
||||
if (defLengths[k] !== undefined && v !== defLengths[k]) return true;
|
||||
}
|
||||
const defDays = getDefaultDeliveryDays();
|
||||
for (const [k, v] of Object.entries(deliveryDays)) {
|
||||
if (defDays[k] !== undefined && v !== defDays[k]) return true;
|
||||
}
|
||||
const defProfiles = DELIVERY_PROFILES;
|
||||
for (const [key, profile] of Object.entries(deliveryProfiles)) {
|
||||
const def = defProfiles[key];
|
||||
if (!def) {
|
||||
// Custom profile that doesn't exist in defaults — check if it has any nonzero values
|
||||
const hasValues = profile.stopsPerWeekPerUnit.some((v) => v !== 0) ||
|
||||
profile.duration.some((v) => v !== 0);
|
||||
if (hasValues) return true;
|
||||
continue;
|
||||
}
|
||||
for (let i = 0; i < profile.stopsPerWeekPerUnit.length; i++) {
|
||||
if ((profile.stopsPerWeekPerUnit[i] ?? 0) !== (def.stopsPerWeekPerUnit[i] ?? 0)) return true;
|
||||
if ((profile.duration[i] ?? 0) !== (def.duration[i] ?? 0)) return true;
|
||||
}
|
||||
for (let i = 0; i < profile.periodDistribution.length; i++) {
|
||||
for (let j = 0; j < (profile.periodDistribution[i]?.length ?? 0); j++) {
|
||||
if ((profile.periodDistribution[i]?.[j] ?? 0) !== (def.periodDistribution[i]?.[j] ?? 0)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, [vehicleLengths, deliveryDays, deliveryProfiles, intervalMinutes, customFunctions, customVehicles, customDistributions]);
|
||||
|
||||
const clusterIds = useMemo(
|
||||
() => getUniqueClusterIds(clusterAssignments),
|
||||
[clusterAssignments]
|
||||
@@ -118,6 +244,13 @@ export function useSimulationState(): SimulationState {
|
||||
clusterAssignments,
|
||||
clusterServiceLevels,
|
||||
numSimulations,
|
||||
vehicles: allVehicles,
|
||||
functions: allFunctions,
|
||||
distributions: allDistributions,
|
||||
vehicleLengths,
|
||||
deliveryDays,
|
||||
deliveryProfiles,
|
||||
intervalMinutes,
|
||||
});
|
||||
setResults(result);
|
||||
} catch (err) {
|
||||
@@ -126,7 +259,7 @@ export function useSimulationState(): SimulationState {
|
||||
setIsRunning(false);
|
||||
}
|
||||
}, 50);
|
||||
}, [functionCounts, clusterAssignments, clusterServiceLevels, numSimulations]);
|
||||
}, [functionCounts, clusterAssignments, clusterServiceLevels, numSimulations, allVehicles, allFunctions, allDistributions, vehicleLengths, deliveryDays, deliveryProfiles, intervalMinutes]);
|
||||
|
||||
const toggleCluster = useCallback((clusterId: number) => {
|
||||
setExpandedClusters((prev) => ({
|
||||
@@ -135,6 +268,147 @@ export function useSimulationState(): SimulationState {
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const resetToBlank = useCallback(() => {
|
||||
const blank: Record<string, number> = {};
|
||||
for (const f of FUNCTIONS) blank[f.id] = 0;
|
||||
for (const cf of customFunctions) blank[cf.id] = 0;
|
||||
setFunctionCounts(blank);
|
||||
setClusterAssignments({ ...DEFAULT_CLUSTERS });
|
||||
setClusterServiceLevels({ ...DEFAULT_CLUSTER_SERVICE_LEVELS });
|
||||
setResults(null);
|
||||
}, [customFunctions]);
|
||||
|
||||
const resetToGerardDoustraat = useCallback(() => {
|
||||
setFunctionCounts({ ...DEFAULT_FUNCTION_COUNTS });
|
||||
setClusterAssignments({ ...DEFAULT_CLUSTERS });
|
||||
setClusterServiceLevels({ ...DEFAULT_CLUSTER_SERVICE_LEVELS });
|
||||
setResults(null);
|
||||
}, []);
|
||||
|
||||
// --- Advanced parameter handlers ---
|
||||
|
||||
const handleVehicleLengthChange = useCallback((vehicleId: string, value: number) => {
|
||||
setVehicleLengths((prev) => ({ ...prev, [vehicleId]: Math.max(0, value) }));
|
||||
}, []);
|
||||
|
||||
const handleDeliveryDaysChange = useCallback((distId: string, value: number) => {
|
||||
setDeliveryDays((prev) => ({ ...prev, [distId]: Math.max(1, Math.round(value)) }));
|
||||
}, []);
|
||||
|
||||
const handleIntervalMinutesChange = useCallback((value: number) => {
|
||||
setIntervalMinutes(Math.max(1, Math.min(60, Math.round(value))));
|
||||
}, []);
|
||||
|
||||
const handleProfileFieldChange = useCallback(
|
||||
(profileKey: string, field: 'stopsPerWeekPerUnit' | 'duration', vehicleIdx: number, value: number) => {
|
||||
setDeliveryProfiles((prev) => {
|
||||
const existing = prev[profileKey];
|
||||
if (!existing) return prev;
|
||||
const updated = {
|
||||
...existing,
|
||||
[field]: existing[field].map((v, i) => (i === vehicleIdx ? Math.max(0, value) : v)),
|
||||
};
|
||||
return { ...prev, [profileKey]: updated };
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleProfilePeriodDistChange = useCallback(
|
||||
(profileKey: string, vehicleIdx: number, periodIdx: number, value: number) => {
|
||||
setDeliveryProfiles((prev) => {
|
||||
const existing = prev[profileKey];
|
||||
if (!existing) return prev;
|
||||
const newPeriodDist = existing.periodDistribution.map((pd, vi) =>
|
||||
vi === vehicleIdx ? pd.map((v, pi) => (pi === periodIdx ? Math.max(0, value) : v)) : [...pd]
|
||||
);
|
||||
return {
|
||||
...prev,
|
||||
[profileKey]: { ...existing, periodDistribution: newPeriodDist },
|
||||
};
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleResetAdvancedParams = useCallback(() => {
|
||||
setVehicleLengths(getDefaultVehicleLengths());
|
||||
setDeliveryDays(getDefaultDeliveryDays());
|
||||
setDeliveryProfiles(getDefaultDeliveryProfiles());
|
||||
setIntervalMinutes(SIM_PARAMS.intervalMinutes);
|
||||
setCustomFunctions([]);
|
||||
setCustomVehicles([]);
|
||||
setCustomDistributions([]);
|
||||
}, []);
|
||||
|
||||
const handleAddFunction = useCallback(() => {
|
||||
setCustomFunctions((prev) => {
|
||||
const totalCount = FUNCTIONS.length + prev.length;
|
||||
if (totalCount >= MAX_FUNCTIONS) return prev;
|
||||
const nextId = `F${totalCount + 1}`;
|
||||
return [...prev, { id: nextId, name: '<<LEEG>>', unit: 'eenheden', description: '' }];
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleAddVehicle = useCallback(() => {
|
||||
setCustomVehicles((prev) => {
|
||||
const totalCount = VEHICLES.length + prev.length;
|
||||
if (totalCount >= MAX_VEHICLES) return prev;
|
||||
const nextId = `V${totalCount + 1}`;
|
||||
const newVeh: VehicleDef = { id: nextId, name: `Voertuig ${totalCount + 1}`, length: 0 };
|
||||
// Set default length for new vehicle
|
||||
setVehicleLengths((prevLengths) => ({ ...prevLengths, [nextId]: 0 }));
|
||||
// Set default cluster for new vehicle
|
||||
setClusterAssignments((prevClusters) => ({ ...prevClusters, [nextId]: 1 }));
|
||||
// Extend all existing delivery profiles with a zero entry for the new vehicle
|
||||
setDeliveryProfiles((prevProfiles) => {
|
||||
const updated = deepCloneProfiles(prevProfiles);
|
||||
for (const [key, profile] of Object.entries(updated)) {
|
||||
profile.stopsPerWeekPerUnit.push(0);
|
||||
profile.duration.push(0);
|
||||
profile.periodDistribution.push([0, 0, 0, 0]);
|
||||
}
|
||||
return updated;
|
||||
});
|
||||
return [...prev, newVeh];
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleAddDistribution = useCallback(() => {
|
||||
setCustomDistributions((prev) => {
|
||||
const totalCount = DISTRIBUTIONS.length + prev.length;
|
||||
if (totalCount >= MAX_DISTRIBUTIONS) return prev;
|
||||
const nextId = `D${totalCount + 1}`;
|
||||
return [...prev, { id: nextId, name: '<<LEEG>>', deliveryDays: 6 }];
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleCustomFunctionNameChange = useCallback((funcId: string, name: string) => {
|
||||
setCustomFunctions((prev) => prev.map((f) => (f.id === funcId ? { ...f, name } : f)));
|
||||
}, []);
|
||||
|
||||
const handleCustomVehicleNameChange = useCallback((vehicleId: string, name: string) => {
|
||||
setCustomVehicles((prev) => prev.map((v) => (v.id === vehicleId ? { ...v, name } : v)));
|
||||
}, []);
|
||||
|
||||
const handleCustomDistributionNameChange = useCallback((distId: string, name: string) => {
|
||||
setCustomDistributions((prev) => prev.map((d) => (d.id === distId ? { ...d, name } : d)));
|
||||
}, []);
|
||||
|
||||
const handleEnsureProfile = useCallback((profileKey: string, numVehicles: number) => {
|
||||
setDeliveryProfiles((prev) => {
|
||||
if (prev[profileKey]) return prev;
|
||||
return {
|
||||
...prev,
|
||||
[profileKey]: {
|
||||
stopsPerWeekPerUnit: new Array(numVehicles).fill(0),
|
||||
duration: new Array(numVehicles).fill(0),
|
||||
periodDistribution: Array.from({ length: numVehicles }, () => [0, 0, 0, 0]),
|
||||
},
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
|
||||
return {
|
||||
functionCounts,
|
||||
clusterAssignments,
|
||||
@@ -146,11 +420,37 @@ export function useSimulationState(): SimulationState {
|
||||
clusterIds,
|
||||
totalFunctions,
|
||||
computedTotalVehicles,
|
||||
vehicleLengths,
|
||||
deliveryDays,
|
||||
deliveryProfiles,
|
||||
intervalMinutes,
|
||||
customFunctions,
|
||||
customVehicles,
|
||||
customDistributions,
|
||||
allFunctions,
|
||||
allVehicles,
|
||||
allDistributions,
|
||||
hasAdvancedOverrides,
|
||||
handleFunctionCountChange,
|
||||
handleClusterMatrixChange,
|
||||
handleServiceLevelChange,
|
||||
handleRun,
|
||||
toggleCluster,
|
||||
setNumSimulations,
|
||||
resetToBlank,
|
||||
resetToGerardDoustraat,
|
||||
handleVehicleLengthChange,
|
||||
handleDeliveryDaysChange,
|
||||
handleIntervalMinutesChange,
|
||||
handleProfileFieldChange,
|
||||
handleProfilePeriodDistChange,
|
||||
handleResetAdvancedParams,
|
||||
handleAddFunction,
|
||||
handleAddVehicle,
|
||||
handleAddDistribution,
|
||||
handleCustomFunctionNameChange,
|
||||
handleCustomVehicleNameChange,
|
||||
handleCustomDistributionNameChange,
|
||||
handleEnsureProfile,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user