cb5adfe031
* fix: swap error caused by invalid id and batchcount * fix: enhance creation messages for admin drive and user drives * fix: identity and wallet creation * fix: asset preview types * fix: fm search unicode text * fix: feed identity and stamp usage * fix: ui display changes * fix: stamp buy and dilute * fix: vite polyfill warning for stream * fix: standard mode postage stamp purchase reserves incorrect size and duration * fix: add syncing message for Bee node and update page state handling * refactor: stamp depth and amount validation --------- Co-authored-by: Balint Ujvari <balint.ujvari@solarpunk.buzz> Co-authored-by: Bálint Ujvári <58116288+bosi95@users.noreply.github.com> Co-authored-by: rolandlor <33499567+rolandlor@users.noreply.github.com>
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import React, { ReactElement, useLayoutEffect, useState } from 'react'
|
|
import { createPortal } from 'react-dom'
|
|
|
|
import { Button } from '../Button/Button'
|
|
|
|
import '../../styles/global.scss'
|
|
import './ConfirmModal.scss'
|
|
|
|
interface ConfirmModalProps {
|
|
title?: React.ReactNode
|
|
message?: React.ReactNode
|
|
confirmLabel?: string
|
|
cancelLabel?: string
|
|
onConfirm?: () => void | Promise<void>
|
|
onCancel?: () => void
|
|
showFooter?: boolean
|
|
isProgress?: boolean
|
|
spinnerMessage?: React.ReactNode
|
|
showMinimize?: boolean
|
|
onMinimize?: () => void
|
|
background?: boolean
|
|
}
|
|
|
|
export function ConfirmModal({
|
|
title = 'Are you sure?',
|
|
message,
|
|
confirmLabel = 'Confirm',
|
|
cancelLabel = 'Cancel',
|
|
onConfirm,
|
|
onCancel,
|
|
showFooter = true,
|
|
isProgress = false,
|
|
spinnerMessage,
|
|
showMinimize = true,
|
|
onMinimize,
|
|
background = true,
|
|
}: ConfirmModalProps): ReactElement {
|
|
const [modalRoot, setModalRoot] = useState<Element>(() => document.querySelector('.fm-main') || document.body)
|
|
|
|
useLayoutEffect(() => {
|
|
setModalRoot(document.querySelector('.fm-main') || document.body)
|
|
}, [])
|
|
|
|
return createPortal(
|
|
<div className={`fm-modal-container fm-confirm-modal ${background ? '' : 'fm-modal-no-background'}`}>
|
|
<div className="fm-modal-window">
|
|
<div className="fm-modal-window-header">{title}</div>
|
|
<div className="fm-modal-window-scrollable">
|
|
<div className="fm-modal-window-body">
|
|
{isProgress ? (
|
|
<div className="fm-spinner-center">
|
|
<div className="fm-spinner-message">
|
|
<div>{spinnerMessage || 'Working…'}</div>
|
|
<div className="fm-mini-spinner" />
|
|
</div>
|
|
{showMinimize && <Button label="Minimize" variant="secondary" onClick={onMinimize} />}
|
|
</div>
|
|
) : (
|
|
<div className="fm-modal-white-section">{message}</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{showFooter && (onCancel || onConfirm) && (
|
|
<div className="fm-modal-window-footer">
|
|
{onCancel && <Button label={cancelLabel} variant="secondary" onClick={onCancel} />}
|
|
{onConfirm && <Button label={confirmLabel} variant="primary" onClick={() => onConfirm()} />}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>,
|
|
modalRoot,
|
|
)
|
|
}
|