Merge branch 'main' of https://git.igny8.com/salman/igny8
This commit is contained in:
@@ -2147,6 +2147,97 @@ export async function validateContent(id: number): Promise<{
|
||||
});
|
||||
}
|
||||
|
||||
// Content Taxonomy API
|
||||
export interface ContentTaxonomy {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
taxonomy_type: 'category' | 'tag' | 'product_category' | 'product_tag' | 'product_attribute' | 'cluster';
|
||||
external_taxonomy?: string | null;
|
||||
external_id?: string | null;
|
||||
parent_id?: number | null;
|
||||
description?: string | null;
|
||||
count?: number;
|
||||
site_id: number;
|
||||
sector_id?: number | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface ContentTaxonomyFilters {
|
||||
taxonomy_type?: string;
|
||||
search?: string;
|
||||
site_id?: number;
|
||||
sector_id?: number;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
export interface ContentTaxonomyResponse {
|
||||
count: number;
|
||||
next: string | null;
|
||||
previous: string | null;
|
||||
results: ContentTaxonomy[];
|
||||
}
|
||||
|
||||
export async function fetchTaxonomies(filters: ContentTaxonomyFilters = {}): Promise<ContentTaxonomyResponse> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
// Automatically add active site filter if not explicitly provided
|
||||
if (!filters.site_id) {
|
||||
const activeSiteId = getActiveSiteId();
|
||||
if (activeSiteId) {
|
||||
filters.site_id = activeSiteId;
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically add active sector filter if not explicitly provided
|
||||
if (filters.sector_id === undefined) {
|
||||
const activeSectorId = getActiveSectorId();
|
||||
if (activeSectorId !== null && activeSectorId !== undefined) {
|
||||
filters.sector_id = activeSectorId;
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.search) params.append('search', filters.search);
|
||||
if (filters.taxonomy_type) params.append('taxonomy_type', filters.taxonomy_type);
|
||||
if (filters.site_id) params.append('site_id', filters.site_id.toString());
|
||||
if (filters.sector_id) params.append('sector_id', filters.sector_id.toString());
|
||||
if (filters.page) params.append('page', filters.page.toString());
|
||||
if (filters.page_size !== undefined && filters.page_size !== null) {
|
||||
params.append('page_size', filters.page_size.toString());
|
||||
}
|
||||
if (filters.ordering) params.append('ordering', filters.ordering);
|
||||
|
||||
const queryString = params.toString();
|
||||
return fetchAPI(`/v1/writer/taxonomies/${queryString ? `?${queryString}` : ''}`);
|
||||
}
|
||||
|
||||
export async function fetchTaxonomyById(id: number): Promise<ContentTaxonomy> {
|
||||
return fetchAPI(`/v1/writer/taxonomies/${id}/`);
|
||||
}
|
||||
|
||||
export async function createTaxonomy(data: Partial<ContentTaxonomy>): Promise<ContentTaxonomy> {
|
||||
return fetchAPI('/v1/writer/taxonomies/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateTaxonomy(id: number, data: Partial<ContentTaxonomy>): Promise<ContentTaxonomy> {
|
||||
return fetchAPI(`/v1/writer/taxonomies/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteTaxonomy(id: number): Promise<void> {
|
||||
return fetchAPI(`/v1/writer/taxonomies/${id}/`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// Site Builder API
|
||||
export interface SiteBlueprint {
|
||||
id: number;
|
||||
|
||||
Reference in New Issue
Block a user