@@ -54,6 +80,28 @@
+
+
+
+
+
diff --git a/js/app.js b/js/app.js
index a75a181..ae78b0c 100644
--- a/js/app.js
+++ b/js/app.js
@@ -9,6 +9,8 @@ function salesApp() {
// Authentication state
isLoggedIn: false,
isLoading: true,
+ isLoadingProducts: false,
+ loadingMessage: '',
currentUser: '',
userRole: '',
loginForm: { username: '', password: '' },
@@ -75,7 +77,14 @@ function salesApp() {
this.userRole = result.data.role || 'agent';
localStorage.setItem('telvero_user', result.data.user);
localStorage.setItem('telvero_role', result.data.role || 'agent');
+
+ // Show loading indicator while fetching products
+ this.isLoadingProducts = true;
+ this.loadingMessage = 'Productgegevens ophalen...';
await this.loadProducts();
+ this.isLoadingProducts = false;
+ this.loadingMessage = '';
+
this.isLoggedIn = true;
} else {
alert("Login mislukt");
diff --git a/js/components/products.js b/js/components/products.js
index ba30b64..b8161e7 100644
--- a/js/components/products.js
+++ b/js/components/products.js
@@ -31,11 +31,21 @@ const ProductsComponent = {
*/
async loadProducts() {
try {
+ if (this.isLoadingProducts) {
+ this.loadingMessage = 'Productgegevens ophalen van server...';
+ }
const data = await ApiService.getProducts();
+
+ if (this.isLoadingProducts) {
+ this.loadingMessage = 'Producten verwerken...';
+ }
// Sort products alphabetically by name
this.products = data.sort((a, b) => a.name.localeCompare(b.name, 'nl'));
} catch (e) {
console.error("Failed to load products");
+ if (this.isLoadingProducts) {
+ this.loadingMessage = 'Fout bij laden producten';
+ }
}
},