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 | 52x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 52x | // features/TransactionPanel/components/TransactionSummary.ts
import { Box, Stack } from "@mui/material";
import TransactionSummaryDetails from "./TransactionSummaryDetails";
import { useTransactionSummary } from "../../hooks/useTransactionSummary";
import { styled, useAppTheme } from "@theme/v2/Provider";
import TransactionSummaryActions from "./TransactionSummaryActions";
import RiskLevelProgress from "../RiskLevelProgress";
import { SummaryContainerBase } from "../atoms";
import { TransactionSidePanelType } from "@features/TransactionPanel/types";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
import TopContainer from "./TopContainer/TopContainer";
import { checkPortals } from "@utils/routing";
import { MerchantAccountType } from "types/merchant.preview.types";
type Props = {
data: any;
isFirst?: boolean;
isLast?: boolean;
setSelectedRow?: (newIdx: string | number) => void;
handleSidePanelOpen?: (type: TransactionSidePanelType) => void;
chooseTransaction?: (
loading: boolean,
) => ((prevWasLoading: boolean, data: any) => void) | undefined;
isFees?: boolean;
isManageMoney?: boolean;
handleOpenMerchant?: (modalType: MerchantAccountType, id: string) => void;
};
const TransactionSummary = ({
data,
isFirst,
isLast,
handleSidePanelOpen,
setSelectedRow,
chooseTransaction,
isManageMoney = false,
handleOpenMerchant,
}: Props) => {
const {
section,
isDeclined,
isTransfer,
isFees,
isRiskHeaderVisible,
hasBalance,
showEndingBalance,
formattedCreatedAt,
openRiskModal,
isAcquirerTransfer,
} = useTransactionSummary({ data, handleSidePanelOpen, handleOpenMerchant });
const theme = useAppTheme();
const { isMobileView } = useCustomThemeV2();
const { isMerchantPortal } = checkPortals();
const isReconciliation = data?.transactionType === "reconciliation_credit";
const riskLevel = data?.ipProfileRiskLevel;
const showActions = !isFees && !data?.isMerchantDeleted && !isReconciliation;
const handleOpenRiskModal = () => {
if (openRiskModal) {
openRiskModal();
}
};
const ActionsSection = ({ isTopCard }: { isTopCard?: boolean } = {}) => {
Iif (!showActions) return null;
return (
<TransactionSummaryActions
data={data}
setSelectedRow={setSelectedRow}
isFirst={isFirst}
isLast={isLast}
setIsCustomerPanelOpen={() => null}
chooseTransaction={chooseTransaction}
isTopCard={isTopCard}
/>
);
};
const hideSummary =
isMerchantPortal || section?.items?.length === 0 || isAcquirerTransfer;
return (
<Stack spacing="21px">
<TopContainer
data={data}
isDeclined={isDeclined}
isFees={isFees}
isTransfer={isTransfer}
actions={<ActionsSection isTopCard />}
formattedCreatedAt={formattedCreatedAt}
isManageMoney={isManageMoney}
/>
{isMobileView && <ActionsSection />}
{!hideSummary && (
<SummaryContainer>
{isRiskHeaderVisible && (
<RiskLevelProgress
level={riskLevel}
onClick={handleOpenRiskModal}
/>
)}
<TransactionSummaryDetails
list={section?.items}
isHideBorder={true}
sx={{ pb: 0 }}
/>
</SummaryContainer>
)}
</Stack>
);
};
const SummaryContainer = styled(SummaryContainerBase)(({ theme }) => ({
padding: "20px",
paddingTop: "0",
[theme.breakpoints.down("v2_sm")]: {
padding: "4px 20px 20px 20px",
},
}));
export default TransactionSummary;
|