Fix: Enabled Magic Bar project hydration in NewProject wizard (Phase 9)
Browse files
frontend/src/components/NewProject.tsx
CHANGED
|
@@ -144,6 +144,25 @@ const NewProject: React.FC<{ uiMode: UiMode; initialData?: any; onCreated?: () =
|
|
| 144 |
}
|
| 145 |
}, [uiMode]);
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
const handleAiGenerate = async () => {
|
| 148 |
if (!aiPrompt.trim()) return;
|
| 149 |
setIsGenerating(true);
|
|
|
|
| 144 |
}
|
| 145 |
}, [uiMode]);
|
| 146 |
|
| 147 |
+
// Hydrate from Magic Bar / external data
|
| 148 |
+
React.useEffect(() => {
|
| 149 |
+
if (initialData) {
|
| 150 |
+
if (initialData.name) setName(initialData.name);
|
| 151 |
+
if (initialData.description) setDescription(initialData.description);
|
| 152 |
+
if (initialData.context) setContext(initialData.context);
|
| 153 |
+
if (initialData.sources && Array.isArray(initialData.sources)) {
|
| 154 |
+
const aiSources: ProjectSource[] = initialData.sources.map((s: any) => ({
|
| 155 |
+
id: crypto.randomUUID(),
|
| 156 |
+
...s
|
| 157 |
+
}));
|
| 158 |
+
setSources(aiSources);
|
| 159 |
+
}
|
| 160 |
+
// If we have initial data, jump to step 0 of the wizard (Basics)
|
| 161 |
+
// but ensure we are in the wizard view
|
| 162 |
+
setWizardStep(0);
|
| 163 |
+
}
|
| 164 |
+
}, [initialData]);
|
| 165 |
+
|
| 166 |
const handleAiGenerate = async () => {
|
| 167 |
if (!aiPrompt.trim()) return;
|
| 168 |
setIsGenerating(true);
|