Enhance Site Builder Functionality and UI Components
- Added a new method to fetch blueprints from the API, improving data retrieval for site structures. - Updated the WizardPage component to include a progress modal for better user feedback during site structure generation. - Refactored state management in builderStore to track structure generation tasks, enhancing the overall user experience. - Replaced SyncIcon with RefreshCw in integration components for a more consistent iconography. - Improved the site structure generation prompt in utils.py to provide clearer instructions for AI-driven site architecture.
This commit is contained in:
@@ -34,6 +34,7 @@ interface BuilderState {
|
||||
isSubmitting: boolean;
|
||||
error?: string;
|
||||
activeBlueprint?: SiteBlueprint;
|
||||
structureTaskId: string | null;
|
||||
pages: PageBlueprint[];
|
||||
selectedPageIds: number[];
|
||||
isGenerating: boolean;
|
||||
@@ -51,6 +52,7 @@ interface BuilderState {
|
||||
previousStep: () => void;
|
||||
reset: () => void;
|
||||
submitWizard: () => Promise<void>;
|
||||
setStructureTaskId: (taskId: string | null) => void;
|
||||
refreshPages: (blueprintId: number) => Promise<void>;
|
||||
togglePageSelection: (pageId: number) => void;
|
||||
selectAllPages: () => void;
|
||||
@@ -62,7 +64,9 @@ export const useBuilderStore = create<BuilderState>((set, get) => ({
|
||||
form: defaultForm,
|
||||
currentStep: 0,
|
||||
isSubmitting: false,
|
||||
structureTaskId: null,
|
||||
pages: [],
|
||||
setStructureTaskId: (taskId) => set({ structureTaskId: taskId }),
|
||||
selectedPageIds: [],
|
||||
isGenerating: false,
|
||||
|
||||
@@ -118,7 +122,7 @@ export const useBuilderStore = create<BuilderState>((set, get) => ({
|
||||
return;
|
||||
}
|
||||
|
||||
set({ isSubmitting: true, error: undefined });
|
||||
set({ isSubmitting: true, error: undefined, structureTaskId: null });
|
||||
try {
|
||||
const payload = {
|
||||
name: form.siteName || `Site Blueprint (${form.industry || 'New'})`,
|
||||
@@ -143,11 +147,17 @@ export const useBuilderStore = create<BuilderState>((set, get) => ({
|
||||
metadata: { targetAudience: form.targetAudience },
|
||||
});
|
||||
|
||||
if (generation?.task_id) {
|
||||
set({ structureTaskId: generation.task_id });
|
||||
}
|
||||
|
||||
if (generation?.structure) {
|
||||
useSiteDefinitionStore.getState().setStructure(generation.structure);
|
||||
}
|
||||
|
||||
await get().refreshPages(blueprint.id);
|
||||
if (!generation?.task_id) {
|
||||
await get().refreshPages(blueprint.id);
|
||||
}
|
||||
} catch (error) {
|
||||
set({ error: error instanceof Error ? error.message : 'Unexpected error' });
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user