ADD new frontend

This commit is contained in:
Urtzi Alfaro
2025-08-28 10:41:04 +02:00
parent 9c247a5f99
commit 0fd273cfce
492 changed files with 114979 additions and 1632 deletions

View File

@@ -0,0 +1,101 @@
// Simplified useSuppliers hook for TypeScript compatibility
import { useState } from 'react';
import {
SupplierSummary,
CreateSupplierRequest,
UpdateSupplierRequest,
SupplierSearchParams,
SupplierStatistics,
PurchaseOrder,
CreatePurchaseOrderRequest,
PurchaseOrderSearchParams,
PurchaseOrderStatistics,
Delivery,
DeliverySearchParams,
DeliveryPerformanceStats
} from '../services/suppliers.service';
export const useSuppliers = () => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
// Simple stub implementations
const getSuppliers = async (params?: SupplierSearchParams) => {
setIsLoading(true);
try {
// Mock data for now
return [];
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
throw err;
} finally {
setIsLoading(false);
}
};
const createSupplier = async (data: CreateSupplierRequest) => {
setIsLoading(true);
try {
// Mock implementation
return { id: '1', ...data } as any;
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
throw err;
} finally {
setIsLoading(false);
}
};
const updateSupplier = async (id: string, data: UpdateSupplierRequest) => {
setIsLoading(true);
try {
// Mock implementation
return { id, ...data } as any;
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
throw err;
} finally {
setIsLoading(false);
}
};
// Return all the expected properties/methods
return {
suppliers: [],
isLoading,
error,
getSuppliers,
createSupplier,
updateSupplier,
deleteSupplier: async () => {},
getSupplierStatistics: async () => ({} as SupplierStatistics),
getActiveSuppliers: async () => [] as SupplierSummary[],
getTopSuppliers: async () => [] as SupplierSummary[],
getSuppliersNeedingReview: async () => [] as SupplierSummary[],
approveSupplier: async () => {},
// Purchase orders
getPurchaseOrders: async () => [] as PurchaseOrder[],
createPurchaseOrder: async () => ({} as PurchaseOrder),
updatePurchaseOrderStatus: async () => ({} as PurchaseOrder),
// Deliveries
getDeliveries: async () => [] as Delivery[],
getTodaysDeliveries: async () => [] as Delivery[],
getDeliveryPerformanceStats: async () => ({} as DeliveryPerformanceStats),
};
};
// Re-export types
export type {
SupplierSummary,
CreateSupplierRequest,
UpdateSupplierRequest,
SupplierSearchParams,
SupplierStatistics,
PurchaseOrder,
CreatePurchaseOrderRequest,
PurchaseOrderSearchParams,
PurchaseOrderStatistics,
Delivery,
DeliverySearchParams,
DeliveryPerformanceStats
};