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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 273x 273x 31x 273x 304x 273x 31x 273x 273x 273x 273x 366x 55x 27x 273x 55x 328x 27x 273x 328x 1638x 52x 273x 429x 1092x | import { HelpCircle } from "lucide-react";
import { Button } from "@/ahuora-design-system/ui/button";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/ahuora-design-system/ui/select";
import { ToolTipCover } from "@/ahuora-design-system/ui/tooltip";
import type { ScheduleScenarioOption } from "@/api/apiStore.gen";
import { FieldLabel, FieldMeta } from "../shared/ui/EconomicsFormFields";
import {
COMPOSITE_SCHEDULE_VALUE,
type ScheduleSelectValue,
STEADY_SCHEDULE_HELP,
STEADY_SCHEDULE_VALUE,
} from "./scheduleEditorModel";
export function ScheduleModeSelect({
studyId,
value,
options,
canEdit,
loading,
saving,
error,
onValueChange,
}: {
studyId: number;
value: ScheduleSelectValue;
options: ScheduleScenarioOption[];
canEdit: boolean;
loading: boolean;
saving: boolean;
error: string;
onValueChange: (value: ScheduleSelectValue) => void;
}) {
const messageId = `economics-schedule-${studyId}-message`;
return (
<div className="space-y-2">
<FieldLabel
htmlFor={`economics-schedule-${studyId}`}
label="Costing schedule"
help="Select steady values, one solved production schedule, or a weekly composite schedule."
/>
<Select
value={value}
disabled={!canEdit || loading || saving}
onValueChange={onValueChange}
>
<SelectTrigger
id={`economics-schedule-${studyId}`}
aria-label="Costing schedule"
aria-invalid={Boolean(error)}
aria-describedby={error ? messageId : undefined}
className="min-w-0 [&>span]:min-w-0"
>
<SelectValue placeholder="Select schedule" />
</SelectTrigger>
<SelectContent>
<SelectItem
value={STEADY_SCHEDULE_VALUE}
inlineTrailing={
<ToolTipCover
asChild
content={STEADY_SCHEDULE_HELP}
delay={0}
side="right"
>
<Button
type="button"
variant="ghost"
size="xs"
className="text-muted-foreground hover:text-foreground"
aria-label="Steady state schedule help"
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
}}
>
<HelpCircle className="h-3.5 w-3.5" />
</Button>
</ToolTipCover>
}
>
Steady state
</SelectItem>
{options.map((option) => (
<SelectItem key={option.id} value={String(option.id)}>
{option.name}
</SelectItem>
))}
<SelectItem value={COMPOSITE_SCHEDULE_VALUE}>
Composite schedule
</SelectItem>
</SelectContent>
</Select>
<FieldMeta
id={messageId}
error={error}
errorTone="destructive"
defaultBadge={
saving ? "Saving" : loading ? "Loading schedules" : undefined
}
/>
</div>
);
}
|