feat: display available stock balance on products page based on n8n inventory updates

This commit is contained in:
Cauê Faleiros
2026-05-25 11:26:00 -03:00
parent 4ce1e9aedb
commit c47a64d831
4 changed files with 120 additions and 6 deletions

View File

@@ -33,6 +33,25 @@ export const isAuthenticated = (): boolean => {
return !!localStorage.getItem('auth_token');
};
export const fetchStock = async (): Promise<any[]> => {
try {
const token = localStorage.getItem('auth_token');
const response = await fetch(`${API_URL}/stock`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
if (response.status === 401 || response.status === 403) {
logout();
return [];
}
if (!response.ok) return [];
return await response.json();
} catch (error) {
return [];
}
};
export const fetchData = async (): Promise<OrderData[]> => {
try {
const token = localStorage.getItem('auth_token');