Refactor Site Builder Integration and Update Component Structure

- Removed the separate `igny8_sites` service from Docker Compose, integrating its functionality into the main app.
- Updated the Site Builder components to enhance user experience, including improved loading states and error handling.
- Refactored routing and navigation in the Site Builder Wizard and Preview components for better clarity and usability.
- Adjusted test files to reflect changes in import paths and ensure compatibility with the new structure.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-18 10:52:24 +00:00
parent 3ea519483d
commit 5d97ab6e49
8 changed files with 325 additions and 133 deletions

View File

@@ -40,6 +40,7 @@ interface BuilderState {
currentStep: number;
isSubmitting: boolean;
isGenerating: boolean;
isLoadingBlueprint: boolean;
error?: string;
activeBlueprint?: SiteBlueprint;
pages: PageBlueprint[];
@@ -67,6 +68,7 @@ interface BuilderState {
togglePageSelection: (pageId: number) => void;
selectAllPages: () => void;
clearPageSelection: () => void;
loadBlueprint: (blueprintId: number) => Promise<void>;
generateAllPages: (blueprintId: number, force?: boolean) => Promise<void>;
}
@@ -75,6 +77,7 @@ export const useBuilderStore = create<BuilderState>((set, get) => ({
currentStep: 0,
isSubmitting: false,
isGenerating: false,
isLoadingBlueprint: false,
pages: [],
selectedPageIds: [],
@@ -221,6 +224,41 @@ export const useBuilderStore = create<BuilderState>((set, get) => ({
clearPageSelection: () => set({ selectedPageIds: [] }),
loadBlueprint: async (blueprintId: number) => {
set({ isLoadingBlueprint: true, error: undefined });
try {
const [blueprint, pages] = await Promise.all([
siteBuilderApi.getBlueprint(blueprintId),
siteBuilderApi.listPages(blueprintId),
]);
set({
activeBlueprint: blueprint,
pages,
selectedPageIds: [],
});
if (blueprint.structure_json) {
useSiteDefinitionStore.getState().setStructure(blueprint.structure_json);
} else {
useSiteDefinitionStore.getState().setStructure({
site: undefined,
pages: pages.map((page) => ({
slug: page.slug,
title: page.title,
type: page.type,
blocks: page.blocks_json,
})),
});
}
useSiteDefinitionStore.getState().setPages(pages);
} catch (error: any) {
set({
error: error?.message || "Unable to load blueprint",
});
} finally {
set({ isLoadingBlueprint: false });
}
},
generateAllPages: async (blueprintId: number, force = false) => {
const { selectedPageIds } = get();
set({ isGenerating: true, error: undefined, generationProgress: undefined });