All files / src/features/Minibuilders/Conversations/Modal/Sections ConversationsModalSubHeader.tsx

80% Statements 8/10
50% Branches 8/16
50% Functions 1/2
88.88% Lines 8/9

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                  21x                     11x 11x 11x 11x   11x       11x   11x                                              
import { Switch_V2 } from "@common/Switch";
import { Text } from "@common/Text";
import { Skeleton, Stack } from "@mui/material";
import { useAppDispatch, useAppSelector } from "@redux/hooks";
import { selectUser } from "@redux/slices/auth/auth";
import { setConversationsFilter } from "@redux/slices/conversations";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import { ChangeEvent } from "react";
 
const ConversationsModalSubHeader = ({
  filterString,
  isDataEmpty,
  isFetching,
  queryString,
}: {
  isFetching: boolean;
  isDataEmpty: boolean;
  filterString: string;
  queryString: string;
}) => {
  const dispatch = useAppDispatch();
  const { globalName, userAccID } = useAppSelector(selectUser);
  const { isMobileView } = useCustomTheme();
  const builder = `@[__${globalName.firstName} ${globalName.lastName}__](user:__${userAccID}__)`;
 
  const handleCheck = (e: ChangeEvent<HTMLInputElement>, c: boolean) => {
    dispatch(setConversationsFilter(c ? `${builder}` : ""));
  };
 
  Iif (queryString && !filterString && isDataEmpty && !isFetching) return <></>;
 
  return (
    <Stack
      justifyContent={isMobileView ? "flex-end" : "flex-start"}
      direction="row"
      alignItems="center"
      mb={isMobileView ? "18px" : 0}
      gap={1}
    >
      {isFetching && queryString ? (
        <Skeleton variant="rectangular" width={100} height={12} />
      ) : (
        <>
          <Text fontSize="14px" color="#575353">
            @Mentions
          </Text>
          <Switch_V2 size="small" onChange={handleCheck} />
        </>
      )}
    </Stack>
  );
};
 
export default ConversationsModalSubHeader;