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 | 19x 6x 6x 19x | import { Text } from "@common/Text";
import { Box, Stack, styled } from "@mui/material";
import { palette } from "@palette";
import { IInputProps } from "react-dropzone-uploader";
import { IdentificationCard } from "@assets/icons/RebrandedIcons";
import { UploaderState } from "@components/Merchants/MerchantPreview/components/PrimaryAccountHolder/PAHUploaderMachine";
import PAHUploaderActions from "@components/Merchants/MerchantPreview/components/PrimaryAccountHolder/PAHUploaderActions";
import { showMessage } from "@common/Toast";
type Props = IInputProps & {
state: UploaderState;
fileUrl: string;
fileName?: string;
isMobile?: boolean;
downloadHandler: () => Promise<void>;
deleteDocument: () => void;
previewDocument: () => void;
disabled?: boolean;
};
export const BusinessOwnerIDInput = ({
accept,
fileUrl,
isMobile,
getFilesFromEvent,
state,
disabled,
onFiles,
downloadHandler,
deleteDocument,
previewDocument,
}: Props) => {
const onClick = () => {
if (disabled) return;
return previewDocument();
};
return (
<Stack
height="100%"
width="100%"
alignItems="center"
justifyContent="center"
onClick={state === UploaderState.ON_UPLOADED ? onClick : undefined}
sx={{
height: "100%",
borderRadius: "12px",
pointerEvents: "initial",
".pah-uploader-actions": {
opacity: 1,
},
}}
>
<Stack
height="100%"
width="100%"
component="label"
alignItems="center"
justifyContent="center"
sx={{
cursor: "pointer",
}}
>
{state === UploaderState.ON_UPLOADED && (
<PAHUploaderActions
disabled={{
delete: disabled,
preview: false,
download: false,
}}
shouldShowTooltip={false}
type={"businessOwnerID"}
downloadHandler={downloadHandler}
deleteDocument={deleteDocument}
previewDocument={() => previewDocument()}
/>
)}
<StyledContainer>
<Stack spacing={0.5} justifyContent="center" alignItems="center">
{state !== UploaderState.ON_UPLOADED && (
<>
<IdentificationCard fill={palette.neutral[70]} />
<Text color={palette.neutral[70]}>Business Owner ID </Text>
</>
)}
{state === UploaderState.ON_INITIAL && (
<Stack direction="row" gap="4px">
{!isMobile && (
<Text color={palette.neutral[70]} fontSize="12px">
Drag and drop your files or
</Text>
)}
<Text color="accent.3" fontSize="12px">
{!isMobile ? "Click to browse" : "Tap to browse"}
</Text>
</Stack>
)}
</Stack>
</StyledContainer>
{state !== UploaderState.ON_UPLOADED && (
<input
disabled={
Boolean(fileUrl) || state !== UploaderState.ON_INITIAL || disabled
}
type="file"
id="upload"
accept={accept}
style={{ display: "none" }}
onChange={async (e) => {
const chosenFiles = await getFilesFromEvent(e);
const validatedFiles = chosenFiles.filter(
(file) => file.name.length < 254,
);
if (validatedFiles.length < chosenFiles.length) {
showMessage("Error", "File name too long");
}
if (validatedFiles.length > 0) {
onFiles(validatedFiles);
}
(e.target as any).value = null;
}}
data-testid="bo-id-upload-input"
/>
)}
</Stack>
</Stack>
);
};
const StyledContainer = styled(Box)({
textAlign: "center",
});
|