import { api } from '@/lib/api' import type { PaginatedResponse, StoreResponse, KycDocumentResponse, OutstandingBalanceResponse, StoreDashboardResponse, StoreVisitHistoryItem, KycStatus, } from '@/types/api' import type { PageParams } from './master' // ─── Stores ─────────────────────────────────────────────────────────────────── export interface StoreBody { routeId: string ownerName: string storeName: string storeAddress: string latitude: number longitude: number oneTimeAmount?: number creditLimit?: number segment?: string | null isActive?: boolean } export interface StoreListParams extends PageParams { routeId?: string kycStatus?: KycStatus search?: string } export const stores = { list: (params?: StoreListParams) => api.get>('/stores', { params }).then(r => r.data), get: (id: string) => api.get(`/stores/${id}`).then(r => r.data), create: (body: StoreBody) => api.post('/stores', body).then(r => r.data), update: (id: string, body: Partial) => api.put(`/stores/${id}`, body).then(r => r.data), updateStatus: (id: string, isActive: boolean) => api.patch(`/stores/${id}/status`, { isActive }).then(r => r.data), outstandingBalance: (id: string) => api.get(`/stores/${id}/outstanding-balance`).then(r => r.data), dashboard: (id: string, period?: string) => api.get(`/stores/${id}/dashboard`, { params: { period } }).then(r => r.data), kycDocuments: (id: string) => api.get(`/stores/${id}/kyc-documents`).then(r => r.data), uploadKycDocument: (id: string, documentType: string, fileReference: string) => api.post(`/stores/${id}/kyc-documents`, { documentType, fileReference }).then(r => r.data), updateKycStatus: (id: string, kycStatus: KycStatus) => api.patch(`/stores/${id}/kyc-status`, { kycStatus }).then(r => r.data), visitHistory: (id: string) => api.get(`/stores/${id}/visit-history`).then(r => r.data), }