File size: 1,773 Bytes
246d201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
  Modal,
  ModalBody,
  ModalContent,
  ModalFooter,
  ModalHeader,
} from "@nextui-org/react";
import React from "react";
import { Action, FooterContent } from "./footer-content";
import { HeaderContent } from "./header-content";

interface BaseModalProps {
  isOpen: boolean;
  onOpenChange: (isOpen: boolean) => void;
  title: string;
  contentClassName?: string;
  bodyClassName?: string;
  isDismissable?: boolean;
  subtitle?: string;
  actions?: Action[];
  children?: React.ReactNode;
  testID?: string;
}

export function BaseModal({

  isOpen,

  onOpenChange,

  title,

  contentClassName = "max-w-[30rem] p-[40px]",

  bodyClassName = "px-0 py-[20px]",

  isDismissable = true,

  subtitle = undefined,

  actions = [],

  children = null,

  testID,

}: BaseModalProps) {
  return (
    <Modal

      data-testid={testID}

      isOpen={isOpen}

      onOpenChange={onOpenChange}

      isDismissable={isDismissable}

      backdrop="blur"

      hideCloseButton

      size="sm"

      className="bg-neutral-900 rounded-lg"

    >

      <ModalContent className={contentClassName}>

        {(closeModal) => (

          <>

            {title && (

              <ModalHeader className="flex flex-col p-0">

                <HeaderContent maintitle={title} subtitle={subtitle} />

              </ModalHeader>

            )}



            <ModalBody className={bodyClassName}>{children}</ModalBody>



            {actions && actions.length > 0 && (

              <ModalFooter className="flex-row flex justify-start p-0">

                <FooterContent actions={actions} closeModal={closeModal} />

              </ModalFooter>

            )}

          </>

        )}

      </ModalContent>
    </Modal>
  );
}