frontend fully integreated with the backend
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type {
|
||||
PaginatedResponse,
|
||||
StoreResponse,
|
||||
KycDocumentResponse,
|
||||
OutstandingBalanceResponse,
|
||||
StoreDashboardResponse,
|
||||
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<PaginatedResponse<StoreResponse>>('/stores', { params }).then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<StoreResponse>(`/stores/${id}`).then(r => r.data),
|
||||
|
||||
create: (body: StoreBody) =>
|
||||
api.post<StoreResponse>('/stores', body).then(r => r.data),
|
||||
|
||||
update: (id: string, body: Partial<StoreBody>) =>
|
||||
api.put<StoreResponse>(`/stores/${id}`, body).then(r => r.data),
|
||||
|
||||
outstandingBalance: (id: string) =>
|
||||
api.get<OutstandingBalanceResponse>(`/stores/${id}/outstanding-balance`).then(r => r.data),
|
||||
|
||||
dashboard: (id: string, period?: string) =>
|
||||
api.get<StoreDashboardResponse>(`/stores/${id}/dashboard`, { params: { period } }).then(r => r.data),
|
||||
|
||||
kycDocuments: (id: string) =>
|
||||
api.get<KycDocumentResponse[]>(`/stores/${id}/kyc-documents`).then(r => r.data),
|
||||
|
||||
uploadKycDocument: (id: string, documentType: string, fileReference: string) =>
|
||||
api.post<KycDocumentResponse>(`/stores/${id}/kyc-documents`, { documentType, fileReference }).then(r => r.data),
|
||||
|
||||
updateKycStatus: (id: string, kycStatus: KycStatus) =>
|
||||
api.patch<StoreResponse>(`/stores/${id}/kyc-status`, { kycStatus }).then(r => r.data),
|
||||
}
|
||||
Reference in New Issue
Block a user