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 | 13x 241x 241x 13x 8x 13x 8x 48x 13x 13x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 13x 1x 1x 13x 8x 8x 8x 13x 7x 21x | import { TMerchantDocument } from "@components/Merchants/MerchantPreview/data.types";
import { useGetCurrentMerchantId } from "@hooks/common";
import { Box, Skeleton, Stack, SxProps, Theme } from "@mui/material";
import { TrashIcon, WarningOctagonIcon } from "@phosphor-icons/react";
import GiveAvatar from "@shared/Avatar/GiveAvatar";
import GiveText from "@shared/Text/GiveText";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useAppTheme } from "@theme/v2/Provider";
import { QRCodeSVG } from "qrcode.react";
import { ReactNode } from "react";
import { useQueryClient } from "react-query";
import { infoTextArray } from "../consts";
import GiveTruncateText from "@shared/Text/GiveTruncateText";
import moment from "moment";
import { PLATFORM_TIMEZONE } from "@utils/timezones";
import useDeleteDocument from "@features/Merchants/MerchantSidePanel/GiveMerchantFile/hooks/useDeleteDocument";
import { QKEY_IDENTIFICATION_FILES } from "@constants/queryKeys";
import { checkPortals } from "@utils/routing";
export const PagesContainer = ({
children,
sx,
py = "40px",
testId,
}: {
children: ReactNode;
sx?: SxProps<Theme> | undefined;
py?: string;
testId?: string;
}) => {
const { isMobileView } = useCustomThemeV2();
return (
<Stack
sx={{
...sx,
width: "100%",
padding: isMobileView ? "20px" : `${py} 40px`,
overflowX: "hidden",
}}
gap={"24px"}
data-testid={testId}
>
{children}
</Stack>
);
};
export const CenterIconContainer = ({ children }: { children: ReactNode }) => {
return (
<Stack alignItems="center" width="100%">
{children}
</Stack>
);
};
export const InstructionsList = ({ my = "24px", fontSize = "14px" }) => {
return (
<Box my={my}>
<ul style={{ paddingLeft: "1.25rem", margin: 0 }}>
{instructionsArray.map((instruction) => (
<li key={instruction}>
<GiveText fontWeight={400} fontSize={fontSize}>
{instruction}
</GiveText>
</li>
))}
</ul>
</Box>
);
};
const instructionsArray = [
"Take Picture Holding ID.",
"Use the same ID you uploaded previously.",
"Show the photo side of your ID to the camera.",
"Keep your face clearly visible (no masks, hats, or glasses).",
"Make sure your ID is fully visible and not covered by your fingers.",
"ID must be government-issued and valid.",
];
type Props = {
ownerFiles?: TMerchantDocument[];
userFullName?: string;
onDeleteSuccess?: () => void;
ID?: number;
deleteLocalFile?: (
id: string | number,
name: string,
isExist: boolean,
) => void;
disabled?: boolean;
allowDelete?: boolean;
isLoading?: boolean;
};
export const DocumentSection = ({
ownerFiles,
onDeleteSuccess,
userFullName,
ID,
deleteLocalFile,
disabled,
allowDelete = false,
isLoading,
}: Props) => {
const theme = useAppTheme();
const queryClient = useQueryClient();
const { merchantId } = useGetCurrentMerchantId();
const { deleteDocument } = useDeleteDocument();
const { isMerchantPortal, isEnterprisePortal } = checkPortals();
const usedId = ID ?? merchantId;
const deleteOwnerFile = (doc: TMerchantDocument) => {
if (deleteLocalFile) {
deleteLocalFile(doc.id?.toString(), doc.fileName, doc.isUploaded);
return;
}
deleteDocument(usedId, { fileName: doc.fileName, id: doc.id }, () => {
queryClient.invalidateQueries([QKEY_IDENTIFICATION_FILES, merchantId]);
onDeleteSuccess?.();
});
};
const isHiddenDelete = (doc: TMerchantDocument) => {
return (
((isMerchantPortal || isEnterprisePortal) &&
doc?.isUploaded &&
!allowDelete) ||
disabled
);
};
return (
<Stack gap="20px">
{ownerFiles?.map((item) => (
<Stack
alignItems="center"
flexDirection="row"
justifyContent="space-between"
key={item.fileURL}
>
<Stack gap="12px" alignItems="center" flexDirection="row">
<GiveAvatar size="44px" shape="square" imageUrl={item.fileURL} />
<Box>
<GiveTruncateText fontSize="14px" lineClamp={1}>
{item?.fileName}
</GiveTruncateText>
<Stack gap="8px" alignItems="center" flexDirection="row">
<GiveText fontSize="12px">
by {item?.userFullName || userFullName}
</GiveText>
<GiveText fontSize="12px" color="secondary">
{moment.unix(item.createdAt).tz(PLATFORM_TIMEZONE).format("MMM DD YYYY, HH:mm")}
</GiveText>
</Stack>
</Box>
</Stack>
{!isHiddenDelete(item) && (
<Stack
sx={{
cursor: isLoading ? "default" : "pointer",
}}
onClick={isLoading ? undefined : () => deleteOwnerFile(item)}
>
<TrashIcon
size={20}
fill={theme?.palette?.primitive?.error[50]}
/>
</Stack>
)}
</Stack>
))}
</Stack>
);
};
export const ErrorTextComponent = ({
errorText,
sx,
}: {
errorText: string;
sx?: SxProps<Theme> | undefined;
}) => {
const theme = useAppTheme();
return (
<Stack mb="26px" gap="8px" alignItems="center" flexDirection="row" sx={sx}>
<WarningOctagonIcon fill={theme.palette.primitive?.error[50]} size={24} />
<GiveText fontSize="14px" color="error">
{errorText}
</GiveText>
</Stack>
);
};
export const CustomQRCode = ({
value,
isLoading,
isError,
}: {
value: string;
isLoading: boolean;
isError: boolean;
}) => {
Iif (isError)
return (
<GiveText color="error">
An error occurred while fetching the token.
</GiveText>
);
Iif (isLoading)
return (
<Skeleton
style={{
minHeight: "96px",
minWidth: "96px",
height: "96px",
width: "96px",
}}
/>
);
return (
<QRCodeSVG
style={{
minHeight: "96px",
minWidth: "96px",
height: "96px",
width: "96px",
}}
bgColor="transparent"
value={value}
/>
);
};
export const InfoSection = () => {
return (
<Stack gap="12px">
<GiveText color="warning" fontSize="14px">
Important: To confirm access to your business bank account, please use
your handheld device to take a clear photo of your online banking portal
showing the following details:
</GiveText>
<Box
sx={{ m: 0, p: 0, listStyleType: "disc", pl: "16px" }}
width="100%"
component="ul"
>
{infoTextArray?.map((item) => (
<Box m="0" key={item} component="li">
<GiveText fontSize="14px">{item}</GiveText>
</Box>
))}
</Box>
</Stack>
);
};
|