Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 273x 93x 93x 4x 8x 4x 8x 78x 50x 12x 50x 62x 12x 50x 62x 50x 50x 50x 2221x 185x 197x 36x 72x 72x 108x | import type { EconomicsStudyRead } from "@/api/apiStore.gen";
import { ScheduleModeEnum } from "@/api/apiStore.gen";
import { formatAmount } from "../shared/model/economicsFormatters";
import {
COMPOSITE_SCHEDULE_VALUE,
type ScheduleSelectValue,
schedulePreviewForStudy,
} from "./scheduleEditorModel";
export function SchedulePreviewSummary({
study,
selectedValue,
}: {
study: EconomicsStudyRead;
selectedValue: ScheduleSelectValue;
}) {
const preview = schedulePreviewForStudy(study);
if (!preview) {
return (
<div className="grid content-center gap-1 text-sm text-muted-foreground">
<span>Schedule details are not available.</span>
</div>
);
}
if (selectedValue === COMPOSITE_SCHEDULE_VALUE) {
const annualHours = formatAmount(preview.annual_operating_hours);
Iif (annualHours === "-") return null;
return (
<div className="flex items-end text-sm text-muted-foreground">
<span>
Annual hours{" "}
<span className="font-mono text-foreground">{annualHours}</span>
</span>
</div>
);
}
if (preview.mode !== ScheduleModeEnum.Scenario) {
return null;
}
if (!preview.compatible) {
return (
<div className="grid content-center gap-1 text-sm text-orange-700 dark:text-orange-300">
<span>{preview.message || "Select a solved production schedule."}</span>
</div>
);
}
return (
<div className="grid gap-2 text-sm md:grid-cols-3">
<SchedulePreviewMetric
label="Interval"
value={`${preview.interval_value ?? "-"} ${preview.interval_unit}`}
/>
<SchedulePreviewMetric
label="Schedule length"
value={`${formatAmount(preview.schedule_length_display_value)} ${
preview.schedule_length_display_unit
}`}
/>
<SchedulePreviewMetric
label="Operating cycles"
value={formatAmount(preview.operating_cycles, {
maximumFractionDigits: 2,
})}
/>
</div>
);
}
function SchedulePreviewMetric({
label,
value,
}: {
label: string;
value: string;
}) {
return (
<div className="rounded-md border bg-muted/20 px-3 py-2">
<div className="text-xs text-muted-foreground">{label}</div>
<div className="mt-0.5 font-mono text-sm">{value}</div>
</div>
);
}
|