From 9126b6b4948c540bded4e0e27e0c07bbb968e3f4 Mon Sep 17 00:00:00 2001 From: Nicola Leone Ciardi Date: Mon, 20 Apr 2026 13:20:43 +0200 Subject: [PATCH] minor dashboard changes --- src/routes/admin/+layout.svelte | 1 + src/routes/admin/contatti/+page.server.ts | 35 +++++++++++ src/routes/admin/contatti/+page.svelte | 76 +++++++++++++++++++++++ src/routes/admin/images/+page.server.ts | 12 +++- src/routes/admin/warranty/+page.svelte | 12 +++- 5 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 src/routes/admin/contatti/+page.server.ts create mode 100644 src/routes/admin/contatti/+page.svelte diff --git a/src/routes/admin/+layout.svelte b/src/routes/admin/+layout.svelte index d0a1982..350f3e7 100644 --- a/src/routes/admin/+layout.svelte +++ b/src/routes/admin/+layout.svelte @@ -12,6 +12,7 @@ { href: '/admin', icon: 'space_dashboard', label: 'Dashboard' }, { href: '/admin/copy', icon: 'edit_note', label: 'Testi & SEO/GEO' }, { href: '/admin/images', icon: 'image', label: 'Immagini' }, + { href: '/admin/contatti', icon: 'contact_page', label: 'Contatti' }, { href: '/admin/testimonials', icon: 'reviews', label: 'Testimonianze' }, { href: '/admin/submissions', icon: 'inbox', label: 'Richieste' }, { href: '/admin/notifications', icon: 'notifications', label: 'Notifiche' }, diff --git a/src/routes/admin/contatti/+page.server.ts b/src/routes/admin/contatti/+page.server.ts new file mode 100644 index 0000000..748e75e --- /dev/null +++ b/src/routes/admin/contatti/+page.server.ts @@ -0,0 +1,35 @@ +import type { Actions, PageServerLoad } from './$types'; +import { fail } from '@sveltejs/kit'; +import { getContent, setCopyBulk } from '$lib/server/content'; + +const CONTACT_FIELDS = [ + 'contact.info_title', + 'contact.phone_label', + 'contact.phone_value', + 'contact.email_label', + 'contact.email_value', + 'contact.wa_label', + 'contact.wa_value' +] as const; + +export const load: PageServerLoad = () => { + const content = getContent(); + const values: Record = {}; + for (const id of CONTACT_FIELDS) values[id] = content.copy[id] ?? ''; + return { values }; +}; + +export const actions: Actions = { + save: async ({ request }) => { + const form = await request.formData(); + const updates: Record = {}; + for (const id of CONTACT_FIELDS) { + const v = form.get(id); + if (v === null) continue; + updates[id] = String(v).trim(); + } + if (!Object.keys(updates).length) return fail(400, { error: 'Nessuna modifica da salvare.' }); + setCopyBulk(updates); + return { success: true, count: Object.keys(updates).length }; + } +}; diff --git a/src/routes/admin/contatti/+page.svelte b/src/routes/admin/contatti/+page.svelte new file mode 100644 index 0000000..6c72e04 --- /dev/null +++ b/src/routes/admin/contatti/+page.svelte @@ -0,0 +1,76 @@ + + +Contatti — Admin + +
+

Contatti

+

Contatti

+

+ Modifica i recapiti mostrati nel riquadro "Contatti rapidi" della sezione contatti della landing page. +

+
+ +{#if form?.success} +
Salvato — {form.count} modifiche applicate.
+{/if} +{#if form?.error} +
{form.error}
+{/if} + +
+

Recapiti rapidi

+
+
+ + +
+ +

Telefono

+
+
+ + +
+
+ + +
+
+ +

Email

+
+
+ + +
+
+ + +
+
+ +

WhatsApp

+
+
+ + +
+
+ + +
+
+ +
+ +
+
+
diff --git a/src/routes/admin/images/+page.server.ts b/src/routes/admin/images/+page.server.ts index a8414ba..1ce1b77 100644 --- a/src/routes/admin/images/+page.server.ts +++ b/src/routes/admin/images/+page.server.ts @@ -9,10 +9,16 @@ import { DEFAULT_IMAGES } from '$lib/content/defaults'; const UPLOAD_DIR = join(process.cwd(), 'static', 'img', 'uploads'); const MAX_BYTES = 8 * 1024 * 1024; // 8 MB const ALLOWED = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/svg+xml']); +const LOCKED_SLOTS = new Set(['cima_logo']); export const load: PageServerLoad = () => { const content = getContent(); - return { images: content.images }; + const images: typeof content.images = {}; + for (const [id, img] of Object.entries(content.images)) { + if (LOCKED_SLOTS.has(id)) continue; + images[id] = img; + } + return { images }; }; function extFromType(type: string, fallbackName: string): string { @@ -33,7 +39,7 @@ export const actions: Actions = { const alt = String(form.get('alt') ?? '').trim(); const file = form.get('file'); - if (!slot || !(slot in DEFAULT_IMAGES)) return fail(400, { error: 'Slot immagine non valido.' }); + if (!slot || !(slot in DEFAULT_IMAGES) || LOCKED_SLOTS.has(slot)) return fail(400, { error: 'Slot immagine non valido.' }); if (!(file instanceof File) || !file.size) { // alt-only update if (alt) { @@ -59,7 +65,7 @@ export const actions: Actions = { reset: async ({ request }) => { const form = await request.formData(); const slot = String(form.get('slot') ?? ''); - if (!slot || !(slot in DEFAULT_IMAGES)) return fail(400, { error: 'Slot non valido.' }); + if (!slot || !(slot in DEFAULT_IMAGES) || LOCKED_SLOTS.has(slot)) return fail(400, { error: 'Slot non valido.' }); const current = getContent().images[slot]; if (current?.src?.startsWith('/img/uploads/')) { diff --git a/src/routes/admin/warranty/+page.svelte b/src/routes/admin/warranty/+page.svelte index 1a07bc4..64431f9 100644 --- a/src/routes/admin/warranty/+page.svelte +++ b/src/routes/admin/warranty/+page.svelte @@ -93,9 +93,17 @@ supporto@cimaprogetti.it - + - Chiamaci + 338 245 1171 + + + + WhatsApp 338 245 1171 + + + + cimaprogetti.it/warranty