🎉 Feature: Enhanced Admin Guest Requests API & Startup Initialization Documentation 📚

This commit is contained in:
Till Tomczak
2025-06-20 08:36:07 +02:00
parent 939f14199d
commit cbea4cb765
27 changed files with 1653 additions and 52 deletions

View File

@ -93,7 +93,7 @@ async function loadGuestRequests() {
try {
showLoading(true);
const url = `${API_BASE_URL}/api/admin/guest-requests`;
const url = `${API_BASE_URL}/api/admin/requests`;
const response = await fetch(url, {
method: 'GET',
headers: {
@ -138,7 +138,7 @@ function updateStats(stats) {
const elements = {
'pending-count': stats.pending || 0,
'approved-count': stats.approved || 0,
'rejected-count': stats.rejected || 0,
'rejected-count': stats.denied || stats.rejected || 0,
'total-count': stats.total || 0
};
@ -289,7 +289,7 @@ function createRequestRow(request) {
<td class="px-6 py-4">
<div class="text-sm text-slate-900 dark:text-white font-medium">${escapeHtml(request.file_name || 'Keine Datei')}</div>
<div class="text-sm text-slate-500 dark:text-slate-400">
${request.duration_minutes ? `${request.duration_minutes} Min.` : 'Unbekannte Dauer'}
${request.duration_min ? `${request.duration_min} Min.` : 'Unbekannte Dauer'}
${request.copies ? `${request.copies} Kopien` : ''}
</div>
${request.reason ? `<div class="text-xs text-slate-400 dark:text-slate-500 mt-1 truncate max-w-xs">${escapeHtml(request.reason)}</div>` : ''}
@ -378,6 +378,7 @@ function getStatusColor(status) {
'pending': 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300',
'approved': 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300',
'rejected': 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300',
'denied': 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300',
'expired': 'bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300'
};
return colors[status] || 'bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300';
@ -388,6 +389,7 @@ function getStatusDot(status) {
'pending': 'bg-yellow-400 dark:bg-yellow-300',
'approved': 'bg-green-400 dark:bg-green-300',
'rejected': 'bg-red-400 dark:bg-red-300',
'denied': 'bg-red-400 dark:bg-red-300',
'expired': 'bg-gray-400 dark:bg-gray-300'
};
return dots[status] || 'bg-gray-400 dark:bg-gray-300';
@ -398,6 +400,7 @@ function getStatusText(status) {
'pending': 'Wartend',
'approved': 'Genehmigt',
'rejected': 'Abgelehnt',
'denied': 'Abgelehnt',
'expired': 'Abgelaufen'
};
return texts[status] || status;
@ -429,7 +432,7 @@ async function approveRequest(requestId) {
try {
showLoading(true);
const url = `${API_BASE_URL}/api/admin/guest-requests/${requestId}/approve`;
const url = `${API_BASE_URL}/api/requests/${requestId}/approve`;
const response = await fetch(url, {
method: 'POST',
headers: {
@ -437,7 +440,7 @@ async function approveRequest(requestId) {
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
approval_notes: notes || ''
notes: notes || ''
})
});
@ -446,7 +449,7 @@ async function approveRequest(requestId) {
if (data.success) {
showNotification('✅ Gastauftrag erfolgreich genehmigt', 'success');
if (data.otp_code) {
showNotification(`🔑 OTP-Code für ${data.guest_name}: ${data.otp_code}`, 'info');
showNotification(`🔑 OTP-Code für ${data.guest_name || 'Gast'}: ${data.otp_code}`, 'info');
}
loadGuestRequests();
} else {
@ -470,14 +473,14 @@ async function rejectRequest(requestId) {
try {
showLoading(true);
const url = `${API_BASE_URL}/api/admin/guest-requests/${requestId}/reject`;
const url = `${API_BASE_URL}/api/requests/${requestId}/deny`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({ rejection_reason: reason.trim() })
body: JSON.stringify({ reason: reason.trim() })
});
const data = await response.json();
@ -563,7 +566,7 @@ function showRequestDetail(requestId) {
<h4 class="text-lg font-semibold text-gray-900 dark:text-white">Auftrag Details</h4>
<div class="bg-slate-50 dark:bg-slate-700 rounded-lg p-4">
<p><strong>Datei:</strong> ${escapeHtml(request.file_name || 'Keine Datei')}</p>
<p><strong>Dauer:</strong> ${request.duration_minutes || 'Unbekannt'} Minuten</p>
<p><strong>Dauer:</strong> ${request.duration_min || 'Unbekannt'} Minuten</p>
<p><strong>Kopien:</strong> ${request.copies || 1}</p>
<p><strong>Status:</strong> ${getStatusText(request.status)}</p>
</div>
@ -738,7 +741,7 @@ function exportToCSV(data) {
req.file_name || '',
getStatusText(req.status),
formatDateTime(req.created_at),
req.duration_minutes || '',
req.duration_min || '',
req.copies || '',
req.reason || ''
]);