feat: add back to main page buttons in admin and login
This commit is contained in:
1 parent
696f2ef50a
commit
611cd82763
5 files changed
+66
-51
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function AdminLoginPage() {
|
||||
const [password, setPassword] = useState('');
|
||||
@@ -56,6 +57,9 @@ export default function AdminLoginPage() {
|
||||
<button type="submit" className="btn-primary" style={{ justifyContent: 'center' }} disabled={loading}>
|
||||
{loading ? 'Laden...' : 'Anmelden'}
|
||||
</button>
|
||||
<Link href="/" className="btn-secondary" style={{ display: 'flex', justifyContent: 'center', marginTop: '10px', textDecoration: 'none' }}>
|
||||
Zurück zur Hauptseite
|
||||
</Link>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ type MediaItem = {
|
||||
relativePath: string;
|
||||
filename: string;
|
||||
published: boolean;
|
||||
wasOncePublished: boolean;
|
||||
featured: boolean;
|
||||
mediaType: string;
|
||||
};
|
||||
@@ -77,7 +78,7 @@ export default function AdminDashboard() {
|
||||
const togglePublished = async (id: number, current: boolean) => {
|
||||
// Optimistic UI
|
||||
setItems((prev) =>
|
||||
prev.map((i) => (i.id === id ? { ...i, published: !current } : i))
|
||||
prev.map((i) => (i.id === id ? { ...i, published: !current, ...( !current ? { wasOncePublished: true } : {} ) } : i))
|
||||
);
|
||||
setStats((prev) => ({
|
||||
...prev,
|
||||
@@ -123,7 +124,11 @@ export default function AdminDashboard() {
|
||||
|
||||
// Optimistic UI
|
||||
setItems((prev) =>
|
||||
prev.map((i) => ({ ...i, published: isPublished }))
|
||||
prev.map((i) => ({
|
||||
...i,
|
||||
published: isPublished,
|
||||
...(isPublished ? { wasOncePublished: true } : {})
|
||||
}))
|
||||
);
|
||||
setStats({
|
||||
total: items.length,
|
||||
@@ -150,6 +155,7 @@ export default function AdminDashboard() {
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '20px', flexWrap: 'wrap', gap: '10px' }}>
|
||||
<h2 style={{ fontSize: '1.5rem', fontFamily: 'var(--font-display)' }}>Admin Dashboard</h2>
|
||||
<div style={{ display: 'flex', gap: '10px' }}>
|
||||
<Link href="/" className="btn-secondary" style={{ textDecoration: 'none' }}>Zurück zur Hauptseite</Link>
|
||||
<button className="btn-secondary" onClick={handleScan}>Neu Scannen</button>
|
||||
<Link href="/admin/layout" className="btn-secondary" style={{ textDecoration: 'none' }}>Layout Editor</Link>
|
||||
<button className="btn-primary" onClick={handleLogout}>Logout</button>
|
||||
|
||||
@@ -37,6 +37,7 @@ export async function PATCH(
|
||||
where: { id },
|
||||
data: {
|
||||
...(published !== undefined && { published }),
|
||||
...(published === true && { wasOncePublished: true }),
|
||||
...(featured !== undefined && { featured }),
|
||||
...(placementMode !== undefined && { placementMode }),
|
||||
...(gridColumn !== undefined && { gridColumn }),
|
||||
|
||||
@@ -24,7 +24,10 @@ export async function PATCH(request: NextRequest) {
|
||||
where: {
|
||||
id: { in: ids }
|
||||
},
|
||||
data: { published }
|
||||
data: {
|
||||
published,
|
||||
...(published === true ? { wasOncePublished: true } : {})
|
||||
}
|
||||
});
|
||||
|
||||
if (result.count > 0) {
|
||||
|
||||
Reference in new issue
Block a user