All files / src/components/Sweepstakes/SweepstakesReport/Table/Mobile SweepstakeTableCard.tsx

0% Statements 0/23
0% Branches 0/4
0% Functions 0/11
0% Lines 0/21

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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
import React from "react";
import { palette } from "@palette";
// mui
import Box from "@mui/material/Box";
import Menu from "@mui/material/Menu";
import Stack from "@mui/material/Stack";
import Paper from "@mui/material/Paper";
import Divider from "@mui/material/Divider";
import Collapse from "@mui/material/Collapse";
import { styled } from "@mui/material/styles";
import LinearProgress, {
  linearProgressClasses,
} from "@mui/material/LinearProgress";
// components
import { Text } from "@common/Text";
import SweepstakePurchaseBox from "./SweepstakePurchaseBox";
import { Button } from "@common/Button";
import { DropdownItem } from "@common/Select";
import SweepstakePurchaseKeyValue from "./SweepstakePurchaseKeyValue";
import {
  Refund,
  SendReceipt,
  ViewCustomer,
} from "@components/ManageMoney/TransactionTable/TableActions";
// import ViewTransaction from "../ViewTransaction/ViewTransaction";
// assets
import { MoreIcon } from "@assets/icons";
// types
import { Data } from "../../data";
import ViewTransaction from "@components/DonationList/Table/ViewTransaction/ViewTransaction";
import {
  MERCHANT_PORTAL_REFUND_MODAL,
  MERCHANT_PORTAL_SEND_RECEIPT_MODAL,
  MERCHANT_PORTAL_VIEW_TRANSACTION_MODAL,
  MERCHANT_VIEW_CUSTOMER,
} from "modals/modal_names";
import NiceModal from "@ebay/nice-modal-react";
import { PurchaseItem } from "@components/DonationList/Table/FundraisersDonationsTable";
 
type PurchaseProps = {
  rowData: PurchaseItem;
};
 
const Progress = styled(LinearProgress)(({ theme }) => ({
  width: 120,
  height: "8px",
  borderRadius: "32px",
  [`&.${linearProgressClasses.colorPrimary}`]: {
    backgroundColor: palette.neutral[20],
  },
  [`& .${linearProgressClasses.bar}`]: {
    borderRadius: "32px",
    backgroundColor: palette.neutral[100],
  },
}));
 
const cardStyle = {
  width: "100%",
  py: "12px",
  px: "8px",
  borderRadius: "8px",
  border: "2px solid #EADDFD",
  boxShadow:
    "0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03)",
};
 
const dividerStyle = {
  my: "12px",
  width: "calc(100% + 16px)",
  transform: "translateX(-8px)",
};
 
const SweepstakeTableCard = ({ rowData }: PurchaseProps) => {
  const [openRow, setOpenRow] = React.useState(false);
  const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
  const open = Boolean(anchorEl);
 
  const handleOpenMenu = (event: React.MouseEvent<HTMLElement>) => {
    event.stopPropagation();
    setAnchorEl(event.currentTarget);
  };
 
  const handleOpenActionModal = (modalName: string) => {
    NiceModal.show(modalName);
    if (anchorEl) setAnchorEl(null);
  };
 
  return (
    <Paper sx={cardStyle}>
      <Collapse in={!openRow}>
        <div onClick={() => setOpenRow(!openRow)}>
          <SweepstakePurchaseBox
            title={rowData.product?.name}
            value={rowData.transactionID}
          />
          <Box display="flex" justifyContent="space-between" mt="8px">
            <SweepstakePurchaseBox
              title="Striped Sweater"
              titleSx={{ marginBottom: "4px" }}
              value={`??`}
            />
            {/* <SweepstakePurchaseBox
              title={
                <>
                  5.00 <sup>USD</sup>
                </>
              }
              value="5.00 per ticket"
              flexEnd
            /> */}
          </Box>
        </div>
      </Collapse>
 
      <Collapse in={openRow}>
        <div onClick={() => setOpenRow(!openRow)}>
          <SweepstakePurchaseBox
            title={rowData.product?.name}
            value={rowData.transactionID}
            reverse
          />
        </div>
        <Divider sx={dividerStyle} />
        <Button
          variant="primary"
          endIcon={<MoreIcon />}
          fullWidth
          sx={{ mb: "16px" }}
          onClick={handleOpenMenu}
        >
          Actions
        </Button>
        <SweepstakePurchaseKeyValue
          title="Full Name"
          value={rowData.product?.name}
          highlight
        />
        <SweepstakePurchaseKeyValue title="Email" value={rowData.email} />
        <SweepstakePurchaseKeyValue
          title="Transaction ID"
          value={rowData.transactionID}
          highlight
        />
        <SweepstakePurchaseKeyValue
          title="Processed"
          value={rowData.createdAt}
        />
        <SweepstakePurchaseKeyValue
          title="Name on Card"
          value={rowData.sorceAccountFullName}
          highlight
        />
        <SweepstakePurchaseKeyValue
          title="Revenue Source"
          value={rowData.revenue}
        >
          <Text fontWeight="medium" color={palette.primary.main}>
            staging.givebox.com/12321312
          </Text>
        </SweepstakePurchaseKeyValue>
 
        <Box sx={{ border: "1px dashed #DDDCE5", my: "12px" }} />
 
        {/* <SweepstakePurchaseKeyValue
          title="Type"
          value={rowData.recurringPurchases[0].type}
          highlight
        /> */}
        <SweepstakePurchaseKeyValue
          title="Recurrence"
          value={rowData.recurringInterval}
        >
          <div style={{ display: "flex" }}>
            <div style={{ flexGrow: 1 }} />
            {rowData.recurringInterval !== "once" && (
              <Stack
                mt={1}
                gap="4px"
                direction="row"
                alignItems="center"
                spacing={0.5}
                // sx={{ float: "right" }}
              >
                <Text>1 out of 6</Text>
                <Box>
                  <Progress variant="determinate" value={50} />
                </Box>
              </Stack>
            )}
          </div>
        </SweepstakePurchaseKeyValue>
        <SweepstakePurchaseKeyValue
          title="Purchased"
          value="Subscription 1 x Qty 1 @ 5.00USD each"
          highlight
          style={{ display: "block" }}
          customKeyStyle={{ marginBottom: "8px" }}
        />
 
        <Box
          sx={{
            background: "#FFFFFF",
            boxShadow:
              "inset -4px -4px 9px rgba(255, 255, 255, 0.88), inset 0px 2px 14px rgba(193, 208, 238, 0.5)",
            borderRadius: "4px",
            marginTop: "20px",
          }}
        >
          <SweepstakePurchaseKeyValue
            title="Amount"
            value={
              <Text fontWeight="medium">
                100.00<sup style={{ fontSize: 10 }}>USD</sup>
              </Text>
            }
            bg="transparent"
          />
          <SweepstakePurchaseKeyValue
            title="Givebox Fee"
            value={
              <Text fontWeight="medium">
                0.00<sup style={{ fontSize: 10 }}>USD</sup>
              </Text>
            }
            bg="transparent"
          />
          <SweepstakePurchaseKeyValue
            title="Visa Fee"
            value={
              <Text fontWeight="medium">
                *3.00<sup style={{ fontSize: 10 }}>USD</sup>
              </Text>
            }
            bg="transparent"
          />
          <SweepstakePurchaseKeyValue
            title="Charged"
            value={<Text fontWeight="medium">273.33 USD</Text>}
            bg="transparent"
          />
        </Box>
        <Text
          fontSize={12}
          color={palette.neutral[600]}
          sx={{ textAlign: "center", mt: "16px" }}
        >
          *Visa fee deducted from donation
        </Text>
      </Collapse>
      {/* ---------- Menu ---------- */}
      <Menu
        open={open}
        anchorEl={anchorEl}
        onClose={() => setAnchorEl(null)}
        sx={{
          "& .MuiPaper-root": {
            width: "100%",
          },
        }}
      >
        <DropdownItem
          onClick={() =>
            handleOpenActionModal(MERCHANT_PORTAL_SEND_RECEIPT_MODAL)
          }
        >
          <Text variant="h5">Send Receipt</Text>
        </DropdownItem>
        <DropdownItem
          onClick={() => handleOpenActionModal(MERCHANT_PORTAL_REFUND_MODAL)}
        >
          <Text variant="h5">Refund</Text>
        </DropdownItem>
        <DropdownItem
          onClick={() =>
            handleOpenActionModal(MERCHANT_PORTAL_VIEW_TRANSACTION_MODAL)
          }
        >
          <Text variant="h5">View Transaction</Text>
        </DropdownItem>
        <DropdownItem
          onClick={() => handleOpenActionModal(MERCHANT_VIEW_CUSTOMER)}
        >
          <Text variant="h5">View Customer</Text>
        </DropdownItem>
      </Menu>
    </Paper>
  );
};
 
export default SweepstakeTableCard;