frontend fully integreated with the backend
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type {
|
||||
PaginatedResponse,
|
||||
PriceListResponse,
|
||||
SchemeResponse,
|
||||
SchemeRuleType,
|
||||
} from '@/types/api'
|
||||
|
||||
import type { PageParams } from './master'
|
||||
|
||||
// ─── Price Lists ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface PriceListItemBody {
|
||||
itemId: string
|
||||
price: number
|
||||
minPrice?: number | null
|
||||
}
|
||||
|
||||
export interface PriceListBody {
|
||||
name: string
|
||||
regionId?: string | null
|
||||
effectiveFrom: string
|
||||
effectiveTo: string
|
||||
isActive?: boolean
|
||||
items: PriceListItemBody[]
|
||||
}
|
||||
|
||||
export interface PriceListListParams extends PageParams {
|
||||
regionId?: string
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export const priceLists = {
|
||||
list: (params?: PriceListListParams) =>
|
||||
api.get<PaginatedResponse<PriceListResponse>>('/price-lists', { params }).then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<PriceListResponse>(`/price-lists/${id}`).then(r => r.data),
|
||||
|
||||
create: (body: PriceListBody) =>
|
||||
api.post<PriceListResponse>('/price-lists', body).then(r => r.data),
|
||||
|
||||
update: (id: string, body: Partial<PriceListBody>) =>
|
||||
api.put<PriceListResponse>(`/price-lists/${id}`, body).then(r => r.data),
|
||||
}
|
||||
|
||||
// ─── Schemes ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface BundleComponentBody {
|
||||
itemId: string
|
||||
qty: number
|
||||
}
|
||||
|
||||
export interface SchemeBody {
|
||||
name: string
|
||||
ruleType: SchemeRuleType
|
||||
ruleConfig?: string | null
|
||||
triggerItemId?: string | null
|
||||
triggerQty?: number
|
||||
freeItemId?: string | null
|
||||
freeQty?: number
|
||||
bundleComponents?: BundleComponentBody[]
|
||||
regionId?: string | null
|
||||
eligibleSegment?: string | null
|
||||
dateRangeFrom: string
|
||||
dateRangeTo: string
|
||||
agentLimitExempt?: boolean
|
||||
baselineExpectedSales?: number
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export interface SchemeListParams extends PageParams {
|
||||
regionId?: string
|
||||
isActive?: boolean
|
||||
}
|
||||
|
||||
export const schemes = {
|
||||
list: (params?: SchemeListParams) =>
|
||||
api.get<PaginatedResponse<SchemeResponse>>('/schemes', { params }).then(r => r.data),
|
||||
|
||||
get: (id: string) =>
|
||||
api.get<SchemeResponse>(`/schemes/${id}`).then(r => r.data),
|
||||
|
||||
create: (body: SchemeBody) =>
|
||||
api.post<SchemeResponse>('/schemes', body).then(r => r.data),
|
||||
|
||||
update: (id: string, body: Partial<SchemeBody>) =>
|
||||
api.put<SchemeResponse>(`/schemes/${id}`, body).then(r => r.data),
|
||||
}
|
||||
Reference in New Issue
Block a user