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 ==================
|
// ================== ADMIN SERVICE ==================
|
||||||
|
const log = (method: string, ...args: unknown[]) => {
|
||||||
|
console.log(`📋 [adminService.${method}]`, ...args)
|
||||||
|
}
|
||||||
|
|
||||||
export const adminService = {
|
export const adminService = {
|
||||||
// Users
|
// Users
|
||||||
listUsers: (page = 1, pageSize = 20) =>
|
listUsers: async (page = 1, pageSize = 20) => {
|
||||||
apiClient.get<UserPage>(`/api/v1/users?page=${page}&page_size=${pageSize}`),
|
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) =>
|
getUser: async (id: string) => {
|
||||||
apiClient.get<User>(`/api/v1/users/${id}`),
|
log('getUser', { id })
|
||||||
|
const result = await apiClient.get<User>(`/api/v1/users/${id}`)
|
||||||
|
log('getUser result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
createUser: (data: CreateUserRequest) =>
|
createUser: async (data: CreateUserRequest) => {
|
||||||
apiClient.post<User>('/api/v1/users', data),
|
log('createUser', data)
|
||||||
|
const result = await apiClient.post<User>('/api/v1/users', data)
|
||||||
|
log('createUser result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
updateUser: (id: string, data: UpdateUserRequest) =>
|
updateUser: async (id: string, data: UpdateUserRequest) => {
|
||||||
apiClient.put<User>(`/api/v1/users/${id}`, data),
|
log('updateUser', { id, data })
|
||||||
|
const result = await apiClient.put<User>(`/api/v1/users/${id}`, data)
|
||||||
|
log('updateUser result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
deleteUser: (id: string) =>
|
deleteUser: async (id: string) => {
|
||||||
apiClient.delete(`/api/v1/users/${id}`),
|
log('deleteUser', { id })
|
||||||
|
const result = await apiClient.delete(`/api/v1/users/${id}`)
|
||||||
|
log('deleteUser done')
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
// Companies
|
// Companies
|
||||||
listCompanies: (page = 1, pageSize = 20) =>
|
listCompanies: async (page = 1, pageSize = 20) => {
|
||||||
apiClient.get<CompanyPage>(`/api/v1/companies?page=${page}&page_size=${pageSize}`),
|
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) =>
|
getCompany: async (id: string) => {
|
||||||
apiClient.get<Company>(`/api/v1/companies/${id}`),
|
log('getCompany', { id })
|
||||||
|
const result = await apiClient.get<Company>(`/api/v1/companies/${id}`)
|
||||||
|
log('getCompany result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
createCompany: (data: CreateCompanyRequest) =>
|
createCompany: async (data: CreateCompanyRequest) => {
|
||||||
apiClient.post<Company>('/api/v1/companies', data),
|
log('createCompany', data)
|
||||||
|
const result = await apiClient.post<Company>('/api/v1/companies', data)
|
||||||
|
log('createCompany result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
updateCompany: (id: string, data: UpdateCompanyRequest) =>
|
updateCompany: async (id: string, data: UpdateCompanyRequest) => {
|
||||||
apiClient.patch<Company>(`/api/v1/companies/${id}`, data),
|
log('updateCompany', { id, data })
|
||||||
|
const result = await apiClient.patch<Company>(`/api/v1/companies/${id}`, data)
|
||||||
|
log('updateCompany result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
deleteCompany: (id: string) =>
|
deleteCompany: async (id: string) => {
|
||||||
apiClient.delete(`/api/v1/companies/${id}`),
|
log('deleteCompany', { id })
|
||||||
|
const result = await apiClient.delete(`/api/v1/companies/${id}`)
|
||||||
|
log('deleteCompany done')
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
verifyCompany: (id: string) =>
|
verifyCompany: async (id: string) => {
|
||||||
apiClient.patch<Company>(`/api/v1/companies/${id}/verify`, {}),
|
log('verifyCompany', { id })
|
||||||
|
const result = await apiClient.patch<Company>(`/api/v1/companies/${id}/verify`, {})
|
||||||
|
log('verifyCompany result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
// Products
|
// Products
|
||||||
listProducts: (page = 1, pageSize = 20) =>
|
listProducts: async (page = 1, pageSize = 20) => {
|
||||||
apiClient.get<ProductPage>(`/api/v1/products?page=${page}&page_size=${pageSize}`),
|
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) =>
|
getProduct: async (id: string) => {
|
||||||
apiClient.get<Product>(`/api/v1/products/${id}`),
|
log('getProduct', { id })
|
||||||
|
const result = await apiClient.get<Product>(`/api/v1/products/${id}`)
|
||||||
|
log('getProduct result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
createProduct: (data: CreateProductRequest) =>
|
createProduct: async (data: CreateProductRequest) => {
|
||||||
apiClient.post<Product>('/api/v1/products', data),
|
log('createProduct', data)
|
||||||
|
const result = await apiClient.post<Product>('/api/v1/products', data)
|
||||||
|
log('createProduct result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
updateProduct: (id: string, data: UpdateProductRequest) =>
|
updateProduct: async (id: string, data: UpdateProductRequest) => {
|
||||||
apiClient.patch<Product>(`/api/v1/products/${id}`, data),
|
log('updateProduct', { id, data })
|
||||||
|
const result = await apiClient.patch<Product>(`/api/v1/products/${id}`, data)
|
||||||
|
log('updateProduct result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
deleteProduct: (id: string) =>
|
deleteProduct: async (id: string) => {
|
||||||
apiClient.delete(`/api/v1/products/${id}`),
|
log('deleteProduct', { id })
|
||||||
|
const result = await apiClient.delete(`/api/v1/products/${id}`)
|
||||||
|
log('deleteProduct done')
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
// Orders
|
// Orders
|
||||||
listOrders: (page = 1, pageSize = 20) =>
|
listOrders: async (page = 1, pageSize = 20) => {
|
||||||
apiClient.get<OrderPage>(`/api/v1/orders?page=${page}&page_size=${pageSize}`),
|
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) =>
|
getOrder: async (id: string) => {
|
||||||
apiClient.get<Order>(`/api/v1/orders/${id}`),
|
log('getOrder', { id })
|
||||||
|
const result = await apiClient.get<Order>(`/api/v1/orders/${id}`)
|
||||||
|
log('getOrder result', result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
updateOrderStatus: (id: string, status: string) =>
|
updateOrderStatus: async (id: string, status: string) => {
|
||||||
apiClient.patch(`/api/v1/orders/${id}/status`, { status }),
|
log('updateOrderStatus', { id, status })
|
||||||
|
const result = await apiClient.patch(`/api/v1/orders/${id}/status`, { status })
|
||||||
|
log('updateOrderStatus done')
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
deleteOrder: (id: string) =>
|
deleteOrder: async (id: string) => {
|
||||||
apiClient.delete(`/api/v1/orders/${id}`),
|
log('deleteOrder', { id })
|
||||||
|
const result = await apiClient.delete(`/api/v1/orders/${id}`)
|
||||||
|
log('deleteOrder done')
|
||||||
|
return result
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue