Refactor to defer photo uploads

This commit is contained in:
gpt-engineer-app[bot]
2025-09-29 18:15:12 +00:00
parent 15d95daec4
commit aaa1c633f6
3 changed files with 168 additions and 11 deletions

View File

@@ -10,6 +10,7 @@ import { Progress } from '@/components/ui/progress';
interface UppyPhotoUploadProps {
onUploadComplete?: (urls: string[]) => void;
onFilesSelected?: (files: File[]) => void;
onUploadStart?: () => void;
onUploadError?: (error: Error) => void;
maxFiles?: number;
@@ -24,6 +25,7 @@ interface UppyPhotoUploadProps {
size?: 'default' | 'compact' | 'large';
enableDragDrop?: boolean;
showUploadModal?: boolean;
deferUpload?: boolean; // If true, don't upload immediately
}
interface CloudflareResponse {
@@ -46,6 +48,7 @@ interface UploadSuccessResponse {
export function UppyPhotoUpload({
onUploadComplete,
onFilesSelected,
onUploadStart,
onUploadError,
maxFiles = 5,
@@ -59,6 +62,7 @@ export function UppyPhotoUpload({
showPreview = true,
size = 'default',
enableDragDrop = true,
deferUpload = false,
}: UppyPhotoUploadProps) {
const [uploadedImages, setUploadedImages] = useState<string[]>([]);
const [isUploading, setIsUploading] = useState(false);
@@ -171,6 +175,13 @@ export function UppyPhotoUpload({
}
}
// If deferUpload is true, just notify and don't upload
if (deferUpload) {
onFilesSelected?.(files);
return;
}
// Otherwise, upload immediately (old behavior)
setIsUploading(true);
setUploadProgress(0);
onUploadStart?.();