All files / src/sections/PayBuilder RightSideHeaderPart.tsx

83.33% Statements 5/6
70% Branches 7/10
50% Functions 1/2
83.33% Lines 5/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 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                      12x                     531x 531x 531x   531x                                                                                  
import DotIcon from "@assets/icons/DotIcon";
import { Stack } from "@mui/material";
import { LinkSimpleIcon } from "@phosphor-icons/react";
import GiveButton from "@shared/Button/GiveButton";
import { useAppTheme } from "@theme/v2/Provider";
import { useState } from "react";
import PublicUrlShare from "./LaunchStep/PublicURLShare/PublicURLShare";
import TextWithIcon from "./TextWithIcon";
import { TFormSourceEnum } from "./components/products/types";
import useCheckFormType from "./components/hooks/useCheckFormType";
 
const RightSideHeaderPart = ({
  renderViewActions,
  shouldRenderShareButton,
  source = TFormSourceEnum.PREVIEW,
  isPublished,
}: {
  renderViewActions: () => JSX.Element[];
  shouldRenderShareButton: boolean;
  source?: TFormSourceEnum;
  isPublished: boolean;
}) => {
  const { palette } = useAppTheme();
  const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
  const { isInvoice } = useCheckFormType();
 
  return (
    <>
      <Stack gap="14px" flexDirection="row" alignItems="center">
        {!isInvoice && (
          <TextWithIcon
            Icon={<DotIcon isPublished={isPublished} />}
            text={isPublished ? "published" : "unpublished"}
            textSx={{
              color: palette.primitive?.neutral[60],
            }}
          />
        )}
        {source !== TFormSourceEnum.PUBLIC && renderViewActions()}
        {(shouldRenderShareButton || source === TFormSourceEnum.PUBLIC) && (
          <GiveButton
            label="Share"
            sx={{
              width: "fit-content",
              borderRadius: "8px",
              backgroundColor: palette.primitive?.transparent["darken-10"],
              border: "none",
              color: palette.primitive?.neutral[90],
              "&:hover": {
                color: palette.primitive?.neutral[0],
              },
            }}
            onClick={(e) => setAnchorEl(e.currentTarget)}
            endIcon={<LinkSimpleIcon stroke={palette.primitive?.neutral[90]} />}
          />
        )}
      </Stack>
      <PublicUrlShare
        variant="strict"
        anchorEl={anchorEl}
        setAnchorEl={setAnchorEl}
      />
    </>
  );
};
 
export default RightSideHeaderPart;