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 | 263x 6x 6x 263x 6x 6x 263x 263x 263x 263x 299x 6x | import { palette } from "@palette";
import { Box, BoxProps, styled } from "@mui/material";
import { Text } from "@common/Text";
import { ITextProps } from "@common/Text/Text";
import { CHARGEBACK_REFUND } from "@constants/constants";
export type TagType =
| "approved"
| "refunded"
| "chargeback"
| "pending"
| "sending"
| "settled"
| "failed"
| "error"
| "successful"
| "sent"
| "canceled"
| "refund pending"
| "declined"
| "voided"
| "authorized"
| "chargeback reversal"
| "requested"
| "ready to process"
| "captured"
| "created"
| "enqueued"
| "closed"
| "processing"
| "processing issue"
| "chargeback refund";
const getColorsMap = (type: TagType, filled: boolean) => {
const colorsMap: Partial<Record<TagType, string>> = {
approved: filled ? palette.warning.light : palette.tag.success.hover,
successful: filled ? palette.warning.light : palette.tag.success.hover,
"chargeback reversal": filled
? palette.warning.light
: palette.tag.success.hover,
refunded: filled ? palette.warning.light : palette.tag.warning.hover,
canceled: filled ? palette.warning.light : palette.neutral[80],
chargeback: filled ? palette.error.light : palette.tag.error.hover,
failed: filled ? palette.error.light : palette.tag.error.hover,
declined: filled ? palette.error.light : palette.tag.error.hover,
error: filled ? palette.error.light : palette.tag.error.hover,
pending: filled ? palette.error.light : palette.neutral[80],
voided: filled ? palette.error.light : palette.neutral[80],
authorized: filled ? palette.error.light : palette.neutral[80],
settled: filled ? palette.error.light : palette.tag.success.hover,
sent: filled ? palette.error.light : palette.tag.success.hover,
sending: filled ? palette.error.light : palette.tag.success.hover,
"refund pending": filled ? palette.error.light : palette.neutral[80],
requested: filled ? palette.error.light : palette.neutral[80],
"ready to process": filled
? palette.warning.light
: palette.tag.warning.hover,
[CHARGEBACK_REFUND]: filled ? palette.error.light : palette.tag.error.hover,
};
return colorsMap[type];
};
interface TransactionTableTagProps extends BoxProps {
type: TagType;
filled?: boolean;
isTextCenter?: boolean;
active?: boolean;
isOriginal?: boolean;
textProps?: ITextProps;
textColor?: string;
bgColor?: string;
}
export const TransactionTableTag = ({
type,
filled = false,
isTextCenter = true,
sx,
active = true,
isOriginal = false,
textProps,
textColor,
bgColor,
...rest
}: TransactionTableTagProps) => {
const color = getColorsMap(type, filled);
return (
<Container
bgColor={bgColor}
active={active}
tagType={type}
sx={sx}
{...rest}
data-testid={`transaction-tab-button-${type}`}
>
<Text
color={active ? (textColor ? textColor : color) : palette.black[100]}
variant="body"
textTransform="capitalize"
width="100%"
textAlign={isTextCenter ? "center" : "left"}
fontSize="12px"
{...textProps}
data-testid={`transaction-tab-${type}`}
>
{type}
{isOriginal ? " (Original Transaction)" : ""}
</Text>
</Container>
);
};
const backgrounds = {
green: palette.tag.success.bg,
orange: palette.tag.warning.bg,
red: palette.tag.error.bg,
gray: palette.neutral[10],
};
const { green, orange, red, gray } = backgrounds;
const bgMap: Record<TagType, string> = {
approved: green,
successful: green,
"chargeback reversal": green,
settled: green,
sent: green,
sending: green,
refunded: orange,
canceled: gray,
"ready to process": orange,
declined: red,
chargeback: red,
failed: red,
error: red,
pending: gray,
voided: gray,
authorized: gray,
"refund pending": gray,
requested: gray,
[CHARGEBACK_REFUND]: red,
captured: gray,
created: gray,
enqueued: gray,
closed: gray,
processing: gray,
"processing issue": red,
};
const Container = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "active" && prop !== "bgColor" && prop !== "tagType",
})<{ active?: boolean; bgColor?: string; tagType: TagType }>(
({ active, bgColor, tagType }) => ({
gap: "2px",
display: "flex",
borderRadius: "4px",
width: "100%",
alignItems: "center",
padding: "2px 8px",
maxWidth: "160px",
userSelect: "none",
backgroundColor: active ? (bgColor ? bgColor : bgMap[tagType]) : "#EBEBEB",
cursor: active ? "default" : "pointer",
transition: "all 1s ease-in-out",
}),
);
|