refactor: modularize road management modules
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axiosClient from '../axios/axios';
|
||||
import { API_ROUTES } from '@/constants/apiRoutes';
|
||||
import {
|
||||
Chainage,
|
||||
ChainageCreate,
|
||||
@@ -7,8 +8,6 @@ import {
|
||||
PaginationParams,
|
||||
} from '@/types';
|
||||
|
||||
const CHAINAGES_ENDPOINT = 'biz/api/v1/chainages';
|
||||
|
||||
/**
|
||||
* Chainage Service
|
||||
*/
|
||||
@@ -19,7 +18,7 @@ export const chainageService = {
|
||||
getChainages: async (params?: PaginationParams): Promise<PaginatedResponse<Chainage>> => {
|
||||
const skip = params?.skip ?? 0;
|
||||
const limit = params?.limit ?? 100;
|
||||
const response = await axiosClient.get<PaginatedResponse<Chainage>>(CHAINAGES_ENDPOINT, {
|
||||
const response = await axiosClient.get<PaginatedResponse<Chainage>>(API_ROUTES.CHAINAGES.BASE, {
|
||||
params: { skip, limit },
|
||||
});
|
||||
return response.data;
|
||||
@@ -34,7 +33,7 @@ export const chainageService = {
|
||||
): Promise<PaginatedResponse<Chainage>> => {
|
||||
const skip = params?.skip ?? 0;
|
||||
const limit = params?.limit ?? 100;
|
||||
const response = await axiosClient.get<PaginatedResponse<Chainage>>(CHAINAGES_ENDPOINT, {
|
||||
const response = await axiosClient.get<PaginatedResponse<Chainage>>(API_ROUTES.CHAINAGES.BASE, {
|
||||
params: { package_id: packageId, skip, limit },
|
||||
});
|
||||
return response.data;
|
||||
@@ -44,7 +43,7 @@ export const chainageService = {
|
||||
* Create a new chainage
|
||||
*/
|
||||
createChainage: async (data: ChainageCreate): Promise<Chainage> => {
|
||||
const response = await axiosClient.post<Chainage>(CHAINAGES_ENDPOINT, data);
|
||||
const response = await axiosClient.post<Chainage>(API_ROUTES.CHAINAGES.BASE, data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -52,7 +51,7 @@ export const chainageService = {
|
||||
* Update an existing chainage
|
||||
*/
|
||||
updateChainage: async (chainageId: string, data: ChainageUpdate): Promise<Chainage> => {
|
||||
const response = await axiosClient.put<Chainage>(`${CHAINAGES_ENDPOINT}/${chainageId}`, data);
|
||||
const response = await axiosClient.put<Chainage>(API_ROUTES.CHAINAGES.DETAIL(chainageId), data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -61,7 +60,7 @@ export const chainageService = {
|
||||
*/
|
||||
deleteChainage: async (chainageId: string): Promise<{ message: string }> => {
|
||||
const response = await axiosClient.delete<{ message: string }>(
|
||||
`${CHAINAGES_ENDPOINT}/${chainageId}`,
|
||||
API_ROUTES.CHAINAGES.DETAIL(chainageId),
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user