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> </form>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}> <div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
{specials.map(special => ( {specials.map(special => (
<div key={special.id} style={{ <div
background: '#f3f4f6', key={special.id}
padding: '0.25rem 0.75rem', style={{
borderRadius: '999px', background: '#f3f4f6',
display: 'flex', padding: '0.25rem 0.75rem',
alignItems: 'center', borderRadius: '999px',
gap: '0.5rem', display: 'flex',
fontSize: '0.875rem' alignItems: 'center',
}}> gap: '0.5rem',
<span>{special.name} ({special._count?.songs || 0})</span> fontSize: '0.875rem',
{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> <span>
<button onClick={() => handleDeleteSpecial(special.id)} className="btn-danger">Delete</button> {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>
))} ))}
</div> </div>

View File

@@ -36,11 +36,17 @@ export default function SpecialEditorPage() {
}, [specialId]); }, [specialId]);
const handleSaveStartTime = async (songId: number, startTime: number) => { const handleSaveStartTime = async (songId: number, startTime: number) => {
await fetch(`/api/specials/${specialId}/songs`, { const res = await fetch(`/api/specials/${specialId}/songs`, {
method: 'PUT', method: 'PUT',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ songId, startTime }), 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) { if (loading) {