All files / src/components/common/MerchantsDropdown MerchantDropdownItem.tsx

0% Statements 0/5
0% Branches 0/4
0% Functions 0/2
0% Lines 0/4

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                                                                                                                       
import { TickIcon } from "@assets/icons";
import { DropdownItem } from "@common/Select";
import { SelectItemProps } from "@common/Select/SelectItem";
import { Image } from "@common/StyledImage/Image";
import { Text } from "@common/Text";
import { MerchantData } from "@hooks/enterprise-api/account/types";
import { Stack, styled } from "@mui/material";
import { palette } from "@palette";
import placeholder from "assets/images/Placeholder.png";
 
type Props = {
  merchant: MerchantData;
  selected?: boolean;
} & SelectItemProps;
 
const MerchantDropdownItem = ({ merchant, selected, ...props }: Props) => {
  return (
    <StyledDropdownItem {...props} hoverBgColor={palette.neutral[10]}>
      <Image
        height={29}
        width={29}
        sx={{
          borderRadius: "4px",
        }}
        src={merchant?.imageURL ? `${merchant.imageURL}/thumb` : placeholder}
      />
      <Text
        sx={dropDownTextStyle}
        title={merchant?.name}
        fontSize={12}
        color={palette.neutral[80]}
        fontWeight="book"
      >
        {merchant?.name}
      </Text>
      {!!selected && (
        <Stack width={32} height={32} alignSelf="flex-end" alignItems="center">
          <TickIcon stroke={palette.black[100]} width={15} height={15} />
        </Stack>
      )}
    </StyledDropdownItem>
  );
};
 
const dropDownTextStyle = {
  whiteSpace: "nowrap",
  overflow: "hidden",
  textOverflow: "ellipsis",
  width: 200,
};
 
const StyledDropdownItem = styled(DropdownItem)(() => ({
  "& > div": {
    gap: "8px",
    alignItems: "center",
  },
}));
 
export default MerchantDropdownItem;