All files / src/containers NotAuthorizedWrapper.tsx

75% Statements 15/20
50% Branches 1/2
50% Functions 4/8
78.94% Lines 15/19

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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147                      499x 314x   314x 46x 46x       314x       314x       499x   2994x                           499x                       499x                                                             499x                                         499x                           499x                         499x                      
import { useEffect } from "react";
import { useAppDispatch } from "@redux/hooks";
import { updatePermissions } from "@redux/slices/app";
import { RectShape } from "react-placeholder/lib/placeholders";
import ReactPlaceholder from "react-placeholder/lib";
import { BACKGROUND_VIDEO_PRIMARY } from "@constants/constants";
import { CustomBackgroundVideo } from "@components/Product/NewProductBanner/NewProductBanner";
import { Grid, styled } from "@mui/material";
import { MissingPermissionContent } from "features/Permissions/PopUp/MissingPermissionContent";
import { palette } from "@palette";
 
export const NotAuthorizedWrapper = ({ children, notAuthorized }: any) => {
  const dispatch = useAppDispatch();
 
  useEffect(() => {
    return () => {
      dispatch(updatePermissions({ reset: true }));
    };
  }, []);
 
  Iif (notAuthorized) {
    return <NotAuthorizedMessage />;
  }
 
  return children;
};
 
const awesomePlaceholder = (
  <div className="my-awesome-placeholder">
    {[6, 5, 4, 3, 2, 1].map((n) => (
      <RectShape
        key={n}
        color={`rgba(165,165,165,${0.03 * n})`}
        style={{
          width: "100%",
          height: 80,
          marginBottom: 20,
          borderRadius: "16px",
        }}
      />
    ))}
  </div>
);
 
const PlaceHolder = () => {
  return (
    <ReactPlaceholder
      showLoadingAnimation={false}
      ready={false}
      customPlaceholder={awesomePlaceholder}
    >
      <div />
    </ReactPlaceholder>
  );
};
 
export const NotAuthorizedMessage = () => {
  return (
    <BlurredContainer>
      <StyledBgText>
        <CustomBackgroundVideo
          sx={{
            borderRadius: "16px",
            boxShadow:
              "0px 20px 40px 0px rgba(0, 0, 0, 0.05), 0px 2px 3px 0px rgba(0, 0, 0, 0.10)",
          }}
          videoProps={{
            style: {
              opacity: 0.2,
              objectPosition: "50% 90%",
            },
          }}
          videoSrc={BACKGROUND_VIDEO_PRIMARY}
        >
          <div style={{ width: "100%", height: 200 }} />
        </CustomBackgroundVideo>
        <Grid paddingTop={4}>
          <PlaceHolder />
        </Grid>
      </StyledBgText>
      <StyledContentContainer>
        <MissingPermissionContent />
      </StyledContentContainer>
    </BlurredContainer>
  );
};
 
export const NotAuthorizedBanner = () => {
  return (
    <CustomBackgroundVideo
      sx={{
        borderRadius: "16px",
        boxShadow:
          "0px 20px 40px 0px rgba(0, 0, 0, 0.05), 0px 2px 3px 0px rgba(0, 0, 0, 0.10)",
      }}
      videoProps={{
        style: {
          opacity: 0.2,
          objectPosition: "50% 90%",
        },
      }}
      videoSrc={BACKGROUND_VIDEO_PRIMARY}
    >
      <MissingPermissionContent />
    </CustomBackgroundVideo>
  );
};
 
const BlurredContainer = styled("div")(({ theme }) => ({
  width: "100%",
  height: "90%",
  overflow: "hidden",
  display: "flex",
  justifyContent: "center",
  alignItems: "center",
  [theme.breakpoints.down("sm")]: {
    width: "100%",
    padding: "20px",
    left: 0,
  },
}));
 
const StyledBgText = styled("div")({
  width: "60%",
  height: "95%",
  position: "absolute",
  top: "50%",
  left: "50%",
  transform: "translate(-50%, -50%)",
  color: "black",
  fontSize: "24px",
  userSelect: "none",
  boxShadow: `-1px 2px 38px 10px ${palette.primary.background}`,
});
 
const StyledContentContainer = styled("div")({
  position: "absolute",
  top: "25%",
  zIndex: 1,
  background: "rgba(255, 255, 255, 0.80)",
  boxShadow: "0px 60px 180px 0px rgba(0, 0, 0, 0.15)",
  borderRadius: 16,
  padding: "48px 16px",
  border: " 2px solid var(--popup-border, #FFF)",
  backdropFilter: "blur(20px)",
});