/**
* @file
* File : ordersApiSlice.js\
* Defines API endpoints for managing orders using RTK Query.
* Extends the base API slice with order-related endpoints.
*
* @author Pierre-Yves Léglise <contact@axialdata.net>
* @name ordersGroupsStatusApiSlice
*/
import { apiSlice } from './apiSlice'
export const ordersGroupsStatusApiSlice = apiSlice.injectEndpoints({
/**
* Injects additional endpoints related to orders into the base API slice.
* Defines endpoints for querying orders based on order groups.
*
* @category ApiSlice
* @function
* @author Pierre-Yves Léglise <contact@axialdata.net>
* @param {Object} builder - RTK Query endpoints builder.
* @example
* const { data, isLoading, isFetching } = useGetOrdersListQuery({
* ordersGroupNb: selectedOrdersGroupNb,
* })
* @returns {Object} Object containing order-related endpoint definitions.
*/
endpoints: (builder) => ({
/**
* Endpoint for retrieving a list of orders within a specific orders group.
* Sends a GET request to the `/ordersgroups/{ordersGroupNb}/orders` endpoint.
*
* @method
* @author Pierre-Yves Léglise <contact@axialdata.net>
* @name getOrdersList
* @param {Object} params - Query parameters for the request.
* @param {string} params.ordersGroupNb - The identifier of the orders group.
* @param {Object} [params.params] - Additional query parameters for filtering or pagination.
* @example
* const { data, isLoading, isFetching } = useGetOrdersListQuery({
* ordersGroupNb: selectedOrdersGroupNb,
* })
* @returns {Object} Result of the API request.
*/
listOrdersGroupsStatus: builder.query({
query: (params) => ({
url: `/ordersgroupsstatus`,
method: 'get',
withCredentials: true,
params: { ...params },
}),
}),
}),
})
/**
* Hooks for interacting with the orders-related endpoints.
*
* @typedef {Object} Hooks
* @author Pierre-Yves Léglise <contact@axialdata.net>
* @property {Function} useGetOrdersListQuery - Hook to trigger the getOrdersList query.
* @example
* const { data, isLoading, isFetching } = useGetOrdersListQuery({
* ordersGroupNb: selectedOrdersGroupNb,
* })
* @returns {Object} Object containing order-related endpoint hooks.
*/
export const { useListOrdersGroupsStatusQuery } = ordersGroupsStatusApiSlice