1e0845f4b9
* Add tsconfig.json for common * Prefer `const` over `let` over `var` * Kill dead code * Fix some trivial Typescript issues * Turn on Typescript linting in common except for no-explicit-any * Correctly specify tsconfig dir name in functions eslintrc * Give react children explicit types * Add explicit types to removeUndefinedProps * Create StripeSession type * Give event in Dropdown an explicit type * Revert "Give event in Dropdown an explicit type" This reverts commit80604310f2
. * Give bids in NewBidTable an explicit type * Cast results of removeUndefinedProps when neccessary * Fix type of JoinSpans * Revert "Cast results of removeUndefinedProps when neccessary" This reverts commit5541617bc8
. * Revert "Add explicit types to removeUndefinedProps" This reverts commitccf8ffb0b5
. * Give React children types everywhere * Give event a type * Give event correct type * Lint * Standardize React import Co-authored-by: Marshall Polaris <marshall@pol.rs>
92 lines
2.2 KiB
TypeScript
92 lines
2.2 KiB
TypeScript
import clsx from 'clsx'
|
|
import { ReactNode, useState } from 'react'
|
|
import { Col } from './layout/col'
|
|
import { Modal } from './layout/modal'
|
|
import { Row } from './layout/row'
|
|
|
|
export function ConfirmationButton(props: {
|
|
id: string
|
|
openModalBtn: {
|
|
label: string
|
|
icon?: any
|
|
className?: string
|
|
}
|
|
cancelBtn?: {
|
|
label?: string
|
|
className?: string
|
|
}
|
|
submitBtn?: {
|
|
label?: string
|
|
className?: string
|
|
}
|
|
onSubmit: () => void
|
|
children: ReactNode
|
|
}) {
|
|
const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props
|
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
return (
|
|
<>
|
|
<Modal open={open} setOpen={setOpen}>
|
|
<Col className="gap-4 rounded-md bg-white px-8 py-6">
|
|
{children}
|
|
<Row className="gap-4">
|
|
<button
|
|
className={clsx('btn', cancelBtn?.className)}
|
|
onClick={() => setOpen(false)}
|
|
>
|
|
{cancelBtn?.label ?? 'Cancel'}
|
|
</button>
|
|
<button
|
|
className={clsx('btn', submitBtn?.className)}
|
|
onClick={onSubmit}
|
|
>
|
|
{submitBtn?.label ?? 'Submit'}
|
|
</button>
|
|
</Row>
|
|
</Col>
|
|
</Modal>
|
|
<button
|
|
className={clsx('btn', openModalBtn.className)}
|
|
onClick={() => setOpen(true)}
|
|
>
|
|
{openModalBtn.label}
|
|
</button>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export function ResolveConfirmationButton(props: {
|
|
onResolve: () => void
|
|
isSubmitting: boolean
|
|
openModalButtonClass?: string
|
|
submitButtonClass?: string
|
|
}) {
|
|
const { onResolve, isSubmitting, openModalButtonClass, submitButtonClass } =
|
|
props
|
|
return (
|
|
<ConfirmationButton
|
|
id="resolution-modal"
|
|
openModalBtn={{
|
|
className: clsx(
|
|
'border-none self-start',
|
|
openModalButtonClass,
|
|
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>
|
|
)
|
|
}
|