Add frontend types and API client methods for region management
Adds RegionalTargetResponse, RegionalBudgetResponse, RegionAgencyMapResponse, RegionalTaxRuleResponse, RegionHierarchyResponse, and RegionDashboardResponse types, plus setTarget/setBudget/mapAgency/setTaxRule/hierarchy/dashboard methods on the regions API client, mirroring the new backend endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,12 @@ import { api } from '@/lib/api'
|
|||||||
import type {
|
import type {
|
||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
RegionResponse,
|
RegionResponse,
|
||||||
|
RegionalTargetResponse,
|
||||||
|
RegionalBudgetResponse,
|
||||||
|
RegionAgencyMapResponse,
|
||||||
|
RegionalTaxRuleResponse,
|
||||||
|
RegionHierarchyResponse,
|
||||||
|
RegionDashboardResponse,
|
||||||
RouteResponse,
|
RouteResponse,
|
||||||
VehicleResponse,
|
VehicleResponse,
|
||||||
WarehouseResponse,
|
WarehouseResponse,
|
||||||
@@ -96,6 +102,24 @@ export const regions = {
|
|||||||
|
|
||||||
remove: (id: string) =>
|
remove: (id: string) =>
|
||||||
api.delete(`/regions/${id}`),
|
api.delete(`/regions/${id}`),
|
||||||
|
|
||||||
|
setTarget: (id: string, period: string, targetValue: number) =>
|
||||||
|
api.put<RegionalTargetResponse>(`/regions/${id}/targets/${period}`, { targetValue }).then(r => r.data),
|
||||||
|
|
||||||
|
setBudget: (id: string, period: string, budgetAmount: number) =>
|
||||||
|
api.put<RegionalBudgetResponse>(`/regions/${id}/budgets/${period}`, { budgetAmount }).then(r => r.data),
|
||||||
|
|
||||||
|
mapAgency: (id: string, agencyUserId: string) =>
|
||||||
|
api.post<RegionAgencyMapResponse>(`/regions/${id}/agencies`, { agencyUserId }).then(r => r.data),
|
||||||
|
|
||||||
|
setTaxRule: (id: string, ruleConfig: string) =>
|
||||||
|
api.put<RegionalTaxRuleResponse>(`/regions/${id}/tax-rule`, { ruleConfig }).then(r => r.data),
|
||||||
|
|
||||||
|
hierarchy: (id: string) =>
|
||||||
|
api.get<RegionHierarchyResponse>(`/regions/${id}/hierarchy`).then(r => r.data),
|
||||||
|
|
||||||
|
dashboard: (id: string, period?: string) =>
|
||||||
|
api.get<RegionDashboardResponse>(`/regions/${id}/dashboard`, { params: { period } }).then(r => r.data),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Routes ───────────────────────────────────────────────────────────────────
|
// ─── Routes ───────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -85,6 +85,50 @@ export interface RouteResponse {
|
|||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RegionalTargetResponse {
|
||||||
|
regionId: string
|
||||||
|
period: string
|
||||||
|
targetValue: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionalBudgetResponse {
|
||||||
|
regionId: string
|
||||||
|
period: string
|
||||||
|
budgetAmount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionAgencyMapResponse {
|
||||||
|
regionId: string
|
||||||
|
agencyUserId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionalTaxRuleResponse {
|
||||||
|
regionId: string
|
||||||
|
ruleConfig: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionHierarchyRouteItem {
|
||||||
|
routeId: string
|
||||||
|
routeName: string
|
||||||
|
storeIds: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionHierarchyResponse {
|
||||||
|
regionId: string
|
||||||
|
regionName: string
|
||||||
|
routes: RegionHierarchyRouteItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionDashboardResponse {
|
||||||
|
regionId: string
|
||||||
|
period: string
|
||||||
|
targetValue: number | null
|
||||||
|
budgetAmount: number | null
|
||||||
|
orderCount: number
|
||||||
|
actualSales: number
|
||||||
|
lastOrderDate: string | null
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Vehicles / Warehouses ───────────────────────────────────────────────────
|
// ─── Vehicles / Warehouses ───────────────────────────────────────────────────
|
||||||
|
|
||||||
export interface VehicleResponse {
|
export interface VehicleResponse {
|
||||||
|
|||||||
Reference in New Issue
Block a user