| 1 |
import { analyticsApi } from '../api/analyticsApi'; |
| 2 |
|
| 3 |
export const campaignsApi = analyticsApi.injectEndpoints({ |
| 4 |
endpoints: (builder) => ({ |
| 5 |
// GET /analytics/campaigns |
| 6 |
getCampaigns: builder.query({ |
| 7 |
query: ({ |
| 8 |
date_from, |
| 9 |
date_to, |
| 10 |
search, |
| 11 |
customer_id, |
| 12 |
sort_by = 'revenue', |
| 13 |
order = 'desc', |
| 14 |
page = 1, |
| 15 |
limit = 10, |
| 16 |
} = {}) => ({ |
| 17 |
url: '/campaigns', |
| 18 |
params: { date_from, date_to, search, customer_id, sort_by, order, page, limit }, |
| 19 |
}), |
| 20 |
}), |
| 21 |
|
| 22 |
// GET /analytics/campaigns/{id} |
| 23 |
getCampaign: builder.query({ |
| 24 |
query: ({ id, date_from, date_to }) => ({ |
| 25 |
url: `/campaigns/${id}`, |
| 26 |
params: { date_from, date_to }, |
| 27 |
}), |
| 28 |
}), |
| 29 |
}), |
| 30 |
}); |
| 31 |
|
| 32 |
export const { |
| 33 |
useGetCampaignsQuery, |
| 34 |
useGetCampaignQuery, |
| 35 |
} = campaignsApi; |
| 36 |
|