chore: remove the old modal component

This commit is contained in:
Pablo Lara
2024-08-07 09:06:38 +02:00
parent d69c35fa3c
commit 3511cd977a
4 changed files with 0 additions and 116 deletions
-1
View File
@@ -1,7 +1,6 @@
export * from "./alert/Alert";
export * from "./dialog/Dialog";
export * from "./header/Header";
export * from "./modal";
export * from "./sidebar";
export * from "./table/StatusBadge";
export * from "./table/Table";
-65
View File
@@ -1,65 +0,0 @@
import {
Button,
Modal as ModalContainer,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
} from "@nextui-org/react";
import React from "react";
interface ModalProps {
modalTitle: string;
modalBody: React.ReactNode;
closeButtonLabel?: string;
actionButtonLabel?: string;
onAction: () => void;
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
isDismissable?: boolean;
isKeyboardDismissDisabled?: boolean;
hideCloseButton?: boolean;
}
export const Modal: React.FC<ModalProps> = ({
modalTitle,
modalBody,
closeButtonLabel,
actionButtonLabel,
onAction,
isOpen,
onOpenChange,
isDismissable,
}) => {
return (
<>
<ModalContainer
isOpen={isOpen}
onOpenChange={onOpenChange}
backdrop="blur"
isDismissable={isDismissable}
isKeyboardDismissDisabled={!isDismissable}
hideCloseButton={!isDismissable}
>
<ModalContent>
{(onClose) => (
<>
<ModalHeader className="flex flex-col gap-1">
{modalTitle}
</ModalHeader>
<ModalBody>{modalBody}</ModalBody>
<ModalFooter>
<Button color="danger" variant="light" onPress={onClose}>
{closeButtonLabel}
</Button>
<Button color="primary" onPress={onAction}>
{actionButtonLabel}
</Button>
</ModalFooter>
</>
)}
</ModalContent>
</ModalContainer>
</>
);
};
-48
View File
@@ -1,48 +0,0 @@
"use client";
import { Button, useDisclosure } from "@nextui-org/react";
import React from "react";
import { Modal } from "@/components/ui";
interface ModalWrapProps {
modalTitle: string;
modalBody: React.ReactNode;
closeButtonLabel?: string;
actionButtonLabel?: string;
onAction: () => void;
openButtonLabel?: string;
isDismissable?: boolean;
}
export const ModalWrap: React.FC<ModalWrapProps> = ({
modalTitle,
modalBody,
closeButtonLabel = "Close",
actionButtonLabel = "Save",
onAction,
openButtonLabel = "Open",
isDismissable = true,
}) => {
const { isOpen, onOpen, onClose, onOpenChange } = useDisclosure();
const closeOnAction = () => {
onAction?.();
onClose();
};
return (
<>
<Button onPress={onOpen}>{openButtonLabel}</Button>
<Modal
modalTitle={modalTitle}
modalBody={modalBody}
closeButtonLabel={closeButtonLabel}
actionButtonLabel={actionButtonLabel}
onAction={closeOnAction}
isDismissable={isDismissable}
isOpen={isOpen}
onOpenChange={onOpenChange}
/>
</>
);
};
-2
View File
@@ -1,2 +0,0 @@
export * from "./Modal";
export * from "./ModalWrap";