refactor: full codebase audit — extract modules, fix type safety, clean dead code

- Extract API helpers from UploadZone into lib/upload-api.ts (FormData builder, checkFolderDiffs, uploadDrive, uploadGit)
- Extract upload orchestration into hooks/useUploadOrchestrator.ts (UploadZone: 489 → 162 lines)
- Extract file diff classification into lib/diff-files.ts (from git route)
- Extract shared SVG icons into components/ui/icons.tsx (7 icons, 0 duplication)
- Extract shared modal wrapper into components/ui/Modal.tsx + ModalActions
- Extract DriveStatusLine sub-component from FolderCard
- Fix checkFolderDiffs silently swallowing auth/network errors (now throws)
- Fix type safety: remove as never casts, add isHttpError type guard, use discriminated union for validateFolder
- Fix nextcloud: cache getConfig, add max bound to findNextVersion, optimize mkdirRecursive (skip PROPFIND)
- Fix drive route: remove req.clone(), extend parseMultiUpload to return extra fields
- Fix commit message: model shown as unchanged with ↔️ on updates (not falsely marked as modified)
- Clean dead code: unused folderExists import, FileStatus/DriveStatus exports, ParsedFile.textureName, getConfig basePath
- Add security headers in next.config.ts (HSTS, X-Content-Type-Options, X-Frame-Options, etc.)
- Update README with new project structure
This commit is contained in:
Tom Boullay
2026-04-14 17:19:10 +02:00
parent 110d64ec33
commit 78f4aa83e0
26 changed files with 957 additions and 721 deletions
+30 -52
View File
@@ -1,3 +1,6 @@
import Modal, { ModalActions } from '@/components/ui/Modal'
import { WarningIcon } from '@/components/ui/icons'
interface DriveErrorModalProps {
error: string
onCancel: () => void
@@ -10,60 +13,35 @@ export default function DriveErrorModal({
onContinue,
}: DriveErrorModalProps) {
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm"
role="dialog"
aria-modal="true"
aria-labelledby="drive-error-title"
>
<div className="bg-black-900 border border-white/20 rounded-2xl p-6 max-w-md w-full mx-4 space-y-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-red-900/30 flex items-center justify-center shrink-0">
<svg className="w-5 h-5 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
</div>
<div>
<h3 id="drive-error-title" className="text-sm font-semibold text-gray-100">
Erreur Drive
</h3>
<p className="text-xs text-gray-400 mt-0.5">
L&apos;archivage sur le Drive a echoue. Les fichiers n&apos;ont pas ete versionnes.
</p>
</div>
<Modal ariaLabelledBy="drive-error-title">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-red-900/30 flex items-center justify-center shrink-0">
<WarningIcon className="w-5 h-5 text-red-400" />
</div>
<div className="bg-black-800 border border-white/10 rounded-xl p-3">
<p className="text-xs text-red-400 font-mono break-all">{error}</p>
</div>
<p className="text-xs text-gray-400">
Voulez-vous quand meme envoyer les fichiers aux devs via GitHub ?
</p>
<div className="flex gap-3">
<button
onClick={onCancel}
className="flex-1 bg-black-700 text-gray-300 font-medium text-sm
py-2.5 px-4 rounded-xl border border-white/10 transition-colors duration-150
hover:bg-black-600"
>
Annuler
</button>
<button
onClick={onContinue}
className="flex-1 bg-white text-[#000000] font-medium text-sm
py-2.5 px-4 rounded-xl transition-colors duration-150
hover:bg-gray-200"
>
Envoyer sur Git seulement
</button>
<div>
<h3 id="drive-error-title" className="text-sm font-semibold text-gray-100">
Erreur Drive
</h3>
<p className="text-xs text-gray-400 mt-0.5">
L&apos;archivage sur le Drive a echoue. Les fichiers n&apos;ont pas ete versionnes.
</p>
</div>
</div>
</div>
<div className="bg-black-800 border border-white/10 rounded-xl p-3">
<p className="text-xs text-red-400 font-mono break-all">{error}</p>
</div>
<p className="text-xs text-gray-400">
Voulez-vous quand meme envoyer les fichiers aux devs via GitHub ?
</p>
<ModalActions
cancelLabel="Annuler"
confirmLabel="Envoyer sur Git seulement"
onCancel={onCancel}
onConfirm={onContinue}
/>
</Modal>
)
}