diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx index 8e2d4f1..9fb7b78 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx @@ -62,7 +62,7 @@ const BarChartInput = (props: Props) => { fetchSavedInputes(); - }, [selectedChartId.id]); + }, [selectedChartId]); // Sync Zustand state when component mounts useEffect(() => { @@ -138,7 +138,7 @@ const BarChartInput = (props: Props) => {
Title
- +
{[...Array(3)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -152,6 +152,7 @@ const BarChartInput = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx index af6f735..78b82c8 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx @@ -23,6 +23,10 @@ const FleetEfficiencyInputComponent = (props: Props) => { const organization = email?.split("@")[1]?.split(".")[0] const [isLoading, setLoading] = useState(true); + const isSelected = () => { + + } + useEffect(() => { const fetchZoneData = async () => { try { @@ -139,7 +143,7 @@ const FleetEfficiencyInputComponent = (props: Props) => {
Title
- +
{[...Array(1)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -153,6 +157,7 @@ const FleetEfficiencyInputComponent = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx index 53ddbcc..271b4fc 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx @@ -139,7 +139,7 @@ const FlotingWidgetInput = (props: Props) => {
Title
- +
{[...Array(6)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -153,6 +153,7 @@ const FlotingWidgetInput = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx index 3cf647e..50330d1 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx @@ -257,7 +257,7 @@ const LineGrapInput = (props: Props) => {
Title
- +
{[...Array(4)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -271,6 +271,7 @@ const LineGrapInput = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx index 1d16358..e7486f2 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx @@ -138,7 +138,7 @@ const PieChartInput = (props: Props) => {
Title
- +
{[...Array(2)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -152,6 +152,7 @@ const PieChartInput = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx index 5d9dd58..797f63a 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx @@ -132,7 +132,7 @@ const Progress1Input = (props: Props) => {
Title
- +
{[...Array(1)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -146,6 +146,7 @@ const Progress1Input = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx index bc6059c..a7d2934 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx @@ -132,7 +132,7 @@ const Progress2Input = (props: Props) => {
Title
- +
{[...Array(2)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -146,6 +146,7 @@ const Progress2Input = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx index 8d5e717..764be54 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx @@ -139,7 +139,7 @@ const WarehouseThroughputInputComponent = (props: Props) => {
Title
- +
{[...Array(1)].map((_, index) => { const inputKey = `input${index + 1}`; @@ -153,6 +153,7 @@ const WarehouseThroughputInputComponent = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx index a1b4360..345de09 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx @@ -151,6 +151,7 @@ const Widget2InputCard3D = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx index 43f8e55..c41447a 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx @@ -144,6 +144,7 @@ const Widget3InputCard3D = () => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx index 4aa9855..20369bd 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx @@ -151,6 +151,7 @@ const Widget4InputCard3D = (props: Props) => { onUnselect={() => handleSelect(inputKey, null)} selectedValue={selections[inputKey]} // Load from Zustand isLoading={isLoading} + allSelections={selections} />
diff --git a/app/src/components/ui/inputs/MultiLevelDropDown.tsx b/app/src/components/ui/inputs/MultiLevelDropDown.tsx index 1293e4a..fa30a55 100644 --- a/app/src/components/ui/inputs/MultiLevelDropDown.tsx +++ b/app/src/components/ui/inputs/MultiLevelDropDown.tsx @@ -1,145 +1,3 @@ -// import React, { useState, useRef, useEffect } from "react"; - -// // Dropdown Item Component -// const DropdownItem = ({ -// label, -// href, -// onClick, -// }: { -// label: string; -// href?: string; -// onClick?: () => void; -// }) => ( -// { -// e.preventDefault(); -// onClick?.(); -// }} -// > -// {label} -// -// ); - -// // Nested Dropdown Component -// const NestedDropdown = ({ -// label, -// children, -// onSelect, -// }: { -// label: string; -// children: React.ReactNode; -// onSelect: (selectedLabel: string) => void; -// }) => { -// const [open, setOpen] = useState(false); - -// return ( -//
-// {/* Dropdown Trigger */} -//
setOpen(!open)} // Toggle submenu on click -// > -// {label} {open ? "▼" : "▶"} -//
- -// {/* Submenu */} -// {open && ( -//
-// {React.Children.map(children, (child) => { -// if (React.isValidElement(child)) { -// // Clone the element and pass the `onSelect` prop only if it's expected -// return React.cloneElement(child as React.ReactElement, { onSelect }); -// } -// return child; // Return non-element children as-is -// })} -//
-// )} -//
-// ); -// }; - -// // Recursive Function to Render Nested Data -// const renderNestedData = ( -// data: Record, -// onSelect: (selectedLabel: string) => void -// ) => { -// return Object.entries(data).map(([key, value]) => { -// if (typeof value === "object" && !Array.isArray(value)) { -// // If the value is an object, render it as a nested dropdown -// return ( -// -// {renderNestedData(value, onSelect)} -// -// ); -// } else if (Array.isArray(value)) { -// // If the value is an array, render each item as a dropdown item -// return value.map((item, index) => ( -// onSelect(item)} /> -// )); -// } else { -// // If the value is a simple string, render it as a dropdown item -// return ( -// onSelect(value)} /> -// ); -// } -// }); -// }; - -// // Main Multi-Level Dropdown Component -// const MultiLevelDropdown = ({ data }: { data: Record }) => { -// const [open, setOpen] = useState(false); -// const [selectedLabel, setSelectedLabel] = useState("Dropdown trigger"); -// const dropdownRef = useRef(null); - -// // Handle outer click to close the dropdown -// useEffect(() => { -// const handleClickOutside = (event: MouseEvent) => { -// if ( -// dropdownRef.current && -// !dropdownRef.current.contains(event.target as Node) -// ) { -// setOpen(false); -// } -// }; - -// document.addEventListener("mousedown", handleClickOutside); -// return () => { -// document.removeEventListener("mousedown", handleClickOutside); -// }; -// }, []); - -// // Handle selection of an item -// const handleSelect = (selectedLabel: string) => { -// setSelectedLabel(selectedLabel); // Update the dropdown trigger text -// setOpen(false); // Close the dropdown -// }; - -// return ( -//
-// {/* Dropdown Trigger Button */} -// - -// {/* Dropdown Menu */} -// {open && ( -//
-//
-// {renderNestedData(data, handleSelect)} -//
-//
-// )} -//
-// ); -// }; - -// export default MultiLevelDropdown; - import React, { useState, useRef, useEffect } from "react"; import { ArrowIcon } from "../../icons/ExportCommonIcons"; @@ -147,11 +5,19 @@ import { ArrowIcon } from "../../icons/ExportCommonIcons"; const DropdownItem = ({ label, onClick, + disabled = false, }: { label: string; onClick: () => void; + disabled?: boolean; }) => ( -
+
{ + if (!disabled) onClick(); + }} + style={{ cursor: disabled ? "not-allowed": "default", opacity: disabled ? 0.5 : 1 }} + > {label}
); @@ -161,10 +27,12 @@ const NestedDropdown = ({ label, fields, onSelect, + disabledFields = [], }: { label: string; fields: string[]; onSelect: (selectedData: { name: string; fields: string }) => void; + disabledFields?: string[]; }) => { const [open, setOpen] = useState(false); @@ -184,13 +52,17 @@ const NestedDropdown = ({
{open && (
- {fields.map((field) => ( - onSelect({ name: label, fields: field })} - /> - ))} + {fields.map((field) => { + const isDisabled = disabledFields.includes(`${label}-${field}`); + return ( + onSelect({ name: label, fields: field })} + disabled={isDisabled} + /> + ); + })}
)}
@@ -203,6 +75,7 @@ interface MultiLevelDropdownProps { onSelect: (selectedData: { name: string; fields: string }) => void; onUnselect: () => void; selectedValue?: { name: string; fields: string }; + allSelections?: Record; isLoading?: boolean; } @@ -212,6 +85,7 @@ const MultiLevelDropdown = ({ onSelect, onUnselect, selectedValue, + allSelections = {}, isLoading = false, }: MultiLevelDropdownProps) => { const [open, setOpen] = useState(false); @@ -249,6 +123,14 @@ const MultiLevelDropdown = ({ ? `${selectedValue.name} - ${selectedValue.fields}` : "Dropdown trigger"; + // Build list of disabled selections + const disabledFieldsList = Object.values(allSelections) + .filter( + (sel) => + !(sel.name === selectedValue?.name && sel.fields === selectedValue?.fields) + ) + .map((sel) => `${sel.name}-${sel.fields}`); + return (