mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
- Extract board-view into organized subfolders following new pattern: - components/: kanban-card, kanban-column - dialogs/: all dialog and modal components (8 files) - hooks/: all board-specific hooks (10 files) - shared/: reusable components between dialogs (model-selector, etc.) - Rename all files to kebab-case convention - Add barrel exports (index.ts) for clean imports - Add docs/folder-pattern.md documenting the folder structure - Reduce board-view.tsx from ~3600 lines to ~490 lines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { useCallback } from "react";
|
|
import { Feature } from "@/store/app-store";
|
|
import { getElectronAPI } from "@/lib/electron";
|
|
import { useAppStore } from "@/store/app-store";
|
|
|
|
interface UseBoardPersistenceProps {
|
|
currentProject: { path: string; id: string } | null;
|
|
}
|
|
|
|
export function useBoardPersistence({
|
|
currentProject,
|
|
}: UseBoardPersistenceProps) {
|
|
const { updateFeature } = useAppStore();
|
|
|
|
// Persist feature update to API (replaces saveFeatures)
|
|
const persistFeatureUpdate = useCallback(
|
|
async (featureId: string, updates: Partial<Feature>) => {
|
|
if (!currentProject) return;
|
|
|
|
try {
|
|
const api = getElectronAPI();
|
|
if (!api.features) {
|
|
console.error("[BoardView] Features API not available");
|
|
return;
|
|
}
|
|
|
|
const result = await api.features.update(
|
|
currentProject.path,
|
|
featureId,
|
|
updates
|
|
);
|
|
if (result.success && result.feature) {
|
|
updateFeature(result.feature.id, result.feature);
|
|
}
|
|
} catch (error) {
|
|
console.error("Failed to persist feature update:", error);
|
|
}
|
|
},
|
|
[currentProject, updateFeature]
|
|
);
|
|
|
|
// Persist feature creation to API
|
|
const persistFeatureCreate = useCallback(
|
|
async (feature: Feature) => {
|
|
if (!currentProject) return;
|
|
|
|
try {
|
|
const api = getElectronAPI();
|
|
if (!api.features) {
|
|
console.error("[BoardView] Features API not available");
|
|
return;
|
|
}
|
|
|
|
const result = await api.features.create(currentProject.path, feature);
|
|
if (result.success && result.feature) {
|
|
updateFeature(result.feature.id, result.feature);
|
|
}
|
|
} catch (error) {
|
|
console.error("Failed to persist feature creation:", error);
|
|
}
|
|
},
|
|
[currentProject, updateFeature]
|
|
);
|
|
|
|
// Persist feature deletion to API
|
|
const persistFeatureDelete = useCallback(
|
|
async (featureId: string) => {
|
|
if (!currentProject) return;
|
|
|
|
try {
|
|
const api = getElectronAPI();
|
|
if (!api.features) {
|
|
console.error("[BoardView] Features API not available");
|
|
return;
|
|
}
|
|
|
|
await api.features.delete(currentProject.path, featureId);
|
|
} catch (error) {
|
|
console.error("Failed to persist feature deletion:", error);
|
|
}
|
|
},
|
|
[currentProject]
|
|
);
|
|
|
|
return {
|
|
persistFeatureCreate,
|
|
persistFeatureUpdate,
|
|
persistFeatureDelete,
|
|
};
|
|
}
|