mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-15 17:40:58 -05:00
8a90ffa3fb
* Add showGenericConfirmModal in ModalsContext * Add confirm modal on accept/reject selected changes * plural in translations * change tooltip to include selected changes * add _plural to all translated languages * lowercase title/tooltip * count replacements as single change * use new translation key GitOrigin-RevId: afadbe1eeb2a290688b96f2b5388485f40c958d0
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { memo } from 'react'
|
|
import OLModal, {
|
|
OLModalBody,
|
|
OLModalFooter,
|
|
OLModalHeader,
|
|
OLModalTitle,
|
|
} from '@/features/ui/components/ol/ol-modal'
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
import { ButtonProps } from '@/features/ui/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',
|
|
...modalProps
|
|
}: GenericConfirmModalProps) {
|
|
const { t } = useTranslation()
|
|
const handleConfirmClick = modalProps.onConfirm
|
|
|
|
return (
|
|
<OLModal {...modalProps}>
|
|
<OLModalHeader closeButton>
|
|
<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={handleConfirmClick}>
|
|
{confirmLabel || t('ok')}
|
|
</OLButton>
|
|
</OLModalFooter>
|
|
</OLModal>
|
|
)
|
|
}
|
|
|
|
export default memo(GenericConfirmModal)
|