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 | 13x 6x 6x 6x 3x 6x 13x 13x 6x 6x 6x 6x 6x 13x 13x 13x 19x 6x | import { MenuItem } from "@common/Menu/Menu";
import { Stack, StackProps, styled } from "@mui/material";
import React, { PropsWithChildren, memo } from "react";
import { useParams } from "react-router-dom";
import HeaderListingBanner from "./HeaderListingBanner";
import ReportListingBanner from "./ReportListingBanner";
import { useDropdownMenu } from "@common/Menu/hooks/useDropdownMenu";
import { StatProps } from "@common/NewStats/Stat";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import { toUTCDateFormat } from "@utils/index";
import NewMobileProductListingBanner from "./NewMobileProductListingBanner";
interface NewProductListingBannerProps extends PropsWithChildren {
menuItems: MenuItem[];
type: string;
stats: any;
previewLink: string;
handleEdit: any;
textToCopy: string;
data: any;
parseStats: StatProps[];
endOfEvent?: boolean;
isEditProductAllowed?: boolean;
}
interface BackgroundImageProps extends StackProps {
backgroundSrc: string;
}
export const usePublicFormUrl = () => {
const { id } = useParams();
const [textToCopy, setTextToCopy] = React.useState("");
React.useEffect(() => {
setTextToCopy(`/${id}`);
}, []);
return { id, textToCopy, composedUrl: window.location.origin + textToCopy };
};
const BOX_BLURED_IMAGE_HEIGHT = "40px";
const NewProductListingBanner = ({
parseStats,
handleEdit,
menuItems,
data,
children,
previewLink,
type,
endOfEvent,
isEditProductAllowed,
}: NewProductListingBannerProps) => {
const { textToCopy } = usePublicFormUrl();
const { DropdownMenu, openMenu } = useDropdownMenu();
const { isMobileView } = useCustomTheme();
const isNewForm = true;
return (
<Container>
<BackgroundImageContainer backgroundSrc={data?.imageURL} />
{isMobileView ? (
<NewMobileProductListingBanner
onClick={openMenu}
title={data?.name}
type={type}
stats={parseStats}
createdAt={toUTCDateFormat(data?.createdAt)}
previewLink={previewLink}
imgSrc={data?.imageURL}
/>
) : (
<StyleStack>
<HeaderListingBanner
isEditProductAllowed={isEditProductAllowed}
title={data?.name}
onMenuOpen={openMenu}
handleEdit={handleEdit}
previewLink={previewLink}
handleOpenMenu={openMenu}
endOfEvent={endOfEvent}
createdAt={toUTCDateFormat(data?.createdAt)}
imgSrc={data?.imageURL}
isNewForm={isNewForm}
paymentId={data?.id}
campaignType={data?.typeName}
/>
<ReportListingBanner
type={type}
stats={parseStats}
imgSrc={data?.imageURL}
createdAt={toUTCDateFormat(data?.createdAt)}
handleEdit={handleEdit}
textToCopy={textToCopy}
handleOpenMenu={openMenu}
previewLink={previewLink}
title={data?.name}
/>
{children}
</StyleStack>
)}
<DropdownMenu items={menuItems} isSwipeableDrawerMobileView />
</Container>
);
};
export default memo(NewProductListingBanner);
const Container = styled(Stack)(() => ({
position: "relative",
}));
const StyleStack = styled(Stack)(({ theme }) => ({
position: "relative",
borderRadius: "16px",
gap: "20px",
marginBottom: 2,
padding: "28px",
boxShadow: "0px 10px 20px 0px #0000000D",
backgroundColor: theme.palette.common.white,
}));
const BackgroundImageContainer = styled<React.FC<BackgroundImageProps>>(Stack, {
shouldForwardProp: (prop) => prop !== "backgroundSrc",
})(({ backgroundSrc }) => ({
position: "absolute",
inset: 0,
height: BOX_BLURED_IMAGE_HEIGHT,
background: `url('${backgroundSrc}/small')`,
filter: "blur(50px)",
}));
|