feat(marketplace): add console logging to adminService for debugging
This commit is contained in:
parent
59919cb875
commit
460303e90e
1 changed files with 125 additions and 40 deletions
|
|
@ -154,68 +154,153 @@ export interface OrderPage {
|
|||
}
|
||||
|
||||
// ================== ADMIN SERVICE ==================
|
||||
const log = (method: string, ...args: unknown[]) => {
|
||||
console.log(`📋 [adminService.${method}]`, ...args)
|
||||
}
|
||||
|
||||
export const adminService = {
|
||||
// Users
|
||||
listUsers: (page = 1, pageSize = 20) =>
|
||||
apiClient.get<UserPage>(`/api/v1/users?page=${page}&page_size=${pageSize}`),
|
||||
listUsers: async (page = 1, pageSize = 20) => {
|
||||
log('listUsers', { page, pageSize })
|
||||
const result = await apiClient.get<UserPage>(`/api/v1/users?page=${page}&page_size=${pageSize}`)
|
||||
log('listUsers result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
getUser: (id: string) =>
|
||||
apiClient.get<User>(`/api/v1/users/${id}`),
|
||||
getUser: async (id: string) => {
|
||||
log('getUser', { id })
|
||||
const result = await apiClient.get<User>(`/api/v1/users/${id}`)
|
||||
log('getUser result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
createUser: (data: CreateUserRequest) =>
|
||||
apiClient.post<User>('/api/v1/users', data),
|
||||
createUser: async (data: CreateUserRequest) => {
|
||||
log('createUser', data)
|
||||
const result = await apiClient.post<User>('/api/v1/users', data)
|
||||
log('createUser result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
updateUser: (id: string, data: UpdateUserRequest) =>
|
||||
apiClient.put<User>(`/api/v1/users/${id}`, data),
|
||||
updateUser: async (id: string, data: UpdateUserRequest) => {
|
||||
log('updateUser', { id, data })
|
||||
const result = await apiClient.put<User>(`/api/v1/users/${id}`, data)
|
||||
log('updateUser result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
deleteUser: (id: string) =>
|
||||
apiClient.delete(`/api/v1/users/${id}`),
|
||||
deleteUser: async (id: string) => {
|
||||
log('deleteUser', { id })
|
||||
const result = await apiClient.delete(`/api/v1/users/${id}`)
|
||||
log('deleteUser done')
|
||||
return result
|
||||
},
|
||||
|
||||
// Companies
|
||||
listCompanies: (page = 1, pageSize = 20) =>
|
||||
apiClient.get<CompanyPage>(`/api/v1/companies?page=${page}&page_size=${pageSize}`),
|
||||
listCompanies: async (page = 1, pageSize = 20) => {
|
||||
log('listCompanies', { page, pageSize })
|
||||
const result = await apiClient.get<CompanyPage>(`/api/v1/companies?page=${page}&page_size=${pageSize}`)
|
||||
log('listCompanies result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
getCompany: (id: string) =>
|
||||
apiClient.get<Company>(`/api/v1/companies/${id}`),
|
||||
getCompany: async (id: string) => {
|
||||
log('getCompany', { id })
|
||||
const result = await apiClient.get<Company>(`/api/v1/companies/${id}`)
|
||||
log('getCompany result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
createCompany: (data: CreateCompanyRequest) =>
|
||||
apiClient.post<Company>('/api/v1/companies', data),
|
||||
createCompany: async (data: CreateCompanyRequest) => {
|
||||
log('createCompany', data)
|
||||
const result = await apiClient.post<Company>('/api/v1/companies', data)
|
||||
log('createCompany result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
updateCompany: (id: string, data: UpdateCompanyRequest) =>
|
||||
apiClient.patch<Company>(`/api/v1/companies/${id}`, data),
|
||||
updateCompany: async (id: string, data: UpdateCompanyRequest) => {
|
||||
log('updateCompany', { id, data })
|
||||
const result = await apiClient.patch<Company>(`/api/v1/companies/${id}`, data)
|
||||
log('updateCompany result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
deleteCompany: (id: string) =>
|
||||
apiClient.delete(`/api/v1/companies/${id}`),
|
||||
deleteCompany: async (id: string) => {
|
||||
log('deleteCompany', { id })
|
||||
const result = await apiClient.delete(`/api/v1/companies/${id}`)
|
||||
log('deleteCompany done')
|
||||
return result
|
||||
},
|
||||
|
||||
verifyCompany: (id: string) =>
|
||||
apiClient.patch<Company>(`/api/v1/companies/${id}/verify`, {}),
|
||||
verifyCompany: async (id: string) => {
|
||||
log('verifyCompany', { id })
|
||||
const result = await apiClient.patch<Company>(`/api/v1/companies/${id}/verify`, {})
|
||||
log('verifyCompany result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
// Products
|
||||
listProducts: (page = 1, pageSize = 20) =>
|
||||
apiClient.get<ProductPage>(`/api/v1/products?page=${page}&page_size=${pageSize}`),
|
||||
listProducts: async (page = 1, pageSize = 20) => {
|
||||
log('listProducts', { page, pageSize })
|
||||
const result = await apiClient.get<ProductPage>(`/api/v1/products?page=${page}&page_size=${pageSize}`)
|
||||
log('listProducts result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
getProduct: (id: string) =>
|
||||
apiClient.get<Product>(`/api/v1/products/${id}`),
|
||||
getProduct: async (id: string) => {
|
||||
log('getProduct', { id })
|
||||
const result = await apiClient.get<Product>(`/api/v1/products/${id}`)
|
||||
log('getProduct result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
createProduct: (data: CreateProductRequest) =>
|
||||
apiClient.post<Product>('/api/v1/products', data),
|
||||
createProduct: async (data: CreateProductRequest) => {
|
||||
log('createProduct', data)
|
||||
const result = await apiClient.post<Product>('/api/v1/products', data)
|
||||
log('createProduct result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
updateProduct: (id: string, data: UpdateProductRequest) =>
|
||||
apiClient.patch<Product>(`/api/v1/products/${id}`, data),
|
||||
updateProduct: async (id: string, data: UpdateProductRequest) => {
|
||||
log('updateProduct', { id, data })
|
||||
const result = await apiClient.patch<Product>(`/api/v1/products/${id}`, data)
|
||||
log('updateProduct result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
deleteProduct: (id: string) =>
|
||||
apiClient.delete(`/api/v1/products/${id}`),
|
||||
deleteProduct: async (id: string) => {
|
||||
log('deleteProduct', { id })
|
||||
const result = await apiClient.delete(`/api/v1/products/${id}`)
|
||||
log('deleteProduct done')
|
||||
return result
|
||||
},
|
||||
|
||||
// Orders
|
||||
listOrders: (page = 1, pageSize = 20) =>
|
||||
apiClient.get<OrderPage>(`/api/v1/orders?page=${page}&page_size=${pageSize}`),
|
||||
listOrders: async (page = 1, pageSize = 20) => {
|
||||
log('listOrders', { page, pageSize })
|
||||
const result = await apiClient.get<OrderPage>(`/api/v1/orders?page=${page}&page_size=${pageSize}`)
|
||||
log('listOrders result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
getOrder: (id: string) =>
|
||||
apiClient.get<Order>(`/api/v1/orders/${id}`),
|
||||
getOrder: async (id: string) => {
|
||||
log('getOrder', { id })
|
||||
const result = await apiClient.get<Order>(`/api/v1/orders/${id}`)
|
||||
log('getOrder result', result)
|
||||
return result
|
||||
},
|
||||
|
||||
updateOrderStatus: (id: string, status: string) =>
|
||||
apiClient.patch(`/api/v1/orders/${id}/status`, { status }),
|
||||
updateOrderStatus: async (id: string, status: string) => {
|
||||
log('updateOrderStatus', { id, status })
|
||||
const result = await apiClient.patch(`/api/v1/orders/${id}/status`, { status })
|
||||
log('updateOrderStatus done')
|
||||
return result
|
||||
},
|
||||
|
||||
deleteOrder: (id: string) =>
|
||||
apiClient.delete(`/api/v1/orders/${id}`),
|
||||
deleteOrder: async (id: string) => {
|
||||
log('deleteOrder', { id })
|
||||
const result = await apiClient.delete(`/api/v1/orders/${id}`)
|
||||
log('deleteOrder done')
|
||||
return result
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue