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 198 199 200 201 202 203 | import * as React from "react";
import { palette } from "@palette";
// mui
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Stack from "@mui/material/Stack";
import { useTheme } from "@mui/material/styles";
// components
import { Text } from "@common/Text";
import { KeyVal } from "@common/KeyVal";
import SubExpandedRow from "./SubExpandedRow";
// assets
import { CartIcon } from "@assets/icons";
import { Item, Transaction } from "./transactions.types";
type ExpandedRowProps = {
rowData: Transaction & any;
};
export const ExpandedRow: React.FC<ExpandedRowProps> = ({ rowData }) => {
const theme = useTheme();
const style = {
"& sup": {
fontSize: 9,
lineHeight: "9px",
marginLeft: "2px",
},
};
const sourceAccount = React.useMemo(() => {
const isUser = rowData.sourceAccount.type === "user";
return {
fullName: isUser
? `${rowData.sourceAccount.user?.firstName} ${rowData.sourceAccount.user?.lastName}`
: rowData.sourceAccount.merchant?.name,
email: rowData.customer.email,
card: {
brand: rowData.sourceMethod.card?.brand,
numberLast4: rowData.sourceMethod.card?.numberLast4,
},
};
}, [rowData]);
return (
<Box p={theme.spacing(3, 1.5, 2)}>
<Box display="flex" gap={3} sx={style}>
<Box gap={1.5} display="flex" flexDirection="column">
{/** ============== GRID [xs={6} 2 items per row (12 column grid) | column & row spacing {2} ] ============= */}
<Grid container spacing={2}>
{/** ================= FULL NAME ================= */}
<Grid item xs={6}>
<KeyVal
textVariant
keyName="Customer Name"
value={rowData.customerName}
/>
</Grid>
{/** ================= EMAIL ================= */}
<Grid item xs={6}>
<KeyVal
textVariant
keyName="Email"
value={rowData.customer.email}
/>
</Grid>
{/** ================= MERCH ORDER ================= */}
<Grid item xs={6}>
<KeyVal
textVariant
keyName="Transaction ID"
value={rowData.paymentDetails.merchantTaxId}
/>
</Grid>
{/** ================= PROCESSED ================= */}
<Grid item xs={6}>
<KeyVal textVariant keyName="Created At" value={rowData.time} />
</Grid>
{/** ================= NAME ON CARD ================= */}
<Grid item xs={6}>
<KeyVal
textVariant={true}
keyName="Name on Card"
value={rowData.sourceMethod.card.cardholderName}
/>
</Grid>
{/** ================= STATUS ================= */}
<Grid item xs={6}>
<KeyVal
keyName="Status"
value={
<Stack gap={4} direction="row" alignItems="center">
<Text>Settled</Text>
<Text>
xxxx xxxx xxxx {rowData.sourceMethod.card.numberLast4}
</Text>
<Text
color={palette.neutral[800]}
textTransform="capitalize"
>
{rowData.sourceMethod.card.brand}
</Text>
</Stack>
}
/>
</Grid>
{/** ================= REVENUE SOURCE ================= */}
<Grid item xs={6}>
{/* <KeyVal
textVariant={true}
keyName="Revenue Source"
value={
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
>
<Text>Donation made from website</Text>
<Text
style={{
textDecoration: "underline",
}}
color={palette.neutral[800]}
>
staging.givebox/12321312
</Text>
</Stack>
}
/> */}
</Grid>
{/** ================= GRID [ xs={3} 4 items per row, Grid item and also container ] ================= */}
<Grid item xs={6} container columnSpacing={1}>
{/** ================= TOTAL ================= */}
<Grid item xs={3}>
<KeyVal
textVariant
keyName="Subtotal"
value={
<Text>
{(rowData.cost / 100).toFixed(2)}
<sup>USD</sup>
</Text>
}
/>
</Grid>
{/** ================= FEE ================= */}
<Grid item xs={3}>
<KeyVal
textVariant
keyName="Fee"
value={
<Text>
{(rowData.fees / 100).toFixed(2)}
<sup>USD</sup>
</Text>
}
/>
</Grid>
{/** ================= CHARGED ================= */}
<Grid item xs={3}>
<KeyVal
textVariant
keyName="Charged"
value={
<Text>
{(rowData.charged / 100).toFixed(2)}
<sup>USD</sup>
</Text>
}
/>
</Grid>
</Grid>
</Grid>
{/** ------------------------ TRANSACTION STATISTICS ------------------------ */}
<Stack gap={0.5} direction="row">
<CartIcon fill="transparent" />
<Text
color={palette.neutral[80]}
variant="headline"
fontWeight="medium"
>
Purchased Items
</Text>
</Stack>
</Box>
</Box>
{/** ------------------------ RECURRING PURCHASES ------------------------ */}
{rowData.items && (
<Box mt={1.5}>
{rowData.items.map((data: Item) => (
<SubExpandedRow
data={data}
transactionID={rowData.id}
sourceAccount={sourceAccount}
key={data.id}
/>
))}
</Box>
)}
</Box>
);
};
|