Files
upload-gltf/components/upload/OverwriteConfirmModal.tsx

78 lines
2.6 KiB
TypeScript

import type { FileDiff } from '@/lib/types'
import Modal, { ModalActions } from '@/components/ui/Modal'
import { WarningIcon } from '@/components/ui/icons'
interface OverwriteConfirmModalProps {
folderName: string
diffs: FileDiff[]
onCancel: () => void
onConfirm: () => void
disabled?: boolean
}
export default function OverwriteConfirmModal({
folderName,
diffs,
onCancel,
onConfirm,
disabled = false,
}: OverwriteConfirmModalProps) {
return (
<Modal ariaLabelledBy="overwrite-title">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-yellow-900/30 flex items-center justify-center shrink-0">
<WarningIcon className="w-5 h-5 text-yellow-400" />
</div>
<div>
<h3 id="overwrite-title" className="text-sm font-semibold text-gray-100">
Dossier deja existant
</h3>
<p className="text-xs text-gray-400 mt-0.5">
<span className="font-mono text-yellow-400">public/models/{folderName}</span> existe deja.
Les anciens fichiers seront archives sur le Drive, puis les nouveaux seront envoyes sur le Drive et Git.
</p>
</div>
</div>
{diffs.length > 0 && (
<div className="bg-black-800 border border-white/10 rounded-xl p-3 max-h-40 overflow-y-auto">
<p className="text-xs text-gray-500 mb-2">Modifications detectees :</p>
<ul className="space-y-1">
{diffs.map((d) => (
<li key={d.name} className="flex items-center gap-2 text-xs font-mono">
{d.status === 'changed' && (
<>
<span className="text-yellow-400">🔄</span>
<span className="text-gray-300">{d.name}</span>
</>
)}
{d.status === 'new' && (
<>
<span className="text-green-400"></span>
<span className="text-gray-300">{d.name}</span>
</>
)}
{d.status === 'deleted' && (
<>
<span className="text-red-400"></span>
<span className="text-gray-500 line-through">{d.name}</span>
</>
)}
</li>
))}
</ul>
</div>
)}
<ModalActions
cancelLabel="Annuler"
confirmLabel="Remplacer"
onCancel={onCancel}
onConfirm={onConfirm}
confirmClassName="bg-yellow-600 text-[#000000] hover:bg-yellow-500"
disabled={disabled}
/>
</Modal>
)
}