All files / src/components/ProfilePage form.components.tsx

100% Statements 10/10
66.66% Branches 8/12
100% Functions 3/3
100% Lines 10/10

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                    22x             133x 133x   133x                                         22x             84x 84x                                                         22x             133x 133x                                                                                            
import React from "react";
import { Button } from "@common/Button";
import { ButtonProps } from "@common/Button/Button";
import { Text } from "@common/Text";
import { Box, Stack, SxProps, useMediaQuery, useTheme } from "@mui/material";
import { palette } from "@palette";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import { ArrowLeft } from "@assets/icons";
import { HiddenComponent } from "@containers/HiddenComponent";
 
export const ProfileSetupFormContainer = ({
  children,
  sx,
}: {
  children: React.ReactNode;
  sx?: SxProps;
}) => {
  const theme = useTheme();
  const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
 
  return (
    <Stack
      direction="column"
      flexGrow={1}
      gap={2}
      justifyContent="space-between"
      sx={{
        overflowY: "visible",
        overflowX: "hidden",
        flexGrow: 1,
        paddingTop: isDesktop ? "50px" : "20px",
        paddingBottom: "16px",
        paddingInline: "8px",
        ...sx,
      }}
    >
      {children}
    </Stack>
  );
};
 
export const ProfileSetupFormTitle = ({
  title,
  description,
}: {
  title: string;
  description?: string;
}) => {
  const { isMobileView } = useCustomTheme();
  return (
    <Stack direction="column" gap={1} alignItems="flex-start">
      <Text
        color={palette.black[200]}
        variant="h1"
        lineHeight={isMobileView ? "38.4px" : "67.2px"}
        fontSize={{ xs: "32px", md: "56px" }}
        fontWeight="book"
        align="left"
        sx={{ letterSpacing: "-1.68px" }}
      >
        {title}
      </Text>
      <HiddenComponent hidden={!description}>
        <Text
          color={palette.gray[300]}
          fontWeight="regular"
          variant="body"
          fontSize={{ xs: "14px", md: "18px" }}
          lineHeight={isMobileView ? "16.8px" : "24.3px"}
          align="left"
        >
          {description}
        </Text>
      </HiddenComponent>
    </Stack>
  );
};
 
export const ProfileSetupFormActions = ({
  secondaryAction,
  primaryAction,
}: {
  secondaryAction?: ButtonProps;
  primaryAction: ButtonProps;
}) => {
  const { isMobileView } = useCustomTheme();
  return (
    <Stack
      direction={{ xs: "column-reverse", md: "row" }}
      justifyContent="space-between"
      alignItems="center"
      gap={2}
    >
      <Button
        {...secondaryAction}
        background="tertiary"
        size="medium"
        sx={{ minWidth: "32px", fontWeight: 400 }}
      >
        {secondaryAction?.children ? (
          secondaryAction.children
        ) : (
          <Box
            component="span"
            color={palette.black[100]}
            display="inline-flex"
            alignItems="center"
            gap="4px"
          >
            <ArrowLeft height={20} width={20} fill={palette.black[100]} /> Back
          </Box>
        )}
      </Button>
      {!primaryAction.hidden && (
        <Button
          background="primary"
          size="medium"
          form="business-profile-form"
          type="submit"
          fullWidth={isMobileView}
          data-testid="primary-button-id"
          {...primaryAction}
          sx={{
            minWidth: "32px",
            fontWeight: 400,
            ...(primaryAction?.sx && primaryAction.sx),
          }}
        />
      )}
    </Stack>
  );
};