Skip to content

Commit

Permalink
reverted to aces/main modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Dec 17, 2024
1 parent 257f039 commit 77dc340
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions jsx/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import {useState, PropsWithChildren, CSSProperties} from 'react';
import {useState, PropsWithChildren, CSSProperties, ReactNode} from 'react';
import Swal from 'sweetalert2';
import Loader from './Loader';
import {
ButtonElement,
FormElement,
} from 'jsx/Form';

type ModalProps = PropsWithChildren<{
export type ModalProps = PropsWithChildren<{
throwWarning?: boolean;
show: boolean;
onClose: () => void;
onSubmit?: () => Promise<any>;
onSuccess?: (data: any) => void;
title?: string;
title?: ReactNode;
}>;

/**
Expand Down Expand Up @@ -87,7 +86,11 @@ const Modal = ({
*/
const submitButton = () => {
if (onSubmit && !(loading || success)) { // Show button if conditions met
return <div style={submitStyle}><ButtonElement/></div>;
return (
<div style={submitStyle}>
<ButtonElement onUserInput={handleSubmit}/>
</div>
);
}
};

Expand Down Expand Up @@ -190,17 +193,6 @@ const Modal = ({
</div>
);

const content = (
<>
<div style={bodyStyle}>{show && children}</div>
<div style={footerStyle}>
{loader}
{successDisplay}
{submitButton()}
</div>
</>
);

return (
<div style={modalContainer} onClick={handleClose}>
<div style={modalContent} onClick={(e) => e.stopPropagation()}>
Expand All @@ -209,11 +201,12 @@ const Modal = ({
<span style={glyphStyle} onClick={handleClose}>×</span>
</div>
<div>
{onSubmit ? (
<FormElement onSubmit={handleSubmit}>
{content}
</FormElement>
) : content}
<div style={bodyStyle}>{show && children}</div>
<div style={footerStyle}>
{loader}
{successDisplay}
{submitButton()}
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 77dc340

Please sign in to comment.