import React from "react";
import { ModModalConfirmationProps, ModModalFormProps } from "./TModal";
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogOverlay,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Divider } from "@nextui-org/react";

class ModModalForm extends React.Component<ModModalFormProps> {
  constructor(props: ModModalFormProps) {
    super(props);
  }

  render(): React.ReactNode {
    return (
      <AlertDialog>
        <AlertDialogTrigger asChild>
          <Button>{this.props.triggerButton}</Button>
        </AlertDialogTrigger>
        <AlertDialogContent>
          <AlertDialogHeader>
            <AlertDialogTitle>{this.props.heading}</AlertDialogTitle>
            <AlertDialogDescription>
              {this.props.content}

              <Divider className="mt-2 mb-2"></Divider>

              {this.props.inputs.map((input, index) => {
                // TODO: Change this to something other than a react node. Won't work with state.
                return (
                  <div key={index} className="m-1">
                    {input}
                  </div>
                );
              })}
            </AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter>
            <AlertDialogCancel>
              {this.props.cancelButton.content}
            </AlertDialogCancel>
            <AlertDialogAction style={{ backgroundColor: "green" }}>
              {this.props.actionButton.content}
            </AlertDialogAction>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
    );
  }
}

export { ModModalForm };
