import apiClient from "@/infrastructure/apiClient";
import apiPath from "@/infrastructure/apiPath";

export default {
    /**
     * Tạo model tìm kiếm mặc định
     */
    createDefaultSearchModel() {
        return {
            FromDate: null,
            ToDate: null,
            Page: 1,
            PageSize: 50,
        };
    },

    /**
     * Lấy tổng quan rủi ro đơn hàng
     * @param {Object} filters - { fromDate, toDate }
     */
    async getOrderRiskOverview(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.overview, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting order risk overview:", error);
            return null;
        }
    },

    /**
     * Lấy danh sách đơn hàng thiếu Source Cashier
     * @param {Object} filters - { fromDate, toDate, page, pageSize }
     */
    async getNoSourceCashierList(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
                page: filters.page || 1,
                pageSize: filters.pageSize || 50,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.noSourceCashier, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting no source cashier list:", error);
            return null;
        }
    },

    /**
     * Lấy tổng quan rủi ro đơn hàng thiếu Dest Cashier
     * @param {Object} filters - { fromDate, toDate }
     */
    async getNoDestCashierOverview(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.noDestCashierOverview, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting no dest cashier overview:", error);
            return null;
        }
    },

    /**
     * Lấy danh sách đơn hàng thiếu Dest Cashier
     * @param {Object} filters - { fromDate, toDate, page, pageSize }
     */
    async getNoDestCashierList(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
                page: filters.page || 1,
                pageSize: filters.pageSize || 50,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.noDestCashier, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting no dest cashier list:", error);
            return null;
        }
    },

    /**
     * Lấy tổng quan rủi ro đơn hàng BothPay thiếu Cashier
     * @param {Object} filters - { fromDate, toDate }
     */
    async getBothPayMissingCashierOverview(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.bothPayMissingCashierOverview, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting both pay missing cashier overview:", error);
            return null;
        }
    },

    /**
     * Lấy danh sách đơn hàng BothPay thiếu Cashier
     * @param {Object} filters - { fromDate, toDate, page, pageSize }
     */
    async getBothPayMissingCashierList(filters = {}) {
        try {
            const params = {
                fromDate: filters.fromDate || null,
                toDate: filters.toDate || null,
                page: filters.page || 1,
                pageSize: filters.pageSize || 50,
            };

            const response = await apiClient.get(apiPath.monitor.orderRisk.bothPayMissingCashier, {
                params,
            });

            return response.data || null;
        } catch (error) {
            console.error("Error getting both pay missing cashier list:", error);
            return null;
        }
    },
};
