import {
  Button,
  Box,
  Dialog,
  DialogActions,
  DialogContent,
  DialogTitle,
  Stack,
  Typography,
  Autocomplete,
  TextField,
  Paper,
} from '@mui/material';
import { ReactElement, useState } from 'react';

import { PropertiesAPI, DocumentAPI, UserAPI, BidAPI } from 'types';
import AttorneyDocumentDialog from './Dialog/AttorneyDocumentDialog';
import PropertyOwnerDocumentDialog from './Dialog/PropertyOwnerDocumentDialog';
import VendorDocumentDialog from './Dialog/VendorDocumentDialog';

export type DocumentDialogProps = {
  showDialog: boolean;
  closeDialog: () => void;
  properties: PropertiesAPI[];
  bids: BidAPI[];
};

type AddDocumentDialogProps = DocumentDialogProps & {
  account: UserAPI;
};

const AddDocumentDialog = ({
  showDialog,
  closeDialog,
  properties,
  bids,
  account,
}: AddDocumentDialogProps): ReactElement => {
  if (account.user_type === 'property_owner') {
    return (
      <PropertyOwnerDocumentDialog
        showDialog={showDialog}
        closeDialog={closeDialog}
        properties={properties}
        bids={bids}
      />
    );
  } else if (account.user_type === 'vendor') {
    return (
      <VendorDocumentDialog
        showDialog={showDialog}
        closeDialog={closeDialog}
        properties={properties}
        bids={bids}
      />
    );
  } else if (account.user_type === 'attorney') {
    return (
      <AttorneyDocumentDialog
        showDialog={showDialog}
        closeDialog={closeDialog}
        properties={properties}
        bids={bids}
      />
    );
  } else {
    return (
      <Dialog open={showDialog} onClose={closeDialog}>
        <Typography>Woops, we have encountered an error</Typography>
      </Dialog>
    );
  }
};

export default AddDocumentDialog;
