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 | 2x 2x 18x 18x 18x 18x 18x 18x 18x 2x 58x 14x 18x | import { TagType } from "@common/Tag";
import { Stack } from "@mui/material";
import { styled } from "@theme/v2/Provider";
import { useAppTheme } from "@theme/v2/Provider";
import GiveText from "@shared/Text/GiveText";
import { CustomPalette } from "@theme/v2/palette.interface";
import {
TObject,
TStatus,
} from "@components/Settings/BusinessDetails/components/MerchantInfoSection/types";
type TData = {
status?: string;
statusDisplayName?: TagType;
statusUpdatedAt?: number | null | undefined;
statusUpdatedByName?: string;
statusUpdatedByEmail?: string;
isReadyToApprove?: boolean;
isOnApprovalDelay?: boolean;
onbStateName?: string;
};
type TObjectV2 = TObject & {
border_color?: string;
};
const statusMapping = {
approved: "approved",
declined: "declined",
suspended: "suspended",
ready_for_kyb: "kyb",
// Sponsor and underwriting display the same status
ready_for_review: "under_verification",
ready_for_underwriting: "under_verification",
};
const MerchantStatusV2 = ({
status,
isReadyToApprove,
isOnApprovalDelay,
onbStateName,
}: TData) => {
const isRefused = status === "preapproved_mid_issue";
const isReadyToBeApproved =
isReadyToApprove &&
["has_mid_ready", "preapproved_no_tx", "has_mid_not_ready"].includes(
status || "",
);
const { palette } = useAppTheme();
const statusMap = getStatusMap(palette);
const usedStatusName =
statusMapping[onbStateName as keyof typeof statusMapping];
const statusObj = statusMap[usedStatusName as TStatus];
return (
<Stack
mt={4}
pb={2}
gap={1}
borderBottom={`1px solid ${palette.primitive?.neutral[20]}`}
mx={2}
>
<Stack gap={2} direction={"row"} alignItems={"center"}>
<GiveText color="primary" fontSize="18px">
Account
</GiveText>
{statusObj?.label && (
<Label
color={statusObj?.color}
bgColor={statusObj?.bg_color}
borderColor={statusObj?.border_color}
>
{statusObj?.label}
</Label>
)}
</Stack>
</Stack>
);
};
export default MerchantStatusV2;
const Label = styled(GiveText, {
shouldForwardProp: (prop) =>
prop !== "bgColor" && prop !== "color" && prop !== "borderColor",
})<{ bgColor: string; color: string; borderColor?: string }>(
({ bgColor, color, borderColor }) => ({
textAlign: "center",
borderRadius: "8px",
color: color,
backgroundColor: bgColor,
padding: "4px 8px",
border: `1px solid ${borderColor}`,
fontSize: "12px",
}),
);
const getStatusMap = (palette: CustomPalette): Record<TStatus, TObjectV2> => ({
approved: {
label: "Approved",
color: palette.primitive?.success[100] as string,
bg_color: palette?.primitive?.success[25] as string,
border_color: palette.primitive?.success[50],
},
declined: {
label: "Declined",
color: palette.primitive?.error[100] as string,
bg_color: palette.primitive?.error[25] as string,
border_color: palette.primitive?.error[50],
},
suspended: {
label: "Suspended",
color: palette.primitive?.warning[100] as string,
bg_color: palette.primitive?.warning[10] as string,
border_color: palette.primitive?.warning[50],
},
under_verification: {
label: "Under Verification",
color: palette.primitive?.blue["100"] as string,
bg_color: palette.primitive?.blue["10"] as string,
border_color: palette.primitive?.blue["50"],
},
ready_verification: {
label: "Ready for Verification",
color: palette.primitive?.blue["100"] as string,
bg_color: palette.primitive?.blue["10"] as string,
border_color: palette.primitive?.blue["50"],
},
onboarding: {
label: "Incomplete",
color: palette.text.primary,
bg_color: palette.surface?.tertiary as string,
border_color: palette.text.primary,
},
kyb: {
label: "Waiting for verification",
color: palette.primitive?.warning[100] as string,
bg_color: palette.primitive?.warning[10] as string,
border_color: palette.primitive?.warning[50] as string,
},
});
|