Start integrating the onboarding flow with backend 3
This commit is contained in:
@@ -23,6 +23,24 @@ import {
|
||||
|
||||
|
||||
class ProcurementService {
|
||||
private getTenantId(): string {
|
||||
const tenantStorage = localStorage.getItem('tenant-storage');
|
||||
if (tenantStorage) {
|
||||
try {
|
||||
const { state } = JSON.parse(tenantStorage);
|
||||
return state?.currentTenant?.id;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private getBaseUrl(): string {
|
||||
const tenantId = this.getTenantId();
|
||||
return `/tenants/${tenantId}`;
|
||||
}
|
||||
|
||||
// Purchase Order management
|
||||
async getPurchaseOrders(params?: {
|
||||
page?: number;
|
||||
@@ -43,34 +61,34 @@ class ProcurementService {
|
||||
}
|
||||
|
||||
const url = queryParams.toString()
|
||||
? `/purchase-orders?${queryParams.toString()}`
|
||||
: `/purchase-orders`;
|
||||
? `${this.getBaseUrl()}/purchase-orders?${queryParams.toString()}`
|
||||
: `${this.getBaseUrl()}/purchase-orders`;
|
||||
|
||||
return apiClient.get(url);
|
||||
}
|
||||
|
||||
async getPurchaseOrder(orderId: string): Promise<ApiResponse<PurchaseOrderResponse>> {
|
||||
return apiClient.get(`/purchase-orders/${orderId}`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/purchase-orders/${orderId}`);
|
||||
}
|
||||
|
||||
async createPurchaseOrder(orderData: PurchaseOrderCreate): Promise<ApiResponse<PurchaseOrderResponse>> {
|
||||
return apiClient.post(`/purchase-orders`, orderData);
|
||||
return apiClient.post(`${this.getBaseUrl()}/purchase-orders`, orderData);
|
||||
}
|
||||
|
||||
async updatePurchaseOrder(orderId: string, orderData: PurchaseOrderUpdate): Promise<ApiResponse<PurchaseOrderResponse>> {
|
||||
return apiClient.put(`/purchase-orders/${orderId}`, orderData);
|
||||
return apiClient.put(`${this.getBaseUrl()}/purchase-orders/${orderId}`, orderData);
|
||||
}
|
||||
|
||||
async approvePurchaseOrder(orderId: string): Promise<ApiResponse<PurchaseOrderResponse>> {
|
||||
return apiClient.post(`/purchase-orders/${orderId}/approve`);
|
||||
return apiClient.post(`${this.getBaseUrl()}/purchase-orders/${orderId}/approve`);
|
||||
}
|
||||
|
||||
async sendPurchaseOrder(orderId: string, sendEmail: boolean = true): Promise<ApiResponse<{ message: string; sent_at: string }>> {
|
||||
return apiClient.post(`/purchase-orders/${orderId}/send`, { send_email: sendEmail });
|
||||
return apiClient.post(`${this.getBaseUrl()}/purchase-orders/${orderId}/send`, { send_email: sendEmail });
|
||||
}
|
||||
|
||||
async cancelPurchaseOrder(orderId: string, reason?: string): Promise<ApiResponse<PurchaseOrderResponse>> {
|
||||
return apiClient.post(`/purchase-orders/${orderId}/cancel`, { reason });
|
||||
return apiClient.post(`${this.getBaseUrl()}/purchase-orders/${orderId}/cancel`, { reason });
|
||||
}
|
||||
|
||||
// Supplier management
|
||||
@@ -86,42 +104,42 @@ class ProcurementService {
|
||||
}
|
||||
|
||||
const url = queryParams.toString()
|
||||
? `/suppliers?${queryParams.toString()}`
|
||||
: `/suppliers`;
|
||||
? `${this.getBaseUrl()}/suppliers?${queryParams.toString()}`
|
||||
: `${this.getBaseUrl()}/suppliers`;
|
||||
|
||||
return apiClient.get(url);
|
||||
}
|
||||
|
||||
async getSupplier(supplierId: string): Promise<ApiResponse<SupplierResponse>> {
|
||||
return apiClient.get(`/suppliers/${supplierId}`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/suppliers/${supplierId}`);
|
||||
}
|
||||
|
||||
async createSupplier(supplierData: SupplierCreate): Promise<ApiResponse<SupplierResponse>> {
|
||||
return apiClient.post(`/suppliers`, supplierData);
|
||||
return apiClient.post(`${this.getBaseUrl()}/suppliers`, supplierData);
|
||||
}
|
||||
|
||||
async updateSupplier(supplierId: string, supplierData: SupplierUpdate): Promise<ApiResponse<SupplierResponse>> {
|
||||
return apiClient.put(`/suppliers/${supplierId}`, supplierData);
|
||||
return apiClient.put(`${this.getBaseUrl()}/suppliers/${supplierId}`, supplierData);
|
||||
}
|
||||
|
||||
async deleteSupplier(supplierId: string): Promise<ApiResponse<{ message: string }>> {
|
||||
return apiClient.delete(`/suppliers/${supplierId}`);
|
||||
return apiClient.delete(`${this.getBaseUrl()}/suppliers/${supplierId}`);
|
||||
}
|
||||
|
||||
async approveSupplier(supplierId: string, approval: SupplierApproval): Promise<ApiResponse<SupplierResponse>> {
|
||||
return apiClient.post(`/suppliers/${supplierId}/approve`, approval);
|
||||
return apiClient.post(`${this.getBaseUrl()}/suppliers/${supplierId}/approve`, approval);
|
||||
}
|
||||
|
||||
async getSupplierStatistics(): Promise<ApiResponse<SupplierStatistics>> {
|
||||
return apiClient.get(`/suppliers/statistics`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/suppliers/statistics`);
|
||||
}
|
||||
|
||||
async getActiveSuppliers(): Promise<ApiResponse<SupplierSummary[]>> {
|
||||
return apiClient.get(`/suppliers/active`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/suppliers/active`);
|
||||
}
|
||||
|
||||
async getTopSuppliers(limit: number = 10): Promise<ApiResponse<SupplierSummary[]>> {
|
||||
return apiClient.get(`/suppliers/top?limit=${limit}`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/suppliers/top?limit=${limit}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,30 +164,30 @@ class ProcurementService {
|
||||
}
|
||||
|
||||
const url = queryParams.toString()
|
||||
? `/deliveries?${queryParams.toString()}`
|
||||
: `/deliveries`;
|
||||
? `${this.getBaseUrl()}/deliveries?${queryParams.toString()}`
|
||||
: `${this.getBaseUrl()}/deliveries`;
|
||||
|
||||
return apiClient.get(url);
|
||||
}
|
||||
|
||||
async getDelivery(deliveryId: string): Promise<ApiResponse<DeliveryResponse>> {
|
||||
return apiClient.get(`/deliveries/${deliveryId}`);
|
||||
return apiClient.get(`${this.getBaseUrl()}/deliveries/${deliveryId}`);
|
||||
}
|
||||
|
||||
async createDelivery(deliveryData: DeliveryCreate): Promise<ApiResponse<DeliveryResponse>> {
|
||||
return apiClient.post(`/deliveries`, deliveryData);
|
||||
return apiClient.post(`${this.getBaseUrl()}/deliveries`, deliveryData);
|
||||
}
|
||||
|
||||
async updateDelivery(deliveryId: string, deliveryData: Partial<DeliveryCreate>): Promise<ApiResponse<DeliveryResponse>> {
|
||||
return apiClient.put(`/deliveries/${deliveryId}`, deliveryData);
|
||||
return apiClient.put(`${this.getBaseUrl()}/deliveries/${deliveryId}`, deliveryData);
|
||||
}
|
||||
|
||||
async updateDeliveryStatus(deliveryId: string, status: DeliveryStatus, notes?: string): Promise<ApiResponse<DeliveryResponse>> {
|
||||
return apiClient.put(`/deliveries/${deliveryId}/status`, { status, notes });
|
||||
return apiClient.put(`${this.getBaseUrl()}/deliveries/${deliveryId}/status`, { status, notes });
|
||||
}
|
||||
|
||||
async confirmDeliveryReceipt(deliveryId: string, confirmation: DeliveryReceiptConfirmation): Promise<ApiResponse<DeliveryResponse>> {
|
||||
return apiClient.post(`/deliveries/${deliveryId}/confirm-receipt`, confirmation);
|
||||
return apiClient.post(`${this.getBaseUrl()}/deliveries/${deliveryId}/confirm-receipt`, confirmation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user