All files / src/features/MerchantPortal/DeveloperApi/components DeveloperPanelContent.tsx

91.66% Statements 11/12
70% Branches 7/10
100% Functions 4/4
90.9% Lines 10/11

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                    2x 7x 7x 7x   7x         7x             7x                                                                           14x                                                           49x                                           7x            
import { Box, Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { ArrowUpRightIcon } from "@phosphor-icons/react";
import GiveLink from "@shared/Link/GiveLink";
import { DEV_API_DOCUMENTATION_TITLE } from "../constants";
import { getBaseUrl, getDocsDomain, SANDBOX_PORTAL_URL } from "../utils";
import { getApiKeyValues } from "../apiKeyUtils";
import ApiInputItem from "./ApiKeyInput";
 
const DeveloperPanelContent = ({ rowData }: { rowData: any }) => {
  const { palette } = useAppTheme();
  const BASE_URL = getBaseUrl(rowData.isSandbox);
  const DocumentationLink = getDocsDomain();
 
  const inputs = [
    { title: "Key", value: rowData.apiKey },
    { title: "Base URL", value: BASE_URL },
  ];
 
  Iif (rowData.isSandbox) {
    inputs.push({
      title: "Portal URL",
      value: SANDBOX_PORTAL_URL,
    });
  }
 
  return (
    <Stack
      gap="24px"
      sx={{
        backgroundColor: "#fff",
        borderRadius: "20px",
        padding: "20px",
      }}
    >
      <Stack pt="12px" gap="16px">
        <GiveText variant="h3" fontWeight={271}>
          {rowData.name}
        </GiveText>
        {rowData.description && (
          <GiveText color="secondary">{rowData.description}</GiveText>
        )}
        <Box
          component="span"
          bgcolor={palette.primitive?.transparent["darken-5"]}
          width="fit-content"
          borderRadius="8px"
          sx={{
            padding: "7px 12px",
          }}
        >
          <StyledGiveLink
            Icon={ArrowUpRightIcon}
            iconPosition="right"
            link={DocumentationLink}
            target="_blank"
            data-testid="side-panel-docs-link"
          >
            {DEV_API_DOCUMENTATION_TITLE}
          </StyledGiveLink>
        </Box>
      </Stack>
 
      {inputs.map(({ title, value }, index) => (
        <ApiInputItem
          key={index}
          title={title}
          value={value}
          tooltipText={title}
        />
      ))}
 
      <Stack
        pt="24px"
        gap="16px"
        sx={{
          borderTop: `1px solid ${palette.border?.primary}`,
        }}
      >
        {rowData.isSandbox && (
          <Box
            sx={{
              background: palette.primitive?.blue["10"],
              borderRadius: "8px",
              padding: "12px",
            }}
          >
            <GiveText variant="bodyS" color="blue">
              The credentials for accessing the sandbox environment are the same
              as the username and password of the creator’s account
            </GiveText>
          </Box>
        )}
        {getApiKeyValues(rowData).map(({ key, value, id }) => (
          <Stack
            gap="16px"
            justifyContent="space-between"
            direction="row"
            key={id}
          >
            <GiveText color="secondary" variant="bodyS" flex={1}>
              {key}
            </GiveText>
            <Box textAlign="left" flex={1}>
              {typeof value === "string" && (
                <GiveText variant="bodyS">{value}</GiveText>
              )}
              {typeof value !== "string" && value}
            </Box>
          </Stack>
        ))}
      </Stack>
    </Stack>
  );
};
 
const StyledGiveLink = styled(GiveLink)(() => ({
  "&:hover span:before": {
    content: "unset",
  },
}));
export default DeveloperPanelContent;