| 1 |
import { analyticsApi } from '../api/analyticsApi'; |
| 2 |
|
| 3 |
export const customersApi = analyticsApi.injectEndpoints({ |
| 4 |
endpoints: (builder) => ({ |
| 5 |
// GET /analytics/customers |
| 6 |
getCustomers: builder.query({ |
| 7 |
query: ({ |
| 8 |
date_from, |
| 9 |
date_to, |
| 10 |
search, |
| 11 |
sort_by = 'total_spent', |
| 12 |
order = 'asc', |
| 13 |
campaign_id, |
| 14 |
order_id, |
| 15 |
page = 1, |
| 16 |
limit = 10, |
| 17 |
} = {}) => ({ |
| 18 |
url: '/customers', |
| 19 |
params: { date_from, date_to, search, sort_by, order, campaign_id, order_id, page, limit }, |
| 20 |
}), |
| 21 |
}), |
| 22 |
|
| 23 |
// GET /analytics/customers/{id} |
| 24 |
getCustomer: builder.query({ |
| 25 |
query: ({ id, date_from, date_to }) => ({ |
| 26 |
url: `/customers/${id}`, |
| 27 |
params: { date_from, date_to }, |
| 28 |
}), |
| 29 |
}), |
| 30 |
}), |
| 31 |
}); |
| 32 |
|
| 33 |
export const { |
| 34 |
useGetCustomersQuery, |
| 35 |
useGetCustomerQuery, |
| 36 |
} = customersApi; |
| 37 |
|