mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 05:41:33 +02:00
19b38340ac
* Convert OLModal to named exports only
* Make closeButton the default for OLModalHeader
* Set `closeButton={false}` for modal that is not dismissible
* Fix duplicated imports
* Remove another unnecessary `closeButton` prop
* Fix import
---------
Co-authored-by: Antoine Clausse <antoine.clausse@overleaf.com>
GitOrigin-RevId: ddd7be6e59a966ac634683d2494d6e9d2c3732e6
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { memo } from 'react'
|
|
import {
|
|
OLModal,
|
|
OLModalBody,
|
|
OLModalFooter,
|
|
OLModalHeader,
|
|
OLModalTitle,
|
|
} from '@/shared/components/ol/ol-modal'
|
|
import OLButton from '@/shared/components/ol/ol-button'
|
|
import { ButtonProps } from '@/shared/components/types/button-props'
|
|
|
|
export type GenericConfirmModalOwnProps = {
|
|
title: string
|
|
message: string
|
|
onConfirm: () => void
|
|
confirmLabel?: string
|
|
primaryVariant?: ButtonProps['variant']
|
|
}
|
|
|
|
type GenericConfirmModalProps = React.ComponentProps<typeof OLModal> &
|
|
GenericConfirmModalOwnProps
|
|
|
|
function GenericConfirmModal({
|
|
title,
|
|
message,
|
|
confirmLabel,
|
|
primaryVariant = 'primary',
|
|
onConfirm,
|
|
...modalProps
|
|
}: GenericConfirmModalProps) {
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
|
<OLModal {...modalProps}>
|
|
<OLModalHeader>
|
|
<OLModalTitle>{title}</OLModalTitle>
|
|
</OLModalHeader>
|
|
|
|
<OLModalBody className="modal-generic-confirm">{message}</OLModalBody>
|
|
|
|
<OLModalFooter>
|
|
<OLButton variant="secondary" onClick={() => modalProps.onHide()}>
|
|
{t('cancel')}
|
|
</OLButton>
|
|
<OLButton variant={primaryVariant} onClick={onConfirm}>
|
|
{confirmLabel || t('ok')}
|
|
</OLButton>
|
|
</OLModalFooter>
|
|
</OLModal>
|
|
)
|
|
}
|
|
|
|
export default memo(GenericConfirmModal)
|