import { Modal, ModalBody, ModalContent, ModalHeader } from "@nextui-org/react";

import PFRSamLogo from "@/components/common/sprites/pfr-sam-logo-sprite";

type SubmitSurveyModalProps = {
  isOpen: boolean;
  oppTitle: string;
  hasError: boolean;
  onClose: () => void;
};

function SubmitSurveyModal({
  isOpen,
  oppTitle,
  hasError,
  onClose,
}: SubmitSurveyModalProps) {
  return (
    <Modal
      isKeyboardDismissDisabled
      backdrop="blur"
      isDismissable={false}
      isOpen={isOpen}
      size="lg"
      onClose={onClose}
    >
      <ModalContent className="p-4 flex flex-col items-center">
        <ModalHeader>
          <h4 className="inline-flex font-inter items-center font-black text-xl tracking-tight">
            Survey submission: {oppTitle}
          </h4>
        </ModalHeader>
        {!hasError && (
          <ModalBody className="flex flex-col items-center justify-center text-center">
            <PFRSamLogo animate width={50} />
            Your survey is being submitted. Do not close this window. Please
            wait...
          </ModalBody>
        )}
        {hasError && (
          <ModalBody className="flex flex-col items-center justify-center text-center">
            An error occurred while submitting your survey. Please close this
            window and try to submit the survey again.
          </ModalBody>
        )}
      </ModalContent>
    </Modal>
  );
}

export default SubmitSurveyModal;
