minor dashboard changes
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
{ href: '/admin', icon: 'space_dashboard', label: 'Dashboard' },
|
{ href: '/admin', icon: 'space_dashboard', label: 'Dashboard' },
|
||||||
{ href: '/admin/copy', icon: 'edit_note', label: 'Testi & SEO/GEO' },
|
{ href: '/admin/copy', icon: 'edit_note', label: 'Testi & SEO/GEO' },
|
||||||
{ href: '/admin/images', icon: 'image', label: 'Immagini' },
|
{ href: '/admin/images', icon: 'image', label: 'Immagini' },
|
||||||
|
{ href: '/admin/contatti', icon: 'contact_page', label: 'Contatti' },
|
||||||
{ href: '/admin/testimonials', icon: 'reviews', label: 'Testimonianze' },
|
{ href: '/admin/testimonials', icon: 'reviews', label: 'Testimonianze' },
|
||||||
{ href: '/admin/submissions', icon: 'inbox', label: 'Richieste' },
|
{ href: '/admin/submissions', icon: 'inbox', label: 'Richieste' },
|
||||||
{ href: '/admin/notifications', icon: 'notifications', label: 'Notifiche' },
|
{ href: '/admin/notifications', icon: 'notifications', label: 'Notifiche' },
|
||||||
|
|||||||
@@ -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<string, string> = {};
|
||||||
|
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<string, string> = {};
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { enhance } from '$app/forms';
|
||||||
|
import type { PageData, ActionData } from './$types';
|
||||||
|
|
||||||
|
let { data, form }: { data: PageData; form: ActionData } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head><title>Contatti — Admin</title></svelte:head>
|
||||||
|
|
||||||
|
<header class="page-head">
|
||||||
|
<p class="kicker">Contatti</p>
|
||||||
|
<h1>Contatti</h1>
|
||||||
|
<p>
|
||||||
|
Modifica i recapiti mostrati nel riquadro "Contatti rapidi" della sezione contatti della landing page.
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{#if form?.success}
|
||||||
|
<div class="alert-row">Salvato — {form.count} modifiche applicate.</div>
|
||||||
|
{/if}
|
||||||
|
{#if form?.error}
|
||||||
|
<div class="alert-row err">{form.error}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h2>Recapiti rapidi</h2>
|
||||||
|
<form method="POST" action="?/save" use:enhance style="margin-top:14px;">
|
||||||
|
<div class="field">
|
||||||
|
<label for="info_title">Titolo del riquadro</label>
|
||||||
|
<input id="info_title" name="contact.info_title" type="text" value={data.values['contact.info_title']} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section-divider"><h2>Telefono</h2></div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="phone_label">Etichetta</label>
|
||||||
|
<input id="phone_label" name="contact.phone_label" type="text" value={data.values['contact.phone_label']} />
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="phone_value">Numero</label>
|
||||||
|
<input id="phone_value" name="contact.phone_value" type="text" value={data.values['contact.phone_value']} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section-divider"><h2>Email</h2></div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="email_label">Etichetta</label>
|
||||||
|
<input id="email_label" name="contact.email_label" type="text" value={data.values['contact.email_label']} />
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="email_value">Indirizzo email</label>
|
||||||
|
<input id="email_value" name="contact.email_value" type="text" value={data.values['contact.email_value']} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section-divider"><h2>WhatsApp</h2></div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="wa_label">Etichetta</label>
|
||||||
|
<input id="wa_label" name="contact.wa_label" type="text" value={data.values['contact.wa_label']} />
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="wa_value">Testo mostrato</label>
|
||||||
|
<input id="wa_value" name="contact.wa_value" type="text" value={data.values['contact.wa_value']} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-top:18px;">
|
||||||
|
<button type="submit" class="btn">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">save</span>
|
||||||
|
Salva contatti
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -9,10 +9,16 @@ import { DEFAULT_IMAGES } from '$lib/content/defaults';
|
|||||||
const UPLOAD_DIR = join(process.cwd(), 'static', 'img', 'uploads');
|
const UPLOAD_DIR = join(process.cwd(), 'static', 'img', 'uploads');
|
||||||
const MAX_BYTES = 8 * 1024 * 1024; // 8 MB
|
const MAX_BYTES = 8 * 1024 * 1024; // 8 MB
|
||||||
const ALLOWED = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/svg+xml']);
|
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 = () => {
|
export const load: PageServerLoad = () => {
|
||||||
const content = getContent();
|
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 {
|
function extFromType(type: string, fallbackName: string): string {
|
||||||
@@ -33,7 +39,7 @@ export const actions: Actions = {
|
|||||||
const alt = String(form.get('alt') ?? '').trim();
|
const alt = String(form.get('alt') ?? '').trim();
|
||||||
const file = form.get('file');
|
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) {
|
if (!(file instanceof File) || !file.size) {
|
||||||
// alt-only update
|
// alt-only update
|
||||||
if (alt) {
|
if (alt) {
|
||||||
@@ -59,7 +65,7 @@ export const actions: Actions = {
|
|||||||
reset: async ({ request }) => {
|
reset: async ({ request }) => {
|
||||||
const form = await request.formData();
|
const form = await request.formData();
|
||||||
const slot = String(form.get('slot') ?? '');
|
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];
|
const current = getContent().images[slot];
|
||||||
if (current?.src?.startsWith('/img/uploads/')) {
|
if (current?.src?.startsWith('/img/uploads/')) {
|
||||||
|
|||||||
@@ -93,9 +93,17 @@
|
|||||||
<span class="material-symbols-outlined" aria-hidden="true">mail</span>
|
<span class="material-symbols-outlined" aria-hidden="true">mail</span>
|
||||||
supporto@cimaprogetti.it
|
supporto@cimaprogetti.it
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-ghost" href="tel:+39000000000">
|
<a class="btn btn-ghost" href="tel:+393382451171">
|
||||||
<span class="material-symbols-outlined" aria-hidden="true">call</span>
|
<span class="material-symbols-outlined" aria-hidden="true">call</span>
|
||||||
Chiamaci
|
338 245 1171
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-ghost" href="https://wa.me/393382451171" target="_blank" rel="noopener noreferrer">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">forum</span>
|
||||||
|
WhatsApp 338 245 1171
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-ghost" href="https://cimaprogetti.it/warranty" target="_blank" rel="noopener noreferrer">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">open_in_new</span>
|
||||||
|
cimaprogetti.it/warranty
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user