diff --git a/src/components/common/modals/common-modal.tsx b/src/components/common/modals/common-modal.tsx index 842dd3e2c..1db3067eb 100644 --- a/src/components/common/modals/common-modal.tsx +++ b/src/components/common/modals/common-modal.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import React from 'react' +import React, { useMemo } from 'react' import { Modal } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { ForkAwesomeIcon } from '../fork-awesome/fork-awesome-icon' @@ -13,31 +13,40 @@ import { ShowIf } from '../show-if/show-if' import type { PropsWithDataCypressId } from '../../../utils/cypress-attribute' import { cypressId } from '../../../utils/cypress-attribute' -export interface CommonModalProps extends PropsWithDataCypressId { +export interface ModalVisibilityProps { show: boolean onHide?: () => void - titleI18nKey?: string +} + +export interface ModalContentProps { title?: string - closeButton?: boolean - icon?: IconName - size?: 'lg' | 'sm' | 'xl' + titleIsI18nKey?: boolean + showCloseButton?: boolean + titleIcon?: IconName + modalSize?: 'lg' | 'sm' | 'xl' additionalClasses?: string } +export type CommonModalProps = PropsWithDataCypressId & ModalVisibilityProps & ModalContentProps + export const CommonModal: React.FC = ({ show, onHide, - titleI18nKey, title, - closeButton, - icon, + showCloseButton, + titleIcon, additionalClasses, - size, + modalSize, children, + titleIsI18nKey = true, ...props }) => { useTranslation() + const titleElement = useMemo(() => { + return titleIsI18nKey ? : {title} + }, [title, titleIsI18nKey]) + return ( = ({ onHide={onHide} animation={true} dialogClassName={`text-dark ${additionalClasses ?? ''}`} - size={size}> - + size={modalSize}> + - - + +   - {titleI18nKey ? : {title}} + {titleElement} {children} diff --git a/src/components/common/modals/deletion-modal.tsx b/src/components/common/modals/deletion-modal.tsx index e1b14059b..93ba72b64 100644 --- a/src/components/common/modals/deletion-modal.tsx +++ b/src/components/common/modals/deletion-modal.tsx @@ -18,17 +18,17 @@ export interface DeletionModalProps extends CommonModalProps { export const DeletionModal: React.FC = ({ show, onHide, - titleI18nKey, + title, onConfirm, deletionButtonI18nKey, - icon, + titleIcon, children, ...props }) => { useTranslation() return ( - + {children}