2026-06-29 07:55:47 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Modal } from './Modal';
|
|
|
|
|
import { Button } from './Button';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
export interface ConfirmDialogProps {
|
|
|
|
|
open: boolean;
|
|
|
|
|
title?: string;
|
|
|
|
|
message: string;
|
|
|
|
|
confirmLabel?: string;
|
|
|
|
|
cancelLabel?: string;
|
|
|
|
|
variant?: 'primary' | 'danger';
|
|
|
|
|
onConfirm: () => void;
|
|
|
|
|
onCancel: () => void;
|
2026-07-19 17:41:39 +02:00
|
|
|
children?: React.ReactNode;
|
2026-06-29 07:55:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ConfirmDialog({
|
|
|
|
|
open,
|
|
|
|
|
title,
|
|
|
|
|
message,
|
|
|
|
|
confirmLabel,
|
|
|
|
|
cancelLabel,
|
|
|
|
|
variant = 'primary',
|
|
|
|
|
onConfirm,
|
|
|
|
|
onCancel,
|
|
|
|
|
}: ConfirmDialogProps) {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal open={open} onClose={onCancel} title={title || t('confirmDialog.title')} size="sm">
|
|
|
|
|
<p className="text-sm text-secondary-700">{message}</p>
|
|
|
|
|
<div className="mt-6 flex justify-end gap-3">
|
|
|
|
|
<Button variant="secondary" onClick={onCancel}>
|
|
|
|
|
{cancelLabel || t('confirmDialog.cancel')}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button variant={variant === 'danger' ? 'danger' : 'primary'} onClick={onConfirm}>
|
|
|
|
|
{confirmLabel || t('confirmDialog.confirm')}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|