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 | import { Stack, styled } from "@mui/material";
import useSidePanel from "./useSidePanel";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import ActionsHeader from "./ActionsHeader";
import GiveSidePanel from "@shared/SidePanel/GiveSidePanel";
import { CAMPAIGN_PANEL_WIDTH } from "@common/CampaignCard/CampaignDetailsModal/useCampaignModal";
import { NiceModalHandler } from "@ebay/nice-modal-react";
type PanelBodyProps = {
data: any;
isExpanded: boolean;
isEmpty: boolean;
};
type TPanelBodyComponent = (props: PanelBodyProps) => JSX.Element;
type TLoadingPlaceholderComponent = ({
isExpanded,
}: {
isExpanded: boolean;
}) => JSX.Element;
interface SidePanelWrapperProps {
data: any;
isLoading: boolean;
PanelBody: TPanelBodyComponent;
LoadingPlaceholder: TLoadingPlaceholderComponent;
isEmpty: boolean;
panelProps?: {
canBeExpanded: boolean;
isExpanded: boolean;
modal: NiceModalHandler<Record<string, unknown>>;
handleClose: () => void;
handleExpandPanel: () => void;
};
}
const SidePanelWrapper = ({
isLoading,
data,
PanelBody,
LoadingPlaceholder,
isEmpty,
panelProps,
}: SidePanelWrapperProps) => {
const { isMobileView } = useCustomTheme();
const {
canBeExpanded,
handleClose,
handleExpandPanel,
isExpanded = false,
modal,
} = panelProps || {};
const panelBodyProps: PanelBodyProps = {
isExpanded,
data,
isEmpty,
};
const PanelContent = () => {
if (isMobileView) {
return (
<ContentWrapper>
{isLoading ? (
<LoadingPlaceholder isExpanded={isExpanded} />
) : (
<PanelBody {...panelBodyProps} />
)}
</ContentWrapper>
);
}
return (
<ContentWrapper>
<ActionsHeader
handleClose={handleClose}
handleExpandPanel={handleExpandPanel}
isExpanded={isExpanded}
isEmpty={isEmpty || isLoading}
/>
{isLoading ? (
<LoadingPlaceholder isExpanded={isExpanded} />
) : (
<PanelBody {...panelBodyProps} />
)}
</ContentWrapper>
);
};
return (
<GiveSidePanel
open={modal?.visible}
onClose={handleClose}
containerProps={{
firstPanel: {
overflow: "auto",
flex: isMobileView ? "none" : 1,
...(isMobileView ? { padding: "32px 12px 16px" } : {}),
scrollbarGutter: "stable both-edges",
},
}}
width={
canBeExpanded && isExpanded
? CAMPAIGN_PANEL_WIDTH * 2
: CAMPAIGN_PANEL_WIDTH
}
>
<PanelContent />
</GiveSidePanel>
);
};
const ContentWrapper = styled(Stack)(({ theme }) => ({
flexDirection: "column",
flexGrow: 1,
gap: "32px",
alignItems: "stretch",
overflowY: "auto",
[theme.breakpoints.up("sm")]: {
padding: "24px 16px",
scrollbarGutter: "stable both-edges",
overflowY: "hidden",
},
}));
export default SidePanelWrapper;
|