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 | 42x 16x 17x 16x 16x 16x 17x 16x 16x 32x 32x 80x 48x 16x 16x 48x 48x 19x 48x | import { Button } from "@/ahuora-design-system/ui/button";
import { Label } from "@/ahuora-design-system/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/ahuora-design-system/ui/select";
import type { CostCurveTemplateRead } from "@/api/apiStore.gen";
import { driverSpecSummary } from "../model/driverSpecs";
export function TemplatePicker({
mode,
templateOptions,
selectedTemplate,
onTemplateChange,
onCopyTemplate,
}: {
mode: "create" | "edit";
templateOptions: readonly CostCurveTemplateRead[];
selectedTemplate?: CostCurveTemplateRead;
onTemplateChange: (value: string) => void;
onCopyTemplate: () => void;
}) {
Iif (mode !== "create" || templateOptions.length === 0) return null;
return (
<div className="grid gap-2 rounded-md border p-3 md:col-span-2">
<div className="grid gap-3 sm:grid-cols-[1fr_auto] sm:items-end">
<div className="grid gap-2">
<Label htmlFor={`curve-template-${mode}`}>
Default curve template
</Label>
<Select
value={selectedTemplate?.value ?? ""}
onValueChange={onTemplateChange}
>
<SelectTrigger id={`curve-template-${mode}`}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{templateOptions.map((template) => (
<SelectItem key={template.value} value={template.value}>
{template.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<Button
type="button"
variant="outline"
disabled={!selectedTemplate}
onClick={onCopyTemplate}
>
Copy template
</Button>
</div>
{selectedTemplate && (
<div className="text-xs text-muted-foreground">
{selectedTemplate.cost_basis} |{" "}
{driverSpecSummary(selectedTemplate.required_driver_specs)}
{" | "}
{selectedTemplate.source_reference}
</div>
)}
</div>
);
}
|