All files / src/pages/Welcome WelcomePage.atoms.tsx

100% Statements 18/18
81.25% Branches 13/16
100% Functions 8/8
100% Lines 15/15

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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189                                17x   17x 13x 13x     17x 82x 13x                                                                 17x                                       17x                                   17x               13x     13x 13x                                                           13x 13x                                                                                                  
import { APP_BAR_HEIGHT } from "@components/CustomBreadcrumbsPage/BreadcrumbsAppBar";
import { useGetCurrentMerchantId } from "@hooks/common";
import { Stack } from "@mui/material";
import { Box } from "@mui/material";
import {
  CircleIcon,
  CaretRightIcon,
  CheckCircleIcon,
} from "@phosphor-icons/react";
import { useAppSelector } from "@redux/hooks";
import { selectUser } from "@redux/slices/auth/auth";
import GiveAnimationWrapper from "@shared/BannerAnimations/GiveAnimationWrapper";
import GiveButton from "@shared/Button/GiveButton";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
 
const CONTAINER_PADDINGTOP = 24;
 
const getPagePixelsOffset = (masqueradeOffset: number) => {
  const appBarOffset = APP_BAR_HEIGHT + CONTAINER_PADDINGTOP * 2;
  return appBarOffset + masqueradeOffset;
};
 
export const WelcomePageContainer = styled(Box, {
  shouldForwardProp: (prop) => prop !== "masqueradeOffset",
})<{ masqueradeOffset: number }>(({ masqueradeOffset = 0 }) => ({
  display: "flex",
  paddingBlock: "8px",
  flexDirection: "column",
  justifyContent: "center",
  alignItems: "center",
  position: "relative",
  transition: "transform 0.5s ease-in-out",
  height: `calc(100vh - ${getPagePixelsOffset(masqueradeOffset)}px)`,
 
  "@keyframes outAnimation": {
    "0%": {
      transform: "translateX(0%)",
      visibility: " hidden",
    },
    "100%": {
      transform: "translateX(-120%)",
      visibility: "visible",
    },
  },
 
  "@keyframes inAnimation": {
    "0%": {
      transform: "translateX(100%)",
      visibility: " hidden",
    },
    "100%": {
      transform: "translateX(0%)",
      visibility: "visible",
    },
  },
}));
 
export const Background = styled(GiveAnimationWrapper)(() => ({
  position: "absolute",
  top: 0,
  bottom: 0,
  left: 0,
  right: 0,
  "&::before": {
    content: '""',
    position: "absolute",
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    background:
      "linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 10%, rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 1) 100% )",
    zIndex: 1,
    pointerEvents: "none",
  },
}));
 
export const Card = styled(Box)(({ theme }) => ({
  padding: "48px 40px",
  gap: "32px",
  backgroundColor: theme.palette.surface?.["primary-transparent"],
  width: "426px",
  borderRadius: theme.customs?.radius.large,
  display: "flex",
  flexDirection: "column",
  alignItems: "center",
  justifyContent: "center",
  backdropFilter: "blur(25px)",
  zIndex: 3,
  [theme.breakpoints.down("sm")]: {
    width: "100%",
    padding: "32px 20px",
  },
}));
 
export const ChecklistContainer = styled(Stack)(({ theme }) => ({
  padding: "12px",
  backgroundColor: theme.palette.surface?.primary,
  borderRadius: "20px",
  width: "100%",
}));
 
export function CardHeader({ completed }: { completed: boolean }) {
  const { masqFirstName } = useGetCurrentMerchantId();
  const {
    globalName: { firstName },
  } = useAppSelector(selectUser);
  return (
    <Stack gap="16px">
      {completed ? (
        <GiveText textAlign="center" variant="h2">
          You’re set up
        </GiveText>
      ) : (
        <GiveText textAlign="center" variant="h2">
          Welcome {masqFirstName ? masqFirstName : firstName}.
          <br />
          Let’s get you started
        </GiveText>
      )}
    </Stack>
  );
}
 
export function ChecklistButton({
  label,
  action,
  isCompleted,
  disabled,
  isUnderReviewProfile,
}: {
  label: string;
  action: () => void;
  isCompleted?: boolean;
  disabled?: boolean;
  isUnderReviewProfile?: boolean;
}) {
  const { palette } = useAppTheme();
  return (
    <GiveButton
      onClick={action}
      disabled={disabled}
      label={
        <GiveText textAlign="left" flex={1} variant="bodyS" color="secondary">
          {label}
        </GiveText>
      }
      startIcon={
        isCompleted && !isUnderReviewProfile ? (
          <CheckCircleIcon
            data-testid="checked-circle"
            color={palette.primitive?.success[50]}
            size={24}
            weight="fill"
          />
        ) : (
          <CircleIcon
            data-testid="unchecked-circle"
            color={
              isUnderReviewProfile
                ? palette.primitive?.blue[50]
                : palette.text.secondary
            }
            size={24}
          />
        )
      }
      endIcon={
        isCompleted ? undefined : (
          <CaretRightIcon color={palette.text.secondary} size={18} />
        )
      }
      variant="ghost"
      sx={{
        width: "100%",
        alignItems: "center",
        justifyContent: "flex-start",
        padding: "12px",
        borderRadius: "8px",
        ...(isCompleted &&
          !isUnderReviewProfile && {
            pointerEvents: "none",
          }),
      }}
    />
  );
}