This commit is contained in:
Tomáš Dvořák
2025-10-03 22:05:32 +02:00
parent f15b2b5630
commit eeff13d5bb
5 changed files with 63 additions and 22 deletions
+32 -5
View File
@@ -385,11 +385,6 @@ uploadForm.addEventListener('submit', async (e) => {
return
}
if (!clubName) {
showNotification('Název klubu je povinný', 'error')
return
}
if (selectedFiles.length === 0) {
showNotification('Vyberte prosím soubor loga', 'error')
return
@@ -508,6 +503,38 @@ console.log('🇨🇿 České Kluby Loga API - Administrace')
console.log('Backend API:', API_BASE_URL)
console.log('FAČR API:', FACR_API_URL)
// Prefill editing when navigated with ?id=<uuid>
try {
const params = new URLSearchParams(window.location.search)
const editId = params.get('id')
if (editId) {
// Fill UUID and show upload section
const uuidInput = document.getElementById('clubUuid')
uuidInput.value = editId
uploadSection.classList.remove('hidden')
uploadSection.scrollIntoView({ behavior: 'smooth', block: 'start' })
showNotification('Režim úprav pro existující logo', 'info')
// Load metadata to prefill fields
;(async () => {
try {
const resp = await fetch(`${API_BASE_URL}/logos/${editId}/json`)
if (resp.ok) {
const contentType = resp.headers.get('content-type') || ''
if (contentType.includes('application/json')) {
const data = await resp.json()
if (data.club_name) document.getElementById('clubName').value = data.club_name
if (data.club_type) document.getElementById('clubType').value = data.club_type
if (data.club_website) document.getElementById('clubWebsite').value = data.club_website
}
}
} catch (e) {
// Non-fatal
}
})()
}
} catch (_) {}
// Load from URL functionality
const loadFromUrlBtn = document.getElementById('loadFromUrl')
const logoUrlInput = document.getElementById('logoUrl')
+3 -1
View File
@@ -43,6 +43,8 @@ function displayLogoDetails(logo) {
logoDetail.classList.remove('hidden')
// Club Info
const editBtn = document.getElementById('editButton')
if (editBtn) editBtn.href = `/admin.html?id=${logoId}`
document.getElementById('clubName').textContent = logo.club_name
document.getElementById('clubMeta').textContent = `${logo.club_type || 'fotbal'}`
@@ -137,7 +139,7 @@ function displayLogoDetails(logo) {
document.getElementById('uploadDate').textContent = formatDate(logo.created_at)
// API URLs
const baseUrl = window.location.origin
const baseUrl = API_BASE_URL
document.getElementById('apiUrlDefault').textContent = `${baseUrl}/logos/${logo.id}`
document.getElementById('apiUrlJson').textContent = `${baseUrl}/logos/${logo.id}/json`