import {
  Button,
  Drawer,
  DrawerBody,
  DrawerCloseButton,
  DrawerContent,
  DrawerFooter,
  DrawerHeader,
  FormControl,
  FormLabel,
  Input,
  Text,
  Box,
} from "@chakra-ui/react";
import React, { useContext } from "react";
import GlobalStateContext from "../../../Contexts/GlobalStateContext";

const InvestmentView = ({ isOpen, onClose, secondField, id }) => {
    const { create, setCreate } = useContext(GlobalStateContext);
    const filteredObject = create?.find((item) => item?.id === id)
  return (
    <Drawer
    size={"md"}
      isOpen={isOpen}
      placement="right"
      onClose={onClose}
      initialFocusRef={secondField}
    >
      <DrawerContent>
        <DrawerCloseButton />
        <DrawerHeader fontSize={'md'}>View Document</DrawerHeader>
        <DrawerBody>
            <>
              <FormControl mb={4}>
                <FormLabel fontSize="sm">File Name</FormLabel>
                <Text
                  fontSize="sm"
                  type="text"
                  size="sm"
                >{filteredObject?.fileName}</Text>
              </FormControl>
              <FormControl mb={4}>
                <FormLabel fontSize="sm">Document</FormLabel>
                <Text
                  fontSize="sm"
                  type="text"
                  size="sm"
                >{filteredObject?.document}</Text>
              </FormControl>
              <FormControl mb={4}>
                <FormLabel fontSize="sm">Type</FormLabel>
                <Text
                  fontSize="xl"
                  type="text"
                  size="sm"
                >{filteredObject?.Type}</Text>
              </FormControl>
            </>
        </DrawerBody>
        <DrawerFooter>
          <Button
            variant="outline"
            colorScheme="forestGreen"
            rounded="sm"
            size="sm"
            mr={3}
            onClick={onClose}
          >
            Cancel
          </Button>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  );
};

export default InvestmentView;
