mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-31 15:54:24 +00:00
feat(modal): Use server to pass event handler
This commit is contained in:
1 parent
8388aad831
commit
1c5859d93c
5 files changed
+75
-9
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
export * from "./ui/header/Header";
|
||||
export * from "./ui/modal/Modal";
|
||||
export * from "./ui/modal";
|
||||
export * from "./ui/sidebar";
|
||||
export * from "./ui/table/CustomTable";
|
||||
@@ -10,12 +10,12 @@ import React from "react";
|
||||
|
||||
interface ModalProps {
|
||||
title: string;
|
||||
isOpen: boolean;
|
||||
onOpenChange: (isOpen: boolean) => void;
|
||||
body: React.ReactNode;
|
||||
onCloseText?: string;
|
||||
closeText?: string;
|
||||
actionText?: string;
|
||||
onAction?: () => void;
|
||||
isOpen: boolean;
|
||||
onOpenChange: (isOpen: boolean) => void;
|
||||
isDismissable?: boolean;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ export const Modal: React.FC<ModalProps> = ({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
body,
|
||||
onCloseText = "Close",
|
||||
actionText = "Save",
|
||||
closeText,
|
||||
actionText,
|
||||
onAction,
|
||||
isDismissable = true,
|
||||
isDismissable,
|
||||
}) => {
|
||||
const hasActionButton = actionText && onAction;
|
||||
|
||||
@@ -48,7 +48,7 @@ export const Modal: React.FC<ModalProps> = ({
|
||||
<ModalBody>{body}</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="danger" variant="light" onPress={onClose}>
|
||||
{onCloseText && onCloseText}
|
||||
{closeText && closeText}
|
||||
</Button>
|
||||
{hasActionButton && (
|
||||
<Button color="primary" onPress={onAction}>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { Button, useDisclosure } from "@nextui-org/react";
|
||||
import React from "react";
|
||||
|
||||
import { Modal } from "@/components";
|
||||
|
||||
interface ModalWrapProps {
|
||||
title: string;
|
||||
body: React.ReactNode;
|
||||
closeText?: string;
|
||||
actionText?: string;
|
||||
onAction?: () => void;
|
||||
triggerText?: string;
|
||||
isDismissable?: boolean;
|
||||
}
|
||||
|
||||
export const ModalWrap: React.FC<ModalWrapProps> = ({
|
||||
title,
|
||||
body,
|
||||
closeText = "Close",
|
||||
actionText = "Save",
|
||||
onAction,
|
||||
isDismissable = true,
|
||||
triggerText = "Open",
|
||||
}) => {
|
||||
const { isOpen, onOpen, onClose, onOpenChange } = useDisclosure();
|
||||
const closeOnAction = () => {
|
||||
onAction && onAction();
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button onPress={onOpen}>{triggerText}</Button>
|
||||
<Modal
|
||||
title={title}
|
||||
body={body}
|
||||
closeText={closeText}
|
||||
actionText={actionText}
|
||||
onAction={closeOnAction}
|
||||
isDismissable={isDismissable}
|
||||
isOpen={isOpen}
|
||||
onOpenChange={onOpenChange}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./Modal";
|
||||
export * from "./ModalWrap";
|
||||
Reference in new issue
Block a user