pre-clean

Signed-off-by: boris <boris@borishub.co.uk>
This commit is contained in:
boris
2025-04-21 21:24:46 +01:00
parent 78508a7cbd
commit 8877faa631
15 changed files with 1302 additions and 407 deletions

View File

@@ -133,21 +133,30 @@ class ApiClient {
});
try {
// Validate auth state before making request
if (!this.authFetch) {
throw new Error('Auth fetch not available');
}
if (action === 'status' && (!data.facilityId || !data.statusComment)) {
throw new Error('Missing required data for status update');
}
// Use authenticated fetch for all facility requests
const response = await this.authFetch('/facilitycontroller.php', {
method: 'POST',
body: formData,
requireAuth: true // Explicitly require authentication
requireAuth: true
});
// Parse the response
const jsonData = await response.json();
// Check if response is ok
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
throw new Error(`HTTP error! status: ${response.status}, message: ${jsonData.error || 'Unknown error'}`);
}
// Parse the JSON response
const jsonData = await response.json();
console.log('Facility API response:', { action, data: jsonData });
return jsonData;
} catch (error) {
console.error('Facility API error:', error);
@@ -242,7 +251,11 @@ class ApiClient {
* @returns {Promise<Object>} The response data
*/
async updateFacilityStatus(statusId, editStatus, facilityId) {
return this.facility('editStatus', { statusId, editStatus, facilityId });
return this.facility('editStatus', {
statusId: statusId,
statusComment: editStatus,
facilityId: facilityId
});
}
/**
@@ -259,7 +272,7 @@ class ApiClient {
}
}
// Initialize API client
// initialise API client
const api = new ApiClient();
// Export API client