fix header text

This commit is contained in:
SrGooglo 2025-03-06 03:51:28 +00:00
parent 34123d6d0c
commit a25a82e333

View File

@ -5,112 +5,115 @@ import { Button } from "antd"
import useLayoutInterface from "@hooks/useLayoutInterface" import useLayoutInterface from "@hooks/useLayoutInterface"
function ConfirmModal(props) { function ConfirmModal(props) {
const [loading, setLoading] = React.useState(false) const [loading, setLoading] = React.useState(false)
async function close({ confirm } = {}) { async function close({ confirm } = {}) {
props.close() props.close()
if (typeof props.onClose === "function") { if (typeof props.onClose === "function") {
props.onClose() props.onClose()
} }
if (confirm === true) { if (confirm === true) {
if (typeof props.onConfirm === "function") { if (typeof props.onConfirm === "function") {
if (props.onConfirm.constructor.name === "AsyncFunction") { if (props.onConfirm.constructor.name === "AsyncFunction") {
setLoading(true) setLoading(true)
} }
await props.onConfirm() await props.onConfirm()
setLoading(false) setLoading(false)
} }
} else { } else {
if (typeof props.onCancel === "function") { if (typeof props.onCancel === "function") {
props.onCancel() props.onCancel()
} }
} }
} }
return <div className="drawer_close_confirm"> return (
<div className="drawer_close_confirm_content"> <div className="drawer_close_confirm">
<h1>{props.headerText ?? "Are you sure?"} Are you sure?</h1> <div className="drawer_close_confirm_content">
<h1>{props.headerText ?? "Are you sure?"}</h1>
{ {props.descriptionText && <p>{props.descriptionText}</p>}
props.descriptionText && <p>{props.descriptionText}</p> </div>
}
</div>
<div className="drawer_close_confirm_actions"> <div className="drawer_close_confirm_actions">
<Button <Button
onClick={() => close({ confirm: false })} onClick={() => close({ confirm: false })}
disabled={loading} disabled={loading}
> >
Cancel Cancel
</Button> </Button>
<Button <Button
onClick={() => close({ confirm: true })} onClick={() => close({ confirm: true })}
disabled={loading} disabled={loading}
loading={loading} loading={loading}
> >
Yes Yes
</Button> </Button>
</div> </div>
</div> </div>
)
} }
export default () => { export default () => {
function confirm(options = {}) { function confirm(options = {}) {
open("confirm", ConfirmModal, { open("confirm", ConfirmModal, {
props: { props: {
onConfirm: options.onConfirm, onConfirm: options.onConfirm,
onCancel: options.onCancel, onCancel: options.onCancel,
onClose: options.onClose, onClose: options.onClose,
headerText: options.headerText, headerText: options.headerText,
descriptionText: options.descriptionText, descriptionText: options.descriptionText,
} },
}) })
} }
function open( function open(
id, id,
render, render,
{ {
framed = true, framed = true,
confirmOnOutsideClick = false, confirmOnOutsideClick = false,
confirmOnClickTitle, confirmOnClickTitle,
confirmOnClickContent, confirmOnClickContent,
className, className,
props, props,
} = {} } = {},
) { ) {
app.cores.window_mng.render(id, <Modal app.cores.window_mng.render(
onClose={() => { id,
app.cores.window_mng.close(id) <Modal
}} onClose={() => {
framed={framed} app.cores.window_mng.close(id)
className={className} }}
confirmOnOutsideClick={confirmOnOutsideClick} framed={framed}
confirmOnClickTitle={confirmOnClickTitle} className={className}
confirmOnClickContent={confirmOnClickContent} confirmOnOutsideClick={confirmOnOutsideClick}
> confirmOnClickTitle={confirmOnClickTitle}
{ confirmOnClickContent={confirmOnClickContent}
React.isValidElement(render) ? React.cloneElement(render, props) : React.createElement(render, props) >
} {React.isValidElement(render)
</Modal>) ? React.cloneElement(render, props)
} : React.createElement(render, props)}
</Modal>,
)
}
function close(id) { function close(id) {
app.cores.window_mng.close(id) app.cores.window_mng.close(id)
} }
useLayoutInterface("modal", { useLayoutInterface("modal", {
open: open, open: open,
close: close, close: close,
confirm: confirm, confirm: confirm,
}) })
return null return null
} }