cambios para produccion
This commit is contained in:
31
src/services/storeStatusService.js
Normal file
31
src/services/storeStatusService.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Service for fetching real-time store connectivity status
|
||||
*/
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL;
|
||||
|
||||
/**
|
||||
* Fetch store status from the backend
|
||||
* @param {string} clientId - Client ID (2 for Peru, 3 for Colombia)
|
||||
* @returns {Promise<Array>} Array of store status objects
|
||||
*/
|
||||
export const fetchStoreStatus = async (clientId) => {
|
||||
try {
|
||||
const url = `${API_URL}/stores/status?filter=all&id_cliente=${clientId}`;
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP Error: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Return the stores array from the response
|
||||
return data.stores || [];
|
||||
} catch (error) {
|
||||
console.error('Error fetching store status:', error);
|
||||
// Return empty array on error to prevent breaking the UI
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user