um-react/src/components/ImportSecretModal.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-06-17 01:45:31 +00:00
import {
Center,
Flex,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalHeader,
ModalOverlay,
Tabs,
Text,
} from '@chakra-ui/react';
import { FileInput } from '~/components/FileInput';
export interface ImportSecretModalProps {
clientName?: React.ReactNode;
children: React.ReactNode;
show: boolean;
onClose: () => void;
onImport: (file: File) => void;
}
export function ImportSecretModal({ clientName, children, show, onClose, onImport }: ImportSecretModalProps) {
const handleFileReceived = (files: File[]) => onImport(files[0]);
return (
<Modal isOpen={show} onClose={onClose} closeOnOverlayClick={false} scrollBehavior="inside" size="xl">
<ModalOverlay />
<ModalContent>
<ModalHeader></ModalHeader>
<ModalCloseButton />
<Flex as={ModalBody} gap={2} flexDir="column" flex={1}>
<Center>
<FileInput onReceiveFiles={handleFileReceived}></FileInput>
</Center>
<Text mt={2}>{clientName && <>{clientName}</>}</Text>
<Flex as={Tabs} variant="enclosed" flexDir="column" flex={1} minH={0}>
{children}
</Flex>
</Flex>
</ModalContent>
</Modal>
);
}