UNPKG

@koia-ai/koia-eshop-sdk

Version:

A configurable React context provider for e-commerce functionality with cart management, discount codes, order processing, and API client for product management

59 lines 1.43 kB
export interface CartItem { id: string; name: string; price: number; quantity: number; } export interface Product { id: string; name: string; description: string; price: number; organization_id: string; created_at: string; updated_at: string; organizations: { id: string; name: string; slug: string; }; } export interface EshopConfig { discountCodes?: Record<string, number>; apiEndpoint?: string; storageKeys?: { cart?: string; discountCode?: string; discountPercentage?: string; }; } export interface EshopContextType { cart: CartItem[]; addToCart: (item: CartItem) => void; removeFromCart: (id: string) => void; removeOneFromCart: (id: string) => void; clearCart: () => void; applyDiscountCode: (code: string) => boolean; removeDiscountCode: () => void; discountCode: string | null; discountPercentage: number; subtotal: number; total: number; shippingCost: number; setShippingCost: (cost: number) => void; finalizeOrder: (customerInfo: any) => Promise<{ order: any; }>; } export interface EshopProviderProps { children: React.ReactNode; config?: EshopConfig; } export interface ApiResponse<T> { data?: T; error?: string; } export interface ProductsResponse { products: Product[]; } //# sourceMappingURL=index.d.ts.map