diff --git a/src/components/filters/FaultTreeFilters.tsx b/src/components/filters/FaultTreeFilters.tsx deleted file mode 100644 index dd68c9a3..00000000 --- a/src/components/filters/FaultTreeFilters.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React, { FC, useState } from "react"; -import { Box, TextField, Button } from "@mui/material"; - -interface FaultTreeFiltersProps { - onFilterChange: (label: string, snsLabel: string) => void; -} - -const FaultTreeFilters: FC = ({ onFilterChange }) => { - const [label, setLabel] = useState(""); - const [snsLabel, setSnsLabel] = useState(""); - - const handleFilterChange = () => { - onFilterChange(label, snsLabel); - }; - - return ( - - setLabel(e.target.value)} - variant="outlined" - style={{ marginRight: 8 }} - /> - setSnsLabel(e.target.value)} - variant="outlined" - style={{ marginRight: 8 }} - /> - - - ); -}; - -export default FaultTreeFilters; diff --git a/src/components/table/FaultTreeAndSystemOverviewTable.tsx b/src/components/table/FaultTreeAndSystemOverviewTable.tsx index faef5bae..19646963 100644 --- a/src/components/table/FaultTreeAndSystemOverviewTable.tsx +++ b/src/components/table/FaultTreeAndSystemOverviewTable.tsx @@ -19,7 +19,6 @@ import { useSelectedSystemSummaries } from "@hooks/useSelectedSystemSummaries"; import { getFilteredFaultTreesBySystem, getReorderedSystemsListbySystem } from "@utils/utils"; import FaultTreeTableBody from "./FaultTreeTableBody"; import SystemTableBody from "./SystemTableBody"; -import FaultTreeFilters from "@components/filters/FaultTreeFilters"; import FaultTreeTableHead from "./FaultTreeTableHead"; import SystemTableHead from "./SystemTableHead"; @@ -51,6 +50,8 @@ const FaultTreeAndSystemOverviewTable: FC = ({ const [filterAnchorEl, setFilterAnchorEl] = useState(null); const [filterType, setFilterType] = useState(null); const [filterValues, setFilterValues] = useState({ label: "", snsLabel: "" }); + const [appliedFilters, setAppliedFilters] = useState({ label: "", snsLabel: "" }); + const initialSortConfig: { key: string; direction: "asc" | "desc" } = { key: "date", direction: "desc" }; const modifiedSystemsList = getReorderedSystemsListbySystem(systems, selectedSystemState); @@ -67,6 +68,7 @@ const FaultTreeAndSystemOverviewTable: FC = ({ }; const applyFilters = () => { + setAppliedFilters(filterValues); // Apply the filters handleFilterChange(filterValues.label, filterValues.snsLabel); handleFilterClose(); }; @@ -81,6 +83,7 @@ const FaultTreeAndSystemOverviewTable: FC = ({ sortConfig={sortConfig || initialSortConfig} onSortChange={handleSortChange} onFilterClick={handleFilterClick} + filterValues={appliedFilters} // Pass applied filters /> )} {systems && } @@ -126,7 +129,7 @@ const FaultTreeAndSystemOverviewTable: FC = ({ horizontal: "center", }} > - + {filterType === "label" && ( void; onFilterClick: (event: React.MouseEvent, type: string) => void; + filterValues: { label: string; snsLabel: string }; } -const FaultTreeTableHead: FC = ({ sortConfig, onSortChange, onFilterClick }) => { +const FaultTreeTableHead: FC = ({ sortConfig, onSortChange, onFilterClick, filterValues }) => { return ( @@ -15,6 +17,7 @@ const FaultTreeTableHead: FC = ({ sortConfig, onSortCha onFilterClick(e, "label")} style={{ cursor: "pointer", marginRight: "8px" }}> FHA Label + {filterValues.label && } = ({ sortConfig, onSortCha onFilterClick(e, "snsLabel")} style={{ cursor: "pointer", marginRight: "8px" }}> SNS Label + {filterValues.snsLabel && }