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 | 6x 5x 5x 5x 5x 5x 6x 5x 5x | import React from "react";
import { palette } from "@palette";
import { Box, SxProps } from "@mui/material";
import { Text } from "@common/Text";
import useMediaQuery from "@mui/material/useMediaQuery";
import { getColorsMap, getIconMap } from "./colorsMap";
import { TagProps, TagType } from "./types";
export const Tag: React.FC<TagProps> = ({
type,
filled = false,
text,
shouldShowIcon = false,
shouldShowText = false,
}) => {
const isDesktop = useMediaQuery("(min-width: 600px)");
const Icon = getIconMap(type, filled);
const color = getColorsMap(type, filled);
const additionalStyle = getAdditionalStyle(type, filled);
return (
<Box
sx={{
gap: "6px",
display: "flex",
borderRadius: 28,
alignItems: "center",
padding: isDesktop ? "4px 16px 4px 12px" : "4px 12px",
border: `1px solid ${color}`,
...additionalStyle,
}}
>
{(!isDesktop || shouldShowIcon) && Icon}
{(isDesktop || shouldShowText) && (
<Text
color={color}
variant="body"
fontWeight="book"
textTransform="capitalize"
>
{text
? text
: type === "upload"
? "upload bank statement"
: type === "preapproved_mid_issue"
? "Pre Approved MID issue"
: type}
</Text>
)}
</Box>
);
};
export type ExtendedTagType = TagType | "tag";
const getAdditionalStyle = (type: ExtendedTagType, filled: boolean) => {
const styleMap: Record<ExtendedTagType, SxProps> = {
tag: {
gap: "6px",
display: "flex",
borderRadius: 28,
alignItems: "center",
padding: "4px 16px 4px 12px",
boxShadow:
"inset -4px -4px 9px rgba(255, 255, 255, 0.88), inset 0px 2px 14px rgba(193, 208, 238, 0.5)",
...(filled && {
backgroundColor: palette.filled.green,
boxShadow:
"inset -4px -4px 9px rgba(255, 255, 255, 0.88), inset 0px 2px 14px rgba(193, 208, 238, 0.5)",
}),
...(!filled && {
backgroundColor: palette.success.light,
boxShadow:
"inset -4px -4px 9px rgba(255, 255, 255, 0.88), inset 0px 2px 14px rgba(193, 208, 238, 0.5)",
}),
},
approved: !filled
? { backgroundColor: palette.success.light }
: { backgroundColor: palette.filled.green },
"pre approved": !filled
? { backgroundColor: palette.success.light }
: { backgroundColor: palette.filled.green },
preapproved_mid_issue: !filled
? { backgroundColor: palette.success.light }
: { backgroundColor: palette.filled.green },
"processing approved": !filled
? { backgroundColor: palette.success.light }
: { backgroundColor: palette.filled.green },
active: { backgroundColor: palette.success.light },
refunded: !filled
? { backgroundColor: palette.warning.light }
: { backgroundColor: palette.filled.orange },
chargeback: !filled
? { backgroundColor: palette.error.light }
: { backgroundColor: palette.filled.red },
pending: !filled
? {
backgroundColor: palette.neutral[10],
borderColor: palette.neutral[80],
}
: { backgroundColor: palette.filled.grey },
"pending review": !filled
? {
backgroundColor: palette.neutral[10],
borderColor: palette.neutral[80],
}
: { backgroundColor: palette.filled.grey },
review: !filled
? {
backgroundColor: palette.neutral[10],
borderColor: palette.neutral[80],
}
: { backgroundColor: palette.filled.grey },
upload: { backgroundColor: palette.warning.light },
upcoming: { backgroundColor: palette.success.light },
ended: !filled
? { backgroundColor: palette.info.soft }
: { backgroundColor: palette.filled.blue },
expired: { backgroundColor: palette.warning.light },
used: { backgroundColor: "#F8EFFF" },
cancelled: { backgroundColor: palette.error.light },
declined: { backgroundColor: palette.error.light },
test: { backgroundColor: palette.warning.light },
remaining: { backgroundColor: palette.neutral[50] },
completed: { backgroundColor: palette.success.light },
suspended: { backgroundColor: palette.warning.light },
deactivated: { backgroundColor: palette.gray[100] },
"Under Review": {
backgroundColor: "#FFF2E9",
},
update_requested: {},
};
return styleMap[type] || {};
};
|