mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 04:51:13 -05:00
Refactor to defer photo uploads
This commit is contained in:
@@ -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?.();
|
||||
|
||||
Reference in New Issue
Block a user