|
|
@@ -2,24 +2,47 @@ import { request } from './request';
|
|
|
import type {
|
|
|
AfterSaleItem,
|
|
|
ApiKeyItem,
|
|
|
+ ApprovalFlowItem,
|
|
|
ChannelItem,
|
|
|
+ CouponItem,
|
|
|
DashboardAlert,
|
|
|
DashboardStat,
|
|
|
+ DepartmentItem,
|
|
|
+ EmployeeItem,
|
|
|
InventoryItem,
|
|
|
InventoryLogItem,
|
|
|
+ InventoryTurnoverItem,
|
|
|
+ InvoiceItem,
|
|
|
+ IQCItem,
|
|
|
LogItem,
|
|
|
+ LogisticsProviderItem,
|
|
|
MappingItem,
|
|
|
+ MessageTemplateItem,
|
|
|
+ NotificationItem,
|
|
|
OrderItem,
|
|
|
+ PaymentItem,
|
|
|
+ PriceWatchItem,
|
|
|
PricingRuleItem,
|
|
|
ProductItem,
|
|
|
+ PromotionItem,
|
|
|
PurchaseOrderItem,
|
|
|
+ PurchaseRequestItem,
|
|
|
+ RefundItem,
|
|
|
ReportDataItem,
|
|
|
ReportItem,
|
|
|
+ ReplenishmentPlanItem,
|
|
|
+ ReturnPackageItem,
|
|
|
RoleItem,
|
|
|
+ SatisfactionItem,
|
|
|
ShippingItem,
|
|
|
+ ShippingTemplateItem,
|
|
|
SupplierItem,
|
|
|
+ SupplierPerformanceItem,
|
|
|
SupplyCapabilityItem,
|
|
|
- UserProfile
|
|
|
+ SupplierSettlementItem,
|
|
|
+ TicketItem,
|
|
|
+ UserProfile,
|
|
|
+ WarehouseItem
|
|
|
} from '@/types/page';
|
|
|
|
|
|
export interface DashboardOverviewResponse {
|
|
|
@@ -141,5 +164,150 @@ export const api = {
|
|
|
updateApiKey: (id: string, data: Partial<ApiKeyItem>) =>
|
|
|
request<ApiKeyItem>(`/api/system/api-keys/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
deleteApiKey: (id: string) =>
|
|
|
- request<{ success: boolean }>(`/api/system/api-keys/${id}`, { method: 'DELETE' })
|
|
|
+ request<{ success: boolean }>(`/api/system/api-keys/${id}`, { method: 'DELETE' }),
|
|
|
+
|
|
|
+ /* Warehouse */
|
|
|
+ getWarehouses: () => request<{ items: WarehouseItem[] }>('/api/warehouses'),
|
|
|
+ createWarehouse: (data: Partial<WarehouseItem>) =>
|
|
|
+ request<WarehouseItem>('/api/warehouses', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateWarehouse: (id: string, data: Partial<WarehouseItem>) =>
|
|
|
+ request<WarehouseItem>(`/api/warehouses/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Return Package */
|
|
|
+ getReturnPackages: () => request<{ items: ReturnPackageItem[] }>('/api/return-packages'),
|
|
|
+ updateReturnPackage: (id: string, data: Partial<ReturnPackageItem>) =>
|
|
|
+ request<ReturnPackageItem>(`/api/return-packages/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Logistics Provider */
|
|
|
+ getLogisticsProviders: () => request<{ items: LogisticsProviderItem[] }>('/api/logistics-providers'),
|
|
|
+ createLogisticsProvider: (data: Partial<LogisticsProviderItem>) =>
|
|
|
+ request<LogisticsProviderItem>('/api/logistics-providers', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateLogisticsProvider: (id: string, data: Partial<LogisticsProviderItem>) =>
|
|
|
+ request<LogisticsProviderItem>(`/api/logistics-providers/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Shipping Template */
|
|
|
+ getShippingTemplates: () => request<{ items: ShippingTemplateItem[] }>('/api/shipping-templates'),
|
|
|
+ createShippingTemplate: (data: Partial<ShippingTemplateItem>) =>
|
|
|
+ request<ShippingTemplateItem>('/api/shipping-templates', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateShippingTemplate: (id: string, data: Partial<ShippingTemplateItem>) =>
|
|
|
+ request<ShippingTemplateItem>(`/api/shipping-templates/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Finance: Payment */
|
|
|
+ getPayments: () => request<{ items: PaymentItem[] }>('/api/finance/payments'),
|
|
|
+ updatePayment: (id: string, data: Partial<PaymentItem>) =>
|
|
|
+ request<PaymentItem>(`/api/finance/payments/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Finance: Refund */
|
|
|
+ getRefunds: () => request<{ items: RefundItem[] }>('/api/finance/refunds'),
|
|
|
+ updateRefund: (id: string, data: Partial<RefundItem>) =>
|
|
|
+ request<RefundItem>(`/api/finance/refunds/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Finance: Supplier Settlement */
|
|
|
+ getSupplierSettlements: () => request<{ items: SupplierSettlementItem[] }>('/api/finance/settlements'),
|
|
|
+ createSupplierSettlement: (data: Partial<SupplierSettlementItem>) =>
|
|
|
+ request<SupplierSettlementItem>('/api/finance/settlements', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateSupplierSettlement: (id: string, data: Partial<SupplierSettlementItem>) =>
|
|
|
+ request<SupplierSettlementItem>(`/api/finance/settlements/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Finance: Invoice */
|
|
|
+ getInvoices: () => request<{ items: InvoiceItem[] }>('/api/finance/invoices'),
|
|
|
+ createInvoice: (data: Partial<InvoiceItem>) =>
|
|
|
+ request<InvoiceItem>('/api/finance/invoices', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateInvoice: (id: string, data: Partial<InvoiceItem>) =>
|
|
|
+ request<InvoiceItem>(`/api/finance/invoices/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Procurement: Replenishment Plan */
|
|
|
+ getReplenishmentPlans: () => request<{ items: ReplenishmentPlanItem[] }>('/api/procurement/replenishment'),
|
|
|
+ createPurchaseFromPlan: (data: Partial<ReplenishmentPlanItem>) =>
|
|
|
+ request<ReplenishmentPlanItem>('/api/procurement/replenishment', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Procurement: Purchase Request */
|
|
|
+ getPurchaseRequests: () => request<{ items: PurchaseRequestItem[] }>('/api/procurement/requests'),
|
|
|
+ createPurchaseRequest: (data: Partial<PurchaseRequestItem>) =>
|
|
|
+ request<PurchaseRequestItem>('/api/procurement/requests', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updatePurchaseRequest: (id: string, data: Partial<PurchaseRequestItem>) =>
|
|
|
+ request<PurchaseRequestItem>(`/api/procurement/requests/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Procurement: IQC */
|
|
|
+ getIQCItems: () => request<{ items: IQCItem[] }>('/api/procurement/iqc'),
|
|
|
+ createIQC: (data: Partial<IQCItem>) =>
|
|
|
+ request<IQCItem>('/api/procurement/iqc', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateIQC: (id: string, data: Partial<IQCItem>) =>
|
|
|
+ request<IQCItem>(`/api/procurement/iqc/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* CRM: Ticket */
|
|
|
+ getTickets: () => request<{ items: TicketItem[] }>('/api/crm/tickets'),
|
|
|
+ createTicket: (data: Partial<TicketItem>) =>
|
|
|
+ request<TicketItem>('/api/crm/tickets', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateTicket: (id: string, data: Partial<TicketItem>) =>
|
|
|
+ request<TicketItem>(`/api/crm/tickets/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* CRM: Satisfaction */
|
|
|
+ getSatisfactions: () => request<{ items: SatisfactionItem[] }>('/api/crm/satisfactions'),
|
|
|
+ updateSatisfaction: (id: string, data: Partial<SatisfactionItem>) =>
|
|
|
+ request<SatisfactionItem>(`/api/crm/satisfactions/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Marketing: Promotion */
|
|
|
+ getPromotions: () => request<{ items: PromotionItem[] }>('/api/marketing/promotions'),
|
|
|
+ createPromotion: (data: Partial<PromotionItem>) =>
|
|
|
+ request<PromotionItem>('/api/marketing/promotions', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updatePromotion: (id: string, data: Partial<PromotionItem>) =>
|
|
|
+ request<PromotionItem>(`/api/marketing/promotions/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* Marketing: Coupon */
|
|
|
+ getCoupons: () => request<{ items: CouponItem[] }>('/api/marketing/coupons'),
|
|
|
+ createCoupon: (data: Partial<CouponItem>) =>
|
|
|
+ request<CouponItem>('/api/marketing/coupons', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateCoupon: (id: string, data: Partial<CouponItem>) =>
|
|
|
+ request<CouponItem>(`/api/marketing/coupons/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+ deleteCoupon: (id: string) =>
|
|
|
+ request<{ success: boolean }>(`/api/marketing/coupons/${id}`, { method: 'DELETE' }),
|
|
|
+
|
|
|
+ /* Marketing: Price Watch */
|
|
|
+ getPriceWatches: () => request<{ items: PriceWatchItem[] }>('/api/marketing/price-watches'),
|
|
|
+ updatePriceWatch: (id: string, data: Partial<PriceWatchItem>) =>
|
|
|
+ request<PriceWatchItem>(`/api/marketing/price-watches/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* System: Notification */
|
|
|
+ getNotifications: () => request<{ items: NotificationItem[] }>('/api/system/notifications'),
|
|
|
+ markNotificationRead: (id: string) =>
|
|
|
+ request<NotificationItem>(`/api/system/notifications/${id}/read`, { method: 'PUT' }),
|
|
|
+
|
|
|
+ /* System: Message Template */
|
|
|
+ getMessageTemplates: () => request<{ items: MessageTemplateItem[] }>('/api/system/message-templates'),
|
|
|
+ createMessageTemplate: (data: Partial<MessageTemplateItem>) =>
|
|
|
+ request<MessageTemplateItem>('/api/system/message-templates', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateMessageTemplate: (id: string, data: Partial<MessageTemplateItem>) =>
|
|
|
+ request<MessageTemplateItem>(`/api/system/message-templates/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* System: Approval Flow */
|
|
|
+ getApprovalFlows: () => request<{ items: ApprovalFlowItem[] }>('/api/system/approval-flows'),
|
|
|
+ createApprovalFlow: (data: Partial<ApprovalFlowItem>) =>
|
|
|
+ request<ApprovalFlowItem>('/api/system/approval-flows', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateApprovalFlow: (id: string, data: Partial<ApprovalFlowItem>) =>
|
|
|
+ request<ApprovalFlowItem>(`/api/system/approval-flows/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* System: Employee */
|
|
|
+ getEmployees: () => request<{ items: EmployeeItem[] }>('/api/system/employees'),
|
|
|
+ createEmployee: (data: Partial<EmployeeItem>) =>
|
|
|
+ request<EmployeeItem>('/api/system/employees', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateEmployee: (id: string, data: Partial<EmployeeItem>) =>
|
|
|
+ request<EmployeeItem>(`/api/system/employees/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+
|
|
|
+ /* System: Department */
|
|
|
+ getDepartments: () => request<{ items: DepartmentItem[] }>('/api/system/departments'),
|
|
|
+ createDepartment: (data: Partial<DepartmentItem>) =>
|
|
|
+ request<DepartmentItem>('/api/system/departments', { method: 'POST', body: JSON.stringify(data) }),
|
|
|
+ updateDepartment: (id: string, data: Partial<DepartmentItem>) =>
|
|
|
+ request<DepartmentItem>(`/api/system/departments/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
+ deleteDepartment: (id: string) =>
|
|
|
+ request<{ success: boolean }>(`/api/system/departments/${id}`, { method: 'DELETE' }),
|
|
|
+
|
|
|
+ /* Report: Inventory Turnover */
|
|
|
+ getInventoryTurnovers: () => request<{ items: InventoryTurnoverItem[] }>('/api/report/inventory-turnovers'),
|
|
|
+
|
|
|
+ /* Supplier: Performance */
|
|
|
+ getSupplierPerformances: () => request<{ items: SupplierPerformanceItem[] }>('/api/supplier/performances'),
|
|
|
+ createSupplierPerformance: (data: Partial<SupplierPerformanceItem>) =>
|
|
|
+ request<SupplierPerformanceItem>('/api/supplier/performances', { method: 'POST', body: JSON.stringify(data) })
|
|
|
};
|