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 | 15x 15x 15x 15x 15x 15x 1x 15x 15x 10x | import { Badge } from "@/ahuora-design-system/ui/badge";
import { Button } from "@/ahuora-design-system/ui/button";
import { Separator } from "@/ahuora-design-system/ui/separator";
import {
api,
ScenarioRead,
useCoreOptimizationDegreesOfFreedomCreateMutation,
useCoreScenarioDestroyMutation,
useCoreScenarioPartialUpdateMutation,
} from "@/api/apiStore.gen";
import { useAppDispatch } from "@/store/hooks";
import { Plus } from "lucide-react";
import { DegreeOfFreedom } from "./DegreesOfFreedom";
import { ObjectiveSelector } from "./ObjectiveSelector";
import { Label } from "recharts";
import {
ToolTipCover,
TooltipProvider,
} from "@/ahuora-design-system/ui/tooltip";
export function OptimisationCheck({
optimization,
}: {
optimization: ScenarioRead;
}) {
const [deleteOptimization] = useCoreScenarioDestroyMutation();
const [updateOptimization] = useCoreScenarioPartialUpdateMutation();
const [createDegreeOfFreedom] =
useCoreOptimizationDegreesOfFreedomCreateMutation();
const dispatch = useAppDispatch();
const handleEnableOptimization = () => {
updateOptimization({
id: optimization.id,
patchedScenario: {
enable_optimization: !optimization.enable_optimization,
},
});
};
const addDegreesOfFreedom = () => {
createDegreeOfFreedom({
optimizationDegreesOfFreedom: { scenario: optimization.id },
});
};
const sortedDegreesOfFreedom =
optimization.degreesOfFreedom?.slice().sort((a, b) => b.id - a.id) || [];
return (
<>
<ObjectiveSelector optimization={optimization} />
<Separator />
<div className="flex flex-row items-center gap-4 py-2">
<p className="text-s">Optimisation Variables and Constraints: </p>
<ToolTipCover
content="Add a new variable and constraint"
variant="default"
>
<Button
onClick={addDegreesOfFreedom}
variant="outline"
className="my-1 flex items-center "
>
<Plus className="icon-small" strokeWidth={3} aria-label="Add" />
</Button>
</ToolTipCover>
</div>
<div className="flex flex-col gap-2 ">
{sortedDegreesOfFreedom.map((degreeOfFreedom) => (
<DegreeOfFreedom
key={degreeOfFreedom.id}
degreeOfFreedom={degreeOfFreedom}
optimization={optimization}
/>
))}
</div>
</>
);
}
|