diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index 0482a0ad..f58455e0 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -101,7 +101,7 @@ export function AppLayout({ onClick={() => setIsSidebarVisible(false)} /> {/* Sidebar - positioned above the backdrop */} -
+ {project.files.length} file{project.files.length !== 1 ? 's' : ''} + {project.isConflict && • Will overwrite existing project} +
- {project.files.length} file{project.files.length !== 1 ? 's' : ''} - {/* Only show overwrite text on desktop when conflict exists */} - {project.isConflict && • Will overwrite existing project} -
@@ -551,7 +617,7 @@ export function BulkProjectImportDialog({ onImport, disabled = false, className, - Projects imported successfully! + {mode === 'single' ? 'Project imported successfully!' : 'Projects imported successfully!'}
- You have selected {conflictingProjects.length} project{conflictingProjects.length !== 1 ? 's' : ''} that already exist: -
-Overwriting will:
-+ A project with ID "{generatedId}" already exists. + Overwriting it will: +
++ You have selected {conflictingProjects.length} project{conflictingProjects.length !== 1 ? 's' : ''} that already exist: +
+Overwriting will:
+This action cannot be undone. Are you sure you want to continue?
@@ -595,7 +678,7 @@ export function BulkProjectImportDialog({ onImport, disabled = false, className, onClick={confirmOverwrite} className="bg-amber-600 hover:bg-amber-700" > - Yes, Overwrite Projects + Yes, {mode === 'single' ? 'Overwrite Project' : 'Overwrite Projects'} diff --git a/src/components/ProjectSidebar.tsx b/src/components/ProjectSidebar.tsx index 3d6782a0..379cbe1e 100644 --- a/src/components/ProjectSidebar.tsx +++ b/src/components/ProjectSidebar.tsx @@ -9,7 +9,7 @@ import { useProjects } from '@/hooks/useProjects'; import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus'; import { useLocalStorage } from '@/hooks/useLocalStorage'; import { useIsMobile } from '@/hooks/useIsMobile'; -import { ZipImportDialog } from '@/components/ZipImportDialog'; +import { ProjectImportDialog } from '@/components/ProjectImportDialog'; import { useProjectsManager } from '@/hooks/useProjectsManager'; import { useToast } from '@/hooks/useToast'; import type { Project } from '@/lib/ProjectsManager'; @@ -123,19 +123,28 @@ export function ProjectSidebar({ } }; - const handleImportZip = async (file: File, overwrite = false, projectId?: string) => { + const handleImportZip = async (data: { file: File; projectId?: string } | { projects: { id: string; files: { [path: string]: Uint8Array } }[] }, overwrite: boolean) => { try { - // Import project from zip file - const project = await projectsManager.importProjectFromZip(file, projectId, overwrite); + let project; - // Show success toast - toast({ - title: overwrite ? "Project Overwritten Successfully" : "Project Imported Successfully", - description: `"${project.name}" has been ${overwrite ? 'overwritten' : 'imported'} and is ready to use.`, - }); + if ('file' in data) { + // Single project import + project = await projectsManager.importProject(data.file, { projectId: data.projectId, overwrite }); + + // Show success toast + toast({ + title: overwrite ? "Project Overwritten Successfully" : "Project Imported Successfully", + description: `"${project.name}" has been ${overwrite ? 'overwritten' : 'imported'} and is ready to use.`, + }); + } else { + // Bulk import - this shouldn't happen in sidebar mode, but handle gracefully + throw new Error('Bulk import not supported in sidebar'); + } // Navigate to the imported project - navigate(`/project/${project.id}`); + if (project) { + navigate(`/project/${project.id}`); + } } catch (error) { console.error('Failed to import project:', error); throw error; // Re-throw to let the dialog handle the error display @@ -282,7 +291,8 @@ export function ProjectSidebar({- A project with the ID "{generatedId}" already exists. - Overwriting it will: -
-- This action cannot be undone. Are you sure you want to continue? -
-