31 lines
944 B
TypeScript
31 lines
944 B
TypeScript
import React, { useState } from 'react'
|
|
import { t } from '../i18n'
|
|
import { Locale } from '../types'
|
|
import { ConfirmDialog } from '../ui/dialog'
|
|
|
|
interface Props {
|
|
locale: Locale
|
|
name: string
|
|
onCancel: () => void
|
|
onConfirm: (keepFiles: boolean) => void
|
|
}
|
|
|
|
export const DeleteDialog: React.FC<Props> = ({ locale, name, onCancel, onConfirm }) => {
|
|
const [keepFiles, setKeepFiles] = useState(false)
|
|
return (
|
|
<ConfirmDialog
|
|
title={t(locale, 'deleteTitle', { name })}
|
|
description={t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
|
cancelLabel={t(locale, 'cancel')}
|
|
confirmLabel={t(locale, 'deleteConfirm')}
|
|
onCancel={onCancel}
|
|
onConfirm={() => onConfirm(keepFiles)}
|
|
>
|
|
<label className="choice">
|
|
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
|
{t(locale, 'deleteKeepFiles')}
|
|
</label>
|
|
</ConfirmDialog>
|
|
)
|
|
}
|