2021-12-14 00:47:43 +00:00
|
|
|
import clsx from 'clsx'
|
2022-05-25 15:22:12 +00:00
|
|
|
import { ReactNode, useState } from 'react'
|
2022-03-31 09:09:08 +00:00
|
|
|
import { Col } from './layout/col'
|
|
|
|
import { Modal } from './layout/modal'
|
|
|
|
import { Row } from './layout/row'
|
2021-12-14 00:47:43 +00:00
|
|
|
|
2021-12-15 18:44:34 +00:00
|
|
|
export function ConfirmationButton(props: {
|
2021-12-14 00:47:43 +00:00
|
|
|
id: string
|
2022-03-31 08:38:57 +00:00
|
|
|
openModalBtn: {
|
2021-12-14 00:47:43 +00:00
|
|
|
label: string
|
2022-02-01 20:10:40 +00:00
|
|
|
icon?: any
|
2021-12-14 00:47:43 +00:00
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
cancelBtn?: {
|
|
|
|
label?: string
|
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
submitBtn?: {
|
|
|
|
label?: string
|
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
onSubmit: () => void
|
2022-05-25 15:22:12 +00:00
|
|
|
children: ReactNode
|
2021-12-14 00:47:43 +00:00
|
|
|
}) {
|
2022-03-31 08:38:57 +00:00
|
|
|
const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props
|
2021-12-14 00:47:43 +00:00
|
|
|
|
2022-03-31 09:09:08 +00:00
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
|
2021-12-14 00:47:43 +00:00
|
|
|
return (
|
|
|
|
<>
|
2022-03-31 09:09:08 +00:00
|
|
|
<Modal open={open} setOpen={setOpen}>
|
|
|
|
<Col className="gap-4 rounded-md bg-white px-8 py-6">
|
2021-12-14 00:47:43 +00:00
|
|
|
{children}
|
2022-03-31 09:09:08 +00:00
|
|
|
<Row className="gap-4">
|
|
|
|
<button
|
|
|
|
className={clsx('btn', cancelBtn?.className)}
|
|
|
|
onClick={() => setOpen(false)}
|
|
|
|
>
|
2021-12-14 00:47:43 +00:00
|
|
|
{cancelBtn?.label ?? 'Cancel'}
|
2022-03-31 09:09:08 +00:00
|
|
|
</button>
|
|
|
|
<button
|
2021-12-14 00:47:43 +00:00
|
|
|
className={clsx('btn', submitBtn?.className)}
|
|
|
|
onClick={onSubmit}
|
|
|
|
>
|
|
|
|
{submitBtn?.label ?? 'Submit'}
|
2022-03-31 09:09:08 +00:00
|
|
|
</button>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
</Modal>
|
|
|
|
<button
|
|
|
|
className={clsx('btn', openModalBtn.className)}
|
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
>
|
|
|
|
{openModalBtn.label}
|
|
|
|
</button>
|
2021-12-14 00:47:43 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2022-02-17 23:00:19 +00:00
|
|
|
|
|
|
|
export function ResolveConfirmationButton(props: {
|
|
|
|
onResolve: () => void
|
|
|
|
isSubmitting: boolean
|
2022-03-31 08:38:57 +00:00
|
|
|
openModalButtonClass?: string
|
2022-02-17 23:00:19 +00:00
|
|
|
submitButtonClass?: string
|
|
|
|
}) {
|
2022-03-31 08:38:57 +00:00
|
|
|
const { onResolve, isSubmitting, openModalButtonClass, submitButtonClass } =
|
2022-02-17 23:00:19 +00:00
|
|
|
props
|
|
|
|
return (
|
|
|
|
<ConfirmationButton
|
|
|
|
id="resolution-modal"
|
2022-03-31 08:38:57 +00:00
|
|
|
openModalBtn={{
|
2022-02-17 23:00:19 +00:00
|
|
|
className: clsx(
|
|
|
|
'border-none self-start',
|
2022-03-31 08:38:57 +00:00
|
|
|
openModalButtonClass,
|
2022-02-17 23:00:19 +00:00
|
|
|
isSubmitting && 'btn-disabled loading'
|
|
|
|
),
|
|
|
|
label: 'Resolve',
|
|
|
|
}}
|
|
|
|
cancelBtn={{
|
|
|
|
label: 'Back',
|
|
|
|
}}
|
|
|
|
submitBtn={{
|
|
|
|
label: 'Resolve',
|
|
|
|
className: clsx('border-none', submitButtonClass),
|
|
|
|
}}
|
|
|
|
onSubmit={onResolve}
|
|
|
|
>
|
|
|
|
<p>Are you sure you want to resolve this market?</p>
|
|
|
|
</ConfirmationButton>
|
|
|
|
)
|
|
|
|
}
|