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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | 33x 54x 54x 54x 1x 1x 54x 1x 1x 1x 1x 1x 1x 1x 54x 54x | import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/ahuora-design-system/ui/alert-dialog";
import { Button } from "@/ahuora-design-system/ui/button";
import { Separator } from "@/ahuora-design-system/ui/separator";
import {
useGraphicsgroupingsPartialUpdateMutation
} from "@/api/apiStore.gen";
import {
useCurrentGroup,
useCurrentObjectId,
useSelectedGroup
} from "@/hooks/flowsheetObjects";
import { toast } from "sonner";
import { CustomProperties } from "../LeftSideBar/Formulas/CustomProperties";
import { GroupPropertyListDisplay } from "./GroupPropertyListDisplay";
import { SelectedPropertyInfo } from "./ObjectDetailsPanel";
import { DataPanel } from "./components/DataPanel";
import { PropertySelectionSummary } from "./components/PropertySelectionSummary";
export const GroupProperties = ({ tempSelectedProperties, setTempSelectedProperties,
view,
setView,
isDialogOpen,
setIsDialogOpen,
}: {
tempSelectedProperties: SelectedPropertyInfo[],
setTempSelectedProperties: (props: SelectedPropertyInfo[]) => void,
view: "selection" | "summary",
setView: (view: "selection" | "summary") => void,
isDialogOpen: boolean,
setIsDialogOpen: (isOpen: boolean) => void,
}) => {
const [updateGrouping] = useGraphicsgroupingsPartialUpdateMutation();
const grouping = useSelectedGroup();
const handleOK = () => {
Iif (tempSelectedProperties?.length === 0) {
toast.warning("No properties selected!");
return;
}
setView("summary");
};
const handleSave = async () => {
try {
Iif (!grouping?.id) {
return;
}
// Use the correct hook name
const result = await updateGrouping({
id: grouping.id,
patchedGrouping: {
propertyInfos: tempSelectedProperties?.map((p) => p.propertyId),
},
}).unwrap();
setIsDialogOpen(false);
setView("selection");
toast.success("Properties saved successfully");
} catch (error: unknown) {
toast.error("Failed to save properties");
}
};
const handleCancel = () => {
setIsDialogOpen(false);
setView("selection");
};
// add a lot of padding to the bottom so the autocomplete for epxressions is not cut off.
return <div className="px-5 w-full flex flex-col min-h-full pb-[300px]">
<GroupPropertyListDisplay grouping={grouping} />
<Separator className="my-2" />
<CustomProperties />
<AlertDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<AlertDialogContent className="max-w-3xl lg:h-[55vh] md:h-[55vh] sm:h-[30vh]">
<AlertDialogHeader>
<AlertDialogTitle>
{view === "selection"
? "Select Properties"
: "Selected Properties"}
</AlertDialogTitle>
<AlertDialogDescription className="">
{view === "selection"
? "Choose which properties you want to observe for this module."
: "Review your selected properties."}
</AlertDialogDescription>
</AlertDialogHeader>
<div className="">
{view === "selection" ? (
<>
<div className="flex flex-col lg:gap-2 ">
<div className="lg:h-[55vh] md:h-[55vh] sm:h-[30vh]">
<DataPanel
setSelectedProperties={setTempSelectedProperties}
selectedProperties={tempSelectedProperties}
/>
</div>
<AlertDialogFooter className="flex justify-end space-x-4">
<Button variant="secondary" onClick={handleCancel}>
Cancel
</Button>
<Button onClick={handleOK}>Next</Button>
</AlertDialogFooter>
</div>
</>
) : (
<PropertySelectionSummary
selectedProperties={tempSelectedProperties}
onSave={handleSave}
onCancel={() => {
setView("selection");
}}
/>
)}
</div>
</AlertDialogContent>
</AlertDialog>
</div>
} |