chore: update eslint and prettier configuration
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import axiosClient from '../axios/axios';
|
||||
import { API_ROUTES } from '@/constants/apiRoutes';
|
||||
import type { Plan, PlanListParams, PlanListResponse, PlanRequest } from '@/types';
|
||||
import type {
|
||||
Plan,
|
||||
PlanListParams,
|
||||
PlanListResponse,
|
||||
PlanRequest,
|
||||
} from '@/types';
|
||||
|
||||
function toPlanPayload(payload: PlanRequest) {
|
||||
return {
|
||||
@@ -22,34 +27,43 @@ function toPlanPayload(payload: PlanRequest) {
|
||||
|
||||
export const planService = {
|
||||
getPlans: async (params?: PlanListParams): Promise<PlanListResponse> => {
|
||||
const response = await axiosClient.get<PlanListResponse>(API_ROUTES.PLANS.BASE, {
|
||||
params: {
|
||||
skip: params?.skip ?? 0,
|
||||
limit: params?.limit ?? 10,
|
||||
search_term: params?.search_term,
|
||||
name: params?.name,
|
||||
slug: params?.slug,
|
||||
is_active: params?.is_active,
|
||||
is_custom: params?.is_custom,
|
||||
sort_by: params?.sort_by,
|
||||
sort_order: params?.sort_order,
|
||||
const response = await axiosClient.get<PlanListResponse>(
|
||||
API_ROUTES.PLANS.BASE,
|
||||
{
|
||||
params: {
|
||||
skip: params?.skip ?? 0,
|
||||
limit: params?.limit ?? 10,
|
||||
search_term: params?.search_term,
|
||||
name: params?.name,
|
||||
slug: params?.slug,
|
||||
is_active: params?.is_active,
|
||||
is_custom: params?.is_custom,
|
||||
sort_by: params?.sort_by,
|
||||
sort_order: params?.sort_order,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
savePlan: async (payload: PlanRequest): Promise<Plan> => {
|
||||
const requestPayload = toPlanPayload(payload);
|
||||
const response = payload.id
|
||||
? await axiosClient.put<Plan>(API_ROUTES.PLANS.DETAIL(payload.id), requestPayload)
|
||||
? await axiosClient.put<Plan>(
|
||||
API_ROUTES.PLANS.DETAIL(payload.id),
|
||||
requestPayload,
|
||||
)
|
||||
: await axiosClient.post<Plan>(API_ROUTES.PLANS.BASE, requestPayload);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updatePlanStatus: async (id: number, isActive: boolean): Promise<Plan> => {
|
||||
const response = await axiosClient.patch<Plan>(API_ROUTES.PLANS.STATUS(id), {
|
||||
is_active: isActive,
|
||||
});
|
||||
const response = await axiosClient.patch<Plan>(
|
||||
API_ROUTES.PLANS.STATUS(id),
|
||||
{
|
||||
is_active: isActive,
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user