Refactor Site Builder Integration and Update Docker Configuration
- Merged the site builder functionality into the main app, enhancing the SiteBuilderWizard component with new steps and improved UI. - Updated the Docker Compose configuration by removing the separate site builder service and integrating its functionality into the igny8_sites service. - Enhanced Vite configuration to support code-splitting for builder routes, optimizing loading times. - Updated package dependencies to include new libraries for state management and form handling.
This commit is contained in:
125
frontend/src/services/siteBuilder.api.ts
Normal file
125
frontend/src/services/siteBuilder.api.ts
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Site Builder API Service
|
||||
* Uses fetchAPI pattern (not axios) - handles authentication automatically
|
||||
*/
|
||||
import { fetchAPI } from './api';
|
||||
import type {
|
||||
SiteBlueprint,
|
||||
PageBlueprint,
|
||||
SiteStructure,
|
||||
BuilderFormData,
|
||||
} from '../types/siteBuilder';
|
||||
|
||||
export interface CreateBlueprintPayload {
|
||||
name: string;
|
||||
description?: string;
|
||||
site_id: number;
|
||||
sector_id: number;
|
||||
hosting_type: BuilderFormData['hostingType'];
|
||||
config_json: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface GenerateStructurePayload {
|
||||
business_brief: string;
|
||||
objectives: string[];
|
||||
style: BuilderFormData['style'];
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Site Builder API functions
|
||||
*/
|
||||
export const siteBuilderApi = {
|
||||
/**
|
||||
* List all site blueprints
|
||||
*/
|
||||
async listBlueprints(siteId?: number): Promise<SiteBlueprint[]> {
|
||||
const params = siteId ? `?site=${siteId}` : '';
|
||||
const response = await fetchAPI(`/v1/site-builder/blueprints/${params}`);
|
||||
// Handle paginated response
|
||||
if (response?.results) {
|
||||
return response.results as SiteBlueprint[];
|
||||
}
|
||||
// Handle direct array response
|
||||
return Array.isArray(response) ? response : [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a single blueprint by ID
|
||||
*/
|
||||
async getBlueprint(id: number): Promise<SiteBlueprint> {
|
||||
return fetchAPI(`/v1/site-builder/blueprints/${id}/`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new site blueprint
|
||||
*/
|
||||
async createBlueprint(payload: CreateBlueprintPayload): Promise<SiteBlueprint> {
|
||||
return fetchAPI('/v1/site-builder/blueprints/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate site structure for a blueprint
|
||||
*/
|
||||
async generateStructure(
|
||||
blueprintId: number,
|
||||
payload: GenerateStructurePayload,
|
||||
): Promise<{ task_id?: string; success?: boolean; structure?: SiteStructure }> {
|
||||
return fetchAPI(`/v1/site-builder/blueprints/${blueprintId}/generate_structure/`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List pages for a blueprint
|
||||
*/
|
||||
async listPages(blueprintId: number): Promise<PageBlueprint[]> {
|
||||
const response = await fetchAPI(`/v1/site-builder/pages/?site_blueprint=${blueprintId}`);
|
||||
// Handle paginated response
|
||||
if (response?.results) {
|
||||
return response.results as PageBlueprint[];
|
||||
}
|
||||
// Handle direct array response
|
||||
return Array.isArray(response) ? response : [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate all pages for a blueprint
|
||||
*/
|
||||
async generateAllPages(
|
||||
blueprintId: number,
|
||||
options?: { pageIds?: number[]; force?: boolean },
|
||||
): Promise<{ success: boolean; pages_queued: number; task_ids: number[]; celery_task_id?: string }> {
|
||||
const response = await fetchAPI(`/v1/site-builder/blueprints/${blueprintId}/generate_all_pages/`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
page_ids: options?.pageIds,
|
||||
force: options?.force || false,
|
||||
}),
|
||||
});
|
||||
// Handle unified response format
|
||||
return response?.data || response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create tasks for pages
|
||||
*/
|
||||
async createTasksForPages(
|
||||
blueprintId: number,
|
||||
pageIds?: number[],
|
||||
): Promise<{ tasks: unknown[]; count: number }> {
|
||||
const response = await fetchAPI(`/v1/site-builder/blueprints/${blueprintId}/create_tasks/`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
page_ids: pageIds,
|
||||
}),
|
||||
});
|
||||
// Handle unified response format
|
||||
return response?.data || response;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user