Update day schedule and simulation chart labels, enhance defaults

This commit is contained in:
2025-12-04 02:03:37 +00:00
parent d64b9eabfa
commit 6b9d8cdf49
6 changed files with 36 additions and 5 deletions

View File

@@ -113,6 +113,7 @@ const MedPlanAssistant = () => {
displayedDays={displayedDays} displayedDays={displayedDays}
yAxisMin={yAxisMin} yAxisMin={yAxisMin}
yAxisMax={yAxisMax} yAxisMax={yAxisMax}
days={days}
t={t} t={t}
/> />
</div> </div>

View File

@@ -107,7 +107,7 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
)} )}
</Button> </Button>
<CardTitle className="text-lg"> <CardTitle className="text-lg">
{day.isTemplate ? t('regularPlan') : t('deviatingPlan')} {day.isTemplate ? t('regularPlan') : t('alternativePlan')}
</CardTitle> </CardTitle>
<Badge variant="secondary" className="text-xs"> <Badge variant="secondary" className="text-xs">
{t('day')} {dayIndex + 1} {t('day')} {dayIndex + 1}

View File

@@ -46,6 +46,7 @@ const SimulationChart = ({
displayedDays, displayedDays,
yAxisMin, yAxisMin,
yAxisMax, yAxisMax,
days,
t t
}: any) => { }: any) => {
const totalHours = (parseInt(simulationDays, 10) || 3) * 24; const totalHours = (parseInt(simulationDays, 10) || 3) * 24;
@@ -113,6 +114,28 @@ const SimulationChart = ({
return deviatingDays; return deviatingDays;
}, [combinedProfile, templateProfile, simulationDays]); }, [combinedProfile, templateProfile, simulationDays]);
// Determine label for each day's reference line
const getDayLabel = React.useCallback((dayNumber: number) => {
if (dayNumber === 1) return t('refLineRegularPlan');
// Check if this day has an actual schedule entry (not auto-filled)
const hasSchedule = days && days.length >= dayNumber;
// Check if this day deviates from template
const hasDeviation = daysWithDeviations.has(dayNumber);
if (!hasDeviation) {
// Matches template
return t('refLineNoDeviation');
} else if (!hasSchedule) {
// Deviates but no schedule = recovering
return t('refLineRecovering');
} else {
// Has deviation and has schedule = actual irregular intake
return t('refLineIrregularIntake');
}
}, [days, daysWithDeviations, t]);
// Merge all profiles into a single dataset for proper tooltip synchronization // Merge all profiles into a single dataset for proper tooltip synchronization
const mergedData = React.useMemo(() => { const mergedData = React.useMemo(() => {
const dataMap = new Map(); const dataMap = new Map();
@@ -358,9 +381,8 @@ const SimulationChart = ({
<ReferenceLine <ReferenceLine
key={`day-${day+1}`} key={`day-${day+1}`}
x={24 * (day+1)} x={24 * (day+1)}
// TODO instead of refLineDeviatingPlan show refLineRegularPlan in case there are no deviations (primary curve for the given day matches the template)
label={{ label={{
value: (day === 0 ? t('refLineRegularPlan') : t('refLineDeviatingPlan')) + ' (' + t('refLineDayX', { x: day+1 }) + ')', value: t('refLineDayX', { x: day+1 }) + '' + getDayLabel(day + 1),
position: 'insideTopRight', position: 'insideTopRight',
style: { style: {
fontSize: '0.75rem', fontSize: '0.75rem',

View File

@@ -104,7 +104,7 @@ export const getDefaultState = (): AppState => ({
chartView: 'damph', chartView: 'damph',
yAxisMin: '8', yAxisMin: '8',
yAxisMax: '13', yAxisMax: '13',
simulationDays: '4', simulationDays: '5',
displayedDays: '3', displayedDays: '5',
} }
}); });

View File

@@ -45,6 +45,9 @@ export const de = {
tickNoon: "Mittag", tickNoon: "Mittag",
refLineRegularPlan: "Regulärer Plan", refLineRegularPlan: "Regulärer Plan",
refLineDeviatingPlan: "Abweichung vom Plan", refLineDeviatingPlan: "Abweichung vom Plan",
refLineNoDeviation: "Keine Abweichung",
refLineRecovering: "Erholung",
refLineIrregularIntake: "Irreguläre Einnahme",
refLineDayX: "Tag {{x}}", refLineDayX: "Tag {{x}}",
refLineMin: "Min", refLineMin: "Min",
refLineMax: "Max", refLineMax: "Max",
@@ -98,6 +101,7 @@ export const de = {
// Day-based schedule // Day-based schedule
regularPlan: "Regulärer Plan", regularPlan: "Regulärer Plan",
deviatingPlan: "Abweichung vom Plan", deviatingPlan: "Abweichung vom Plan",
alternativePlan: "Alternativer Plan",
regularPlanOverlay: "Regulär", regularPlanOverlay: "Regulär",
dayNumber: "Tag {{number}}", dayNumber: "Tag {{number}}",
cloneDay: "Tag klonen", cloneDay: "Tag klonen",

View File

@@ -45,6 +45,9 @@ export const en = {
tickNoon: "Noon", tickNoon: "Noon",
refLineRegularPlan: "Regular Plan", refLineRegularPlan: "Regular Plan",
refLineDeviatingPlan: "Deviation from Plan", refLineDeviatingPlan: "Deviation from Plan",
refLineNoDeviation: "No Deviation",
refLineRecovering: "Recovering",
refLineIrregularIntake: "Irregular Intake",
refLineDayX: "Day {{x}}", refLineDayX: "Day {{x}}",
refLineMin: "Min", refLineMin: "Min",
refLineMax: "Max", refLineMax: "Max",
@@ -107,6 +110,7 @@ export const en = {
// Day-based schedule // Day-based schedule
regularPlan: "Regular Plan", regularPlan: "Regular Plan",
deviatingPlan: "Deviation from Plan", deviatingPlan: "Deviation from Plan",
alternativePlan: "Alternative Plan",
regularPlanOverlay: "Regular", regularPlanOverlay: "Regular",
dayNumber: "Day {{number}}", dayNumber: "Day {{number}}",
cloneDay: "Clone day", cloneDay: "Clone day",