78f4aa83e0
- 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
78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import type { FolderEntry } from '@/lib/client-types'
|
|
import { validateFolder } from '@/lib/validate-folder'
|
|
import { FolderIcon } from '@/components/ui/icons'
|
|
|
|
interface FolderDropzoneProps {
|
|
isUploading: boolean
|
|
onFolderSelected: (entry: FolderEntry) => void
|
|
onError: (message: string) => void
|
|
}
|
|
|
|
export default function FolderDropzone({
|
|
isUploading,
|
|
onFolderSelected,
|
|
onError,
|
|
}: FolderDropzoneProps) {
|
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
const selected = e.target.files
|
|
if (!selected || selected.length === 0) return
|
|
|
|
const fileArray = Array.from(selected)
|
|
const folderName = fileArray[0].webkitRelativePath?.split('/')[0] || 'folder'
|
|
const validation = validateFolder(fileArray)
|
|
|
|
if (!validation.ok) {
|
|
onError(validation.errors.join(' | '))
|
|
return
|
|
}
|
|
|
|
const entry: FolderEntry = {
|
|
folderName,
|
|
modelFile: validation.model,
|
|
textures: validation.textures,
|
|
status: 'pending',
|
|
progress: 0,
|
|
warnings: validation.warnings,
|
|
modelUrl: URL.createObjectURL(validation.model),
|
|
viewerOpen: true,
|
|
}
|
|
onFolderSelected(entry)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<input
|
|
type="file"
|
|
id="folder-input"
|
|
{...({ webkitdirectory: '', directory: '' } as React.InputHTMLAttributes<HTMLInputElement>)}
|
|
multiple
|
|
className="hidden"
|
|
onChange={handleChange}
|
|
/>
|
|
|
|
<div
|
|
onClick={() => document.getElementById('folder-input')?.click()}
|
|
className={`
|
|
relative border-2 border-dashed rounded-2xl p-8 text-center cursor-pointer transition-all duration-200 bg-black-800
|
|
${isUploading ? 'cursor-not-allowed opacity-60 border-white/20' : ''}
|
|
${!isUploading ? 'border-white/30 hover:border-white/50 hover:bg-black-700' : ''}
|
|
`}
|
|
>
|
|
<div className="flex justify-center mb-3">
|
|
<div className="w-12 h-12 rounded-full flex items-center justify-center bg-black-700">
|
|
<FolderIcon className="w-6 h-6 text-gray-400" />
|
|
</div>
|
|
</div>
|
|
<p className="text-sm font-medium text-gray-300">
|
|
Deposez votre dossier ici
|
|
<span className="text-gray-500 font-normal"> ou cliquez pour parcourir</span>
|
|
</p>
|
|
<p className="text-xs text-gray-500 mt-1">
|
|
Contenu attendu : model.glb/gltf + textures (roughness, normal, metalness, color, displace)
|
|
<br />Les originaux sont archives sur le Drive, les comprimes sont envoyes sur Git.
|
|
</p>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|