| | |
| | | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification |
| | | // for details on configuring this project to bundle and minify static web assets. |
| | | |
| | | // API Base URL |
| | | const API_BASE_URL = '/api'; |
| | | // API Base URL (configured server-side) |
| | | const API_BASE_URL = window.API_BASE_URL || '/api'; |
| | | |
| | | // Show toast notification |
| | | function showToast(message, type = 'info') { |
| | |
| | | |
| | | // API call helper |
| | | async function apiCall(url, options = {}) { |
| | | const { silent = false, ...fetchOptions } = options; |
| | | |
| | | try { |
| | | if (!silent) { |
| | | showLoading(); |
| | | } |
| | | const response = await fetch(url, { |
| | | ...options, |
| | | ...fetchOptions, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | ...options.headers |
| | | ...fetchOptions.headers |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | return await response.json(); |
| | | } catch (error) { |
| | | if (!silent) { |
| | | showToast(error.message, 'error'); |
| | | } |
| | | throw error; |
| | | } finally { |
| | | if (!silent) { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Format date |
| | | function formatDate(dateString) { |