Tighten admin specials handling and remove obsolete curate button

This commit is contained in:
Hördle Bot
2025-12-04 12:31:49 +01:00
parent b46e9e3882
commit 12cc81905e
2 changed files with 46 additions and 15 deletions

View File

@@ -638,20 +638,45 @@ export default function AdminPage() {
</form>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
{specials.map(special => (
<div key={special.id} style={{
background: '#f3f4f6',
padding: '0.25rem 0.75rem',
borderRadius: '999px',
display: 'flex',
alignItems: 'center',
gap: '0.5rem',
fontSize: '0.875rem'
}}>
<span>{special.name} ({special._count?.songs || 0})</span>
{special.subtitle && <span style={{ fontSize: '0.75rem', color: '#666', marginLeft: '0.25rem' }}>- {special.subtitle}</span>}
<a href={`/admin/specials/${special.id}`} className="btn-primary" style={{ marginRight: '0.5rem', textDecoration: 'none' }}>Curate</a>
<button onClick={() => startEditSpecial(special)} className="btn-secondary" style={{ marginRight: '0.5rem' }}>Edit</button>
<button onClick={() => handleDeleteSpecial(special.id)} className="btn-danger">Delete</button>
<div
key={special.id}
style={{
background: '#f3f4f6',
padding: '0.25rem 0.75rem',
borderRadius: '999px',
display: 'flex',
alignItems: 'center',
gap: '0.5rem',
fontSize: '0.875rem',
}}
>
<span>
{special.name} ({special._count?.songs || 0})
</span>
{special.subtitle && (
<span
style={{
fontSize: '0.75rem',
color: '#666',
marginLeft: '0.25rem',
}}
>
- {special.subtitle}
</span>
)}
<button
onClick={() => startEditSpecial(special)}
className="btn-secondary"
style={{ marginRight: '0.5rem' }}
>
Edit
</button>
<button
onClick={() => handleDeleteSpecial(special.id)}
className="btn-danger"
>
Delete
</button>
</div>
))}
</div>

View File

@@ -36,11 +36,17 @@ export default function SpecialEditorPage() {
}, [specialId]);
const handleSaveStartTime = async (songId: number, startTime: number) => {
await fetch(`/api/specials/${specialId}/songs`, {
const res = await fetch(`/api/specials/${specialId}/songs`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ songId, startTime }),
});
if (!res.ok) {
const errorText = await res.text().catch(() => res.statusText || 'Unknown error');
console.error('Error updating special song (admin):', res.status, errorText);
throw new Error(`Failed to save start time: ${errorText}`);
}
};
if (loading) {