import { usePublicApi } from '..'; import type { CartResponse, DeleteCartRequest, UpsertCartRequest, ShipmentQuoteCartRequest, SelectShipimentRequest, AddressesToCartRequest, PaymentResponse, BuyCartRequest, BuyCartResponse, PaymentTokenCartRequest, PaymentTokenCartResponse, } from '../types'; export function listDetail() { const response = usePublicApi({ endpoint: '/cart', }); return response; } export function addProduct(payload: UpsertCartRequest) { return usePublicApi({ endpoint: '/cart', method: 'POST', payload, }); } export function upsertProduct(payload: UpsertCartRequest) { return usePublicApi({ endpoint: '/cart', method: 'PUT', payload, }); } export function deleteProduct(payload: DeleteCartRequest) { return usePublicApi({ endpoint: '/cart', method: 'DELETE', payload, }); } export function shipmentQuote(payload: ShipmentQuoteCartRequest) { return usePublicApi({ endpoint: '/cart/quote', method: 'POST', payload, }); } export function selectShipment(payload: SelectShipimentRequest) { return usePublicApi({ endpoint: '/cart/shipping', method: 'PUT', payload, }); } export function applyAddresses(payload: AddressesToCartRequest) { return usePublicApi({ endpoint: '/cart/address', method: 'PUT', payload, }); } export function applyWallet() { return usePublicApi({ endpoint: '/cart/promotionals/customer-wallet', method: 'POST', }); } export function deleteWallet() { return usePublicApi({ endpoint: '/cart/promotionals/customer-wallet', method: 'DELETE', }); } export function applyPoint() { return usePublicApi({ endpoint: '/cart/promotionals/point-system', method: 'POST', }); } export function deletePoint() { return usePublicApi({ endpoint: '/cart/promotionals/point-system', method: 'DELETE', }); } export function listPayments() { return usePublicApi({ endpoint: '/cart/payments', method: 'GET', }); } export function buy(payload: BuyCartRequest) { return usePublicApi({ endpoint: '/cart/buy', method: 'POST', payload, }); } export function paymentToken(payload: PaymentTokenCartRequest) { return usePublicApi({ endpoint: '/cart/payment-token', method: 'POST', payload, }); } export function recovery(recoveryCode: string) { const response = usePublicApi({ endpoint: `/cart/recovery/${recoveryCode}`, }); return response; }