All files / src/features/ChangeLog/hooks useChangelogFilterState.tsx

100% Statements 7/7
100% Branches 4/4
75% Functions 3/4
100% Lines 6/6

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          117x       435x 435x   435x   4x                                       435x            
import { useState } from "react";
import { useAppTheme } from "@theme/v2/Provider";
import { FunnelSimpleIcon } from "@phosphor-icons/react";
import { CustomHeaderRightIcon } from "@features/GiveConversation/types";
 
export const useChangelogFilterState = (
  isFiltersApplied?: boolean,
  hideFilters?: boolean,
) => {
  const [filterOpen, setFilterOpen] = useState(false);
  const { palette } = useAppTheme();
 
  const filterIcon: CustomHeaderRightIcon = {
    Icons: FunnelSimpleIcon,
    handleClick: hideFilters ? () => {} : () => setFilterOpen((prev) => !prev),
    disabled: hideFilters,
    sx: {
      ...(isFiltersApplied && {
        position: "relative",
        "&::after": {
          content: '""',
          position: "absolute",
          top: "5px",
          right: "0px",
          width: "7px",
          height: "7px",
          borderRadius: "50%",
          backgroundColor: palette?.primitive?.blue?.[50],
        },
      }),
    },
    dataTestId: "changelog-filter-button",
  };
 
  return {
    filterOpen,
    setFilterOpen,
    filterIcon,
  };
};