mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
- Extracted new components: ProjectSelectorWithOptions, SidebarFooter, TrashDialog, and OnboardingDialog to improve code organization and reusability. - Introduced new hooks: useProjectCreation, useSetupDialog, and useTrashDialog for better state management and modularity. - Updated sidebar.tsx to utilize the new components and hooks, reducing complexity and improving maintainability. - Enhanced project creation and setup processes with dedicated dialogs and streamlined user interactions. This refactor aims to enhance the user experience and maintainability of the sidebar by modularizing functionality and improving the overall structure.
41 lines
1003 B
TypeScript
41 lines
1003 B
TypeScript
import { useState } from 'react';
|
|
import { useTrashOperations } from './use-trash-operations';
|
|
import type { TrashedProject } from '@/lib/electron';
|
|
|
|
interface UseTrashDialogProps {
|
|
restoreTrashedProject: (projectId: string) => void;
|
|
deleteTrashedProject: (projectId: string) => void;
|
|
emptyTrash: () => void;
|
|
trashedProjects: TrashedProject[];
|
|
}
|
|
|
|
/**
|
|
* Hook that combines trash operations with dialog state management
|
|
*/
|
|
export function useTrashDialog({
|
|
restoreTrashedProject,
|
|
deleteTrashedProject,
|
|
emptyTrash,
|
|
trashedProjects,
|
|
}: UseTrashDialogProps) {
|
|
// Dialog state
|
|
const [showTrashDialog, setShowTrashDialog] = useState(false);
|
|
|
|
// Reuse existing trash operations logic
|
|
const trashOperations = useTrashOperations({
|
|
restoreTrashedProject,
|
|
deleteTrashedProject,
|
|
emptyTrash,
|
|
trashedProjects,
|
|
});
|
|
|
|
return {
|
|
// Dialog state
|
|
showTrashDialog,
|
|
setShowTrashDialog,
|
|
|
|
// Trash operations (spread from existing hook)
|
|
...trashOperations,
|
|
};
|
|
}
|