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 | import * as React from "react";
import { palette } from "@palette";
import { useLocation, useNavigate } from "react-router";
import NiceModal from "@ebay/nice-modal-react";
// mui
import Box from "@mui/material/Box";
import Menu from "@mui/material/Menu";
import Stack from "@mui/material/Stack";
import { TransactionData } from "../data";
// components
import { Text } from "@common/Text";
import { Button } from "@common/Button";
import { DropdownItem } from "@common/Select";
import PersonalInfo from "./PersonalInfo";
import AmountsCard from "./AmountsCard";
import Purchase from "./Purchases";
import {
Refund,
SendReceipt,
ViewCustomer,
} from "@components/ManageMoney/TransactionTable/TableActions";
// assets
import { CartIcon, ServerIcon, ArrowBackIcon, MoreIcon } from "@assets/icons";
// redux
import { useAppDispatch } from "@redux/hooks";
import { hideDrawer } from "@redux/slices/app";
import {
MERCHANT_PORTAL_REFUND_MODAL,
MERCHANT_PORTAL_SEND_RECEIPT_MODAL,
MERCHANT_VIEW_CUSTOMER,
} from "modals/modal_names";
type TransactionDetailsProps = {
rowData: TransactionData;
isSelected?: boolean;
setIsSelected?: any;
};
const TransactionDetails = ({
isSelected,
setIsSelected,
}: TransactionDetailsProps & any) => {
const location = useLocation();
const navigate = useNavigate();
const dispatch = useAppDispatch();
const { rowData } = location.state as TransactionDetailsProps;
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
const handleOpenMenu = (event: React.MouseEvent<HTMLElement>) => {
event.stopPropagation();
setAnchorEl(event.currentTarget);
};
React.useEffect(() => {
dispatch(hideDrawer(true));
return () => {
dispatch(hideDrawer(false));
};
}, []);
return (
<Box display="flex" flexDirection="column" gap="10px">
<Box
mb={2}
display="flex"
alignItems="center"
justifyContent="space-between"
>
<Box
gap={1.5}
display="flex"
alignItems="center"
onClick={() => navigate(-1)}
>
<ArrowBackIcon />
<Text color={palette.neutral[600]}>Back</Text>
</Box>
{/* ------------- MENU ------------- */}
<Menu
open={open}
anchorEl={anchorEl}
onClose={() => setAnchorEl(null)}
anchorOrigin={{
vertical: "bottom",
horizontal: "right",
}}
transformOrigin={{
vertical: "top",
horizontal: "right",
}}
>
<DropdownItem
onClick={() => NiceModal.show(MERCHANT_PORTAL_REFUND_MODAL)}
>
<Text variant="h5">Send Receipt</Text>
</DropdownItem>
<DropdownItem
onClick={() => NiceModal.show(MERCHANT_PORTAL_SEND_RECEIPT_MODAL)}
>
<Text variant="h5">Refund</Text>
</DropdownItem>
<DropdownItem onClick={() => NiceModal.show(MERCHANT_VIEW_CUSTOMER)}>
<Text variant="h5">View Customer</Text>
</DropdownItem>
</Menu>
</Box>
{/* ----------- Payment details ----------- */}
<Stack direction="row" alignItems="center" gap={0.5}>
<ServerIcon fill="transparent" />
<Text
variant="headline"
fontWeight="medium"
color={palette.primary.main}
>
Payment Details
</Text>
<Box sx={{ marginLeft: "auto" }}>
<Button onClick={handleOpenMenu} endIcon={<MoreIcon />}>
<Text
variant="headline"
fontWeight="medium"
color={palette.primary.main}
>
Actions
</Text>
</Button>
</Box>
</Stack>
{/* ----------- Info ----------- */}
<PersonalInfo rowData={rowData} />
{/* ----------- Bottom part ----------- */}
<AmountsCard
paymentData={{
total: rowData.paymentDetails.donation,
giveboxFee: rowData.paymentDetails.giveboxFee,
visaFee: rowData.paymentDetails.visaFee,
charged: rowData.paymentDetails.charged,
}}
/>
<Text fontSize={12} color={palette.neutral[600]}>
*Visa fee deducted from donation
</Text>
{/* ----------- Purchases ----------- */}
<Box
sx={{
display: "flex",
flexDirection: "column",
gap: "10px",
}}
>
<Stack gap={1} direction="row" alignItems="center">
<CartIcon />
<Text
variant="headline"
fontWeight="medium"
color={palette.primary.main}
>
Purchases
</Text>
</Stack>
{/* ----------- Purchases items ----------- */}
{rowData.recurringPurchases && (
<Box display="flex" flexDirection="column" gap="10px">
{rowData.recurringPurchases.map((purchase) => (
<Purchase
key={purchase.id}
description={purchase.description}
title={purchase.title}
type={purchase.type}
recurrence={purchase.recurrence}
donationAmount={purchase.details.donation}
/>
))}
</Box>
)}
</Box>
</Box>
);
};
export default TransactionDetails;
|