Switch confirmation buttons to the new modal
This commit is contained in:
parent
94b7ebe5e8
commit
80728ff4f9
|
@ -1,4 +1,8 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { Col } from './layout/col'
|
||||||
|
import { Modal } from './layout/modal'
|
||||||
|
import { Row } from './layout/row'
|
||||||
|
|
||||||
export function ConfirmationButton(props: {
|
export function ConfirmationButton(props: {
|
||||||
id: string
|
id: string
|
||||||
|
@ -20,34 +24,35 @@ export function ConfirmationButton(props: {
|
||||||
}) {
|
}) {
|
||||||
const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props
|
const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<label
|
<Modal open={open} setOpen={setOpen}>
|
||||||
htmlFor={id}
|
<Col className="gap-4 rounded-md bg-white px-8 py-6">
|
||||||
className={clsx('btn modal-button', openModalBtn.className)}
|
|
||||||
>
|
|
||||||
{openModalBtn.icon} {openModalBtn.label}
|
|
||||||
</label>
|
|
||||||
<input type="checkbox" id={id} className="modal-toggle" />
|
|
||||||
|
|
||||||
<div className="modal">
|
|
||||||
<div className="modal-box whitespace-normal">
|
|
||||||
{children}
|
{children}
|
||||||
|
<Row className="gap-4">
|
||||||
<div className="modal-action">
|
<button
|
||||||
<label htmlFor={id} className={clsx('btn', cancelBtn?.className)}>
|
className={clsx('btn', cancelBtn?.className)}
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
>
|
||||||
{cancelBtn?.label ?? 'Cancel'}
|
{cancelBtn?.label ?? 'Cancel'}
|
||||||
</label>
|
</button>
|
||||||
<label
|
<button
|
||||||
htmlFor={id}
|
|
||||||
className={clsx('btn', submitBtn?.className)}
|
className={clsx('btn', submitBtn?.className)}
|
||||||
onClick={onSubmit}
|
onClick={onSubmit}
|
||||||
>
|
>
|
||||||
{submitBtn?.label ?? 'Submit'}
|
{submitBtn?.label ?? 'Submit'}
|
||||||
</label>
|
</button>
|
||||||
</div>
|
</Row>
|
||||||
</div>
|
</Col>
|
||||||
</div>
|
</Modal>
|
||||||
|
<button
|
||||||
|
className={clsx('btn', openModalBtn.className)}
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
>
|
||||||
|
{openModalBtn.label}
|
||||||
|
</button>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user