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 190 191 192 193 194 195 196 197 | 12x 12x 12x 12x 12x | import ImagePlaceholder from "@assets/svgIcons/storefront-placeholder.svg";
import { rgbToHex, Stack } from "@mui/material";
import { parseDescription } from "@shared/HFInputs/HFRichInput/RichTextUtils";
import GiveText from "@shared/Text/GiveText";
import GiveTruncateText from "@shared/Text/GiveTruncateText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { addSizeToImage } from "@utils/image.helpers";
import { parseAmount } from "@utils/index";
import { ItemCardProps, TFormStatus } from "../types";
import NiceModal from "@ebay/nice-modal-react";
import { PUBLIC_PRODUCT_ITEM_MODAL } from "modals/modal_names";
import { useCart } from "@sections/PayBuilder/provider/CartContext";
import { useParams } from "react-router-dom";
import { usePayBuilderForm } from "@sections/PayBuilder/provider/PayBuilderFormProvider";
import { getTextColorsBasedOnBackground } from "@sections/PayBuilder/utils";
import SubscribeButton from "./SubscribeButton";
import { CURRENCY } from "@constants/constants";
const MembershipCard: React.FC<ItemCardProps> = ({
product,
displayStatus,
itemLayout,
paymentType,
accentColor,
backgroundColor,
isFromADB,
isPreview,
isPeekMode,
}) => {
const { methods, setCheckoutBottomSheetVisible } = usePayBuilderForm();
const { thumbnail, amount, title, description, signupFee, featureList } =
product;
const parsedDescription = parseDescription(description);
const { palette } = useAppTheme();
const { addToCart } = useCart();
const smallThumbnail = addSizeToImage(
thumbnail || "",
"small",
ImagePlaceholder,
);
const { isInputColorLight } = getTextColorsBasedOnBackground(
rgbToHex(backgroundColor).toUpperCase(),
);
const { id: productId } = useParams();
const handleItemClick = () => {
NiceModal.show(PUBLIC_PRODUCT_ITEM_MODAL, {
product,
accentColor,
backgroundColor,
displayStatus,
addToCart,
productId,
subscribeBtnText: methods.watch().Style?.checkoutContent,
isPreview,
secondaryColor: palette.text.secondary,
showCheckoutBottomSheet: setCheckoutBottomSheetVisible,
});
};
return (
<StyledContainer
onClick={handleItemClick}
direction={"column"}
displayStatus={displayStatus}
isFromADB={isFromADB}
sx={{
cursor: "pointer",
}}
>
{Boolean(thumbnail) && <StyledImage alt={title} src={smallThumbnail} />}
<ContentWrapper>
<GiveTruncateText
lineClamp={1}
variant="bodyS"
color="primary"
fontWeight="600"
{...(isFromADB && {
sx: {
color: palette.text.primary,
},
})}
>
{title}
</GiveTruncateText>
<GiveTruncateText
variant="bodyS"
color="secondary"
{...(isFromADB && {
sx: {
color: palette.text.secondary,
},
})}
lineClamp={1}
sx={{ color: isInputColorLight ? "black" : "white" }}
>
{parsedDescription}
</GiveTruncateText>
<Stack gap="6px" direction="column">
<GiveText
variant="bodyS"
color="primary"
{...(isFromADB && {
sx: {
color: palette.text.primary,
},
})}
sx={{ color: isInputColorLight ? "black" : "white" }}
>
{isFromADB
? `From ${parseAmount(amount)} ${CURRENCY}`
: `From ${parseAmount(amount)} ${CURRENCY}`}
<span
style={{
textTransform: "capitalize",
}}
>
{" "}
{isFromADB || paymentType === "monthly"
? paymentType
: `per ${paymentType.slice(0, -2)}`}
</span>
</GiveText>
{Boolean(signupFee) && (
<GiveText
variant="bodyS"
color="secondary"
sx={{ color: isInputColorLight ? "black" : "white" }}
>
{`+ ${parseAmount(signupFee)} ${CURRENCY} Signup Fee`}
</GiveText>
)}
</Stack>
{featureList && (
<GiveTruncateText
variant="bodyS"
color="secondary"
sx={{
whiteSpace: "pre-line",
color: isInputColorLight ? "black" : "white",
}}
lineClamp={5}
>
{featureList}
</GiveTruncateText>
)}
<SubscribeButton
product={product}
accentColor={accentColor}
buttonText={methods.watch().Style?.checkoutContent}
isPreview={isPreview}
isPeekMode={isPeekMode}
showCheckoutBottomSheet={setCheckoutBottomSheetVisible}
/>
</ContentWrapper>
</StyledContainer>
);
};
export default MembershipCard;
const StyledImage = styled("img")(() => ({
borderRadius: "8px",
width: "100%",
objectFit: "cover",
itemLayout: "block",
flexShrink: 0,
height: "144px",
}));
const StyledContainer = styled(Stack, {
shouldForwardProp: (prop) => prop !== "displayStatus" && prop !== "isFromADB",
})<{
displayStatus: TFormStatus;
isFromADB?: boolean;
}>(({ theme, displayStatus, isFromADB }) => ({
borderRadius: "12px",
padding: "16px 16px 24px 16px",
border: `1px solid ${
!isFromADB ? theme.palette.border?.primary : "#0000001A"
}`,
width: "100%",
gap: "16px",
position: "relative",
...(displayStatus === "draft" && {
pointerEvents: "none",
}),
}));
const ContentWrapper = styled(Stack)({
gap: "6px",
flex: 1,
});
|