feat(file-upload-component): FileUpload mit drag-and-drop [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 10:13:53 +02:00
parent ad737de1c3
commit e9dbdc3afe
5 changed files with 212 additions and 1 deletions

View File

@ -5,6 +5,7 @@
"attempted_features": [ "attempted_features": [
"spinner-component", "spinner-component",
"slider-component", "slider-component",
"rating-component" "rating-component",
"chip-component"
] ]
} }

5
.phase39-state.json Normal file
View File

@ -0,0 +1,5 @@
{
"completed_features": [],
"current_feature": "file-upload-component",
"started_at": "2026-05-23T10:13:25.521406"
}

View File

@ -4107,3 +4107,28 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
- `10:09:26` **INFO** Committed feature chip-component
- `10:09:26` **INFO** Pushed: rc=0
## Phase-38 Run beendet (2026-05-23 10:09:26)
- `10:09:26` **INFO** OK: 0, Attempted: 4, Total: 4
## 🚀 Phase-39 Codegen-Run gestartet (2026-05-23 10:13:25)
## Phase-3 Feature: file-upload-component (2026-05-23 10:13:25)
- `10:13:25` **INFO** Description: FileUpload mit drag-and-drop
- `10:13:25` **INFO** Generating apps/web/src/components/FileUpload.tsx (FileUpload-Component. Props: onFiles(files: File[]), accept?, multiple…)
- `10:13:51` **INFO** wrote 2566 chars in 26.0s (attempt 1)
- `10:13:51` **INFO** Running tsc --noEmit on api…
- `10:13:53` **WARN** tsc errors:
src/db/schema.ts(37,14): error TS7022: 'customers' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(45,59): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
src/db/schema.ts(49,14): error TS7022: 'projects' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(53,56): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
src/index.ts(27,25): error TS2769: No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,

View File

@ -0,0 +1,83 @@
import React, { useRef } from 'react';
interface FileUploadProps {
onFiles: (files: File[]) => void;
accept?: string;
multiple?: boolean;
maxSizeMB?: number;
}
export default function FileUpload({
onFiles,
accept,
multiple = false,
maxSizeMB
}: FileUploadProps) {
const inputRef = useRef<HTMLInputElement>(null);
const handleFileSelection = (files: FileList | null) => {
if (!files) return;
const fileArray = Array.from(files);
const filteredFiles = fileArray.filter(file => {
if (maxSizeMB && file.size > maxSizeMB * 1024 * 1024) {
console.warn(`File ${file.name} exceeds size limit of ${maxSizeMB}MB`);
return false;
}
return true;
});
onFiles(filteredFiles);
};
const handleDrop = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
handleFileSelection(e.dataTransfer.files);
};
const handleDragOver = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
};
const handleClick = () => {
inputRef.current?.click();
};
return (
<div
onClick={handleClick}
onDragOver={handleDragOver}
onDrop={handleDrop}
className="relative group cursor-pointer border-2 border-dashed border-slate-300 dark:border-slate-600 rounded-lg p-8 text-center transition-colors hover:border-blue-500 dark:hover:border-blue-400 hover:bg-slate-50 dark:hover:bg-slate-800/50"
>
<input
type="file"
ref={inputRef}
onChange={(e) => handleFileSelection(e.target.files)}
accept={accept}
multiple={multiple}
className="hidden"
/>
<div className="flex flex-col items-center justify-center gap-2">
<svg
className="w-10 h-10 text-slate-400 group-hover:text-blue-500 transition-colors"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13L15.01 13m-1.01 0L14 13m1.01 0L15 13" />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
<p className="text-sm text-slate-600 dark:text-slate-400">
<span className="font-semibold text-blue-600 dark:text-blue-400">Drop files here</span> or click to upload
</p>
{maxSizeMB && (
<p className="text-xs text-slate-400">Max size: {maxSizeMB}MB</p>
)}
</div>
</div>
);
}

View File

@ -0,0 +1,97 @@
#!/usr/bin/env python3
"""Phase-39: standalone components — FileUpload, ImageGallery, KeyValueList, CodeBlock."""
from __future__ import annotations
import asyncio, datetime, json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from phase2_features import Feature, FileGen, ROOT, log, log_section
from phase3_features import run_feature_v2
PHASE_STATE = ROOT / ".phase39-state.json"
FEATURES: list[Feature] = [
Feature(
name="file-upload-component",
description="FileUpload mit drag-and-drop",
files=[FileGen(
path="apps/web/src/components/FileUpload.tsx",
purpose=(
"FileUpload-Component. Props: onFiles(files: File[]), accept?, multiple?, maxSizeMB?. "
"Dashed border + 'Drop files here or click'. onDragOver/onDrop/onClick → input file change. "
"Filter by accept + maxSize. Tailwind. Export default."
),
)],
),
Feature(
name="image-gallery-component",
description="ImageGallery mit Lightbox",
files=[FileGen(
path="apps/web/src/components/ImageGallery.tsx",
purpose=(
"ImageGallery-Component. Props: images (array {url, alt?, caption?}), columns? (default 3). "
"Grid. Klick auf image öffnet Modal-Lightbox (full-screen) mit prev/next. Escape schließt. "
"Tailwind. Export default."
),
)],
),
Feature(
name="key-value-list-component",
description="KeyValueList für Detail-Views",
files=[FileGen(
path="apps/web/src/components/KeyValueList.tsx",
purpose=(
"KeyValueList-Component. Props: items (array {key, value: ReactNode, copyable?}), layout?: 'horizontal'|'vertical'. "
"Horizontal: Grid 2 cols. Vertical: stacked. Wenn copyable: kleiner Copy-Icon button (lucide Copy). "
"Tailwind. Export default."
),
)],
),
Feature(
name="code-block-component",
description="CodeBlock mit syntax-color + copy",
files=[FileGen(
path="apps/web/src/components/CodeBlock.tsx",
purpose=(
"CodeBlock-Component. Props: code (string), language?: string, showCopyButton? (default true). "
"<pre><code> in dunklem bg (zinc-900), text-zinc-100 mono. "
"Copy-Button oben-rechts. Optional Language-Label oben-links. Tailwind. Export default."
),
)],
),
]
def load_state():
if PHASE_STATE.exists():
return json.loads(PHASE_STATE.read_text())
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
def save_state(state):
PHASE_STATE.write_text(json.dumps(state, indent=2))
async def main():
log_section("🚀 Phase-39 Codegen-Run gestartet")
state = load_state()
for feature in FEATURES:
if feature.name in state.get("completed_features", []):
continue
state["current_feature"] = feature.name; save_state(state)
try:
success = await run_feature_v2(feature)
state.setdefault("completed_features" if success else "attempted_features", []).append(feature.name)
save_state(state)
except Exception as e:
log(f"{feature.name} crashed: {e}", level="ERROR")
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
log_section("Phase-39 Run beendet")
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
return 0
if __name__ == "__main__":
sys.exit(asyncio.run(main()))