diff --git a/src/pages/Dashboard/Index.vue b/src/pages/Dashboard/Index.vue index 1b0dd60..cb7a3c1 100644 --- a/src/pages/Dashboard/Index.vue +++ b/src/pages/Dashboard/Index.vue @@ -1,9 +1,233 @@ \ No newline at end of file diff --git a/src/services/reportService.js b/src/services/reportService.js new file mode 100644 index 0000000..5d9e8e7 --- /dev/null +++ b/src/services/reportService.js @@ -0,0 +1,57 @@ +import { api, apiURL } from '@Services/Api'; + +const reportService = { + /** + * Fetches the top selling product. + * @param {string|null} fromDate - Start date in YYYY-MM-DD format. + * @param {string|null} toDate - End date in YYYY-MM-DD format. + * @returns {Promise} + */ + async getTopSellingProduct(fromDate = null, toDate = null) { + return new Promise((resolve, reject) => { + const params = {}; + if (fromDate) params.from_date = fromDate; + if (toDate) params.to_date = toDate; + + api.get(apiURL('reports/top-selling-product'), { + params, + onSuccess: (response) => { + resolve(response); + }, + onError: (error) => { + console.error('Error fetching top selling product:', error); + reject(error); + } + }); + }); + }, + + /** + * Fetches products without movement. + * @param {number} daysThreshold - The threshold in days. + * @param {boolean} includeStockValue - Flag to include the inventory value in the response. + * @returns {Promise} + */ + async getProductsWithoutMovement(daysThreshold = 30, includeStockValue = true) { + return new Promise((resolve, reject) => { + const params = { + days_threshold: daysThreshold, + // Convert boolean to 1 or 0 for Laravel validation + include_stock_value: includeStockValue ? 1 : 0 + }; + + api.get(apiURL('reports/products-without-movement'), { + params, + onSuccess: (response) => { + resolve(response); + }, + onError: (error) => { + console.error('Error fetching products without movement:', error); + reject(error); + } + }); + }); + } +}; + +export default reportService; \ No newline at end of file