Start integrating the onboarding flow with backend 11
This commit is contained in:
@@ -332,14 +332,8 @@ export {
|
||||
|
||||
// Hooks - Classification
|
||||
export {
|
||||
usePendingSuggestions,
|
||||
useSuggestionHistory,
|
||||
useBusinessModelAnalysis,
|
||||
useClassifyProduct,
|
||||
useClassifyProductsBatch,
|
||||
useApproveClassification,
|
||||
useUpdateSuggestion,
|
||||
useDeleteSuggestion,
|
||||
classificationKeys,
|
||||
} from './hooks/classification';
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@ import { apiClient } from '../client';
|
||||
import {
|
||||
ProductClassificationRequest,
|
||||
BatchClassificationRequest,
|
||||
ProductSuggestionResponse,
|
||||
BusinessModelAnalysisResponse,
|
||||
ClassificationApprovalRequest,
|
||||
ClassificationApprovalResponse,
|
||||
ProductSuggestionResponse
|
||||
} from '../types/classification';
|
||||
|
||||
export class ClassificationService {
|
||||
@@ -19,7 +16,7 @@ export class ClassificationService {
|
||||
classificationData: ProductClassificationRequest
|
||||
): Promise<ProductSuggestionResponse> {
|
||||
return apiClient.post<ProductSuggestionResponse>(
|
||||
`${this.baseUrl}/${tenantId}/classification/classify-product`,
|
||||
`${this.baseUrl}/${tenantId}/inventory/classify-product`,
|
||||
classificationData
|
||||
);
|
||||
}
|
||||
@@ -28,67 +25,20 @@ export class ClassificationService {
|
||||
tenantId: string,
|
||||
batchData: BatchClassificationRequest
|
||||
): Promise<ProductSuggestionResponse[]> {
|
||||
return apiClient.post<ProductSuggestionResponse[]>(
|
||||
`${this.baseUrl}/${tenantId}/classification/classify-batch`,
|
||||
const response = await apiClient.post<{
|
||||
suggestions: ProductSuggestionResponse[];
|
||||
business_model_analysis: any;
|
||||
total_products: number;
|
||||
high_confidence_count: number;
|
||||
low_confidence_count: number;
|
||||
}>(
|
||||
`${this.baseUrl}/${tenantId}/inventory/classify-products-batch`,
|
||||
batchData
|
||||
);
|
||||
// Extract just the suggestions array from the response
|
||||
return response.suggestions;
|
||||
}
|
||||
|
||||
async getBusinessModelAnalysis(tenantId: string): Promise<BusinessModelAnalysisResponse> {
|
||||
return apiClient.get<BusinessModelAnalysisResponse>(
|
||||
`${this.baseUrl}/${tenantId}/classification/business-model-analysis`
|
||||
);
|
||||
}
|
||||
|
||||
async approveClassification(
|
||||
tenantId: string,
|
||||
approvalData: ClassificationApprovalRequest
|
||||
): Promise<ClassificationApprovalResponse> {
|
||||
return apiClient.post<ClassificationApprovalResponse>(
|
||||
`${this.baseUrl}/${tenantId}/classification/approve-suggestion`,
|
||||
approvalData
|
||||
);
|
||||
}
|
||||
|
||||
async getPendingSuggestions(tenantId: string): Promise<ProductSuggestionResponse[]> {
|
||||
return apiClient.get<ProductSuggestionResponse[]>(
|
||||
`${this.baseUrl}/${tenantId}/classification/pending-suggestions`
|
||||
);
|
||||
}
|
||||
|
||||
async getSuggestionHistory(
|
||||
tenantId: string,
|
||||
limit: number = 50,
|
||||
offset: number = 0
|
||||
): Promise<{
|
||||
items: ProductSuggestionResponse[];
|
||||
total: number;
|
||||
}> {
|
||||
const queryParams = new URLSearchParams();
|
||||
queryParams.append('limit', limit.toString());
|
||||
queryParams.append('offset', offset.toString());
|
||||
|
||||
return apiClient.get(
|
||||
`${this.baseUrl}/${tenantId}/classification/suggestion-history?${queryParams.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
async deleteSuggestion(tenantId: string, suggestionId: string): Promise<{ message: string }> {
|
||||
return apiClient.delete<{ message: string }>(
|
||||
`${this.baseUrl}/${tenantId}/classification/suggestions/${suggestionId}`
|
||||
);
|
||||
}
|
||||
|
||||
async updateSuggestion(
|
||||
tenantId: string,
|
||||
suggestionId: string,
|
||||
updateData: Partial<ProductSuggestionResponse>
|
||||
): Promise<ProductSuggestionResponse> {
|
||||
return apiClient.put<ProductSuggestionResponse>(
|
||||
`${this.baseUrl}/${tenantId}/classification/suggestions/${suggestionId}`,
|
||||
updateData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const classificationService = new ClassificationService();
|
||||
@@ -26,40 +26,4 @@ export interface ProductSuggestionResponse {
|
||||
is_seasonal: boolean;
|
||||
suggested_supplier?: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface BusinessModelAnalysisResponse {
|
||||
tenant_id: string;
|
||||
analysis_date: string;
|
||||
business_type: string;
|
||||
primary_products: string[];
|
||||
seasonality_patterns: Record<string, any>;
|
||||
supplier_recommendations: Array<{
|
||||
category: string;
|
||||
suppliers: string[];
|
||||
estimated_cost_savings: number;
|
||||
}>;
|
||||
inventory_optimization_suggestions: Array<{
|
||||
product_name: string;
|
||||
current_stock_level: number;
|
||||
suggested_stock_level: number;
|
||||
reason: string;
|
||||
}>;
|
||||
confidence_score: number;
|
||||
}
|
||||
|
||||
export interface ClassificationApprovalRequest {
|
||||
suggestion_id: string;
|
||||
approved: boolean;
|
||||
modifications?: Partial<ProductSuggestionResponse>;
|
||||
}
|
||||
|
||||
export interface ClassificationApprovalResponse {
|
||||
suggestion_id: string;
|
||||
approved: boolean;
|
||||
created_ingredient?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
message: string;
|
||||
}
|
||||
Reference in New Issue
Block a user