fix: flag A/B/C persistence, catalog sort+reorder, offer category pools

- Fix duplicate tier INSERT bug (useState not syncing after router.refresh)
- Add column sort by clicking headers in service catalog
- Add drag-and-drop column reordering (persisted in localStorage)
- Add Categorie Offerta section in Impostazioni (tipo/obiettivo/categoria pools)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 12:12:49 +02:00
parent ba3e824157
commit 320827e13a
9 changed files with 654 additions and 216 deletions
+33
View File
@@ -0,0 +1,33 @@
"use server";
import { getJsonPool, updateJsonPool, SETTINGS_KEYS } from "@/lib/settings";
import { revalidatePath } from "next/cache";
type PoolName = "tipo" | "obiettivo" | "categoria";
function poolKey(pool: PoolName): string {
switch (pool) {
case "tipo": return SETTINGS_KEYS.OFFER_TIPO_POOL;
case "obiettivo": return SETTINGS_KEYS.OFFER_OBIETTIVO_POOL;
case "categoria": return SETTINGS_KEYS.OFFER_CATEGORIA_POOL;
}
}
export async function addPoolValue(pool: PoolName, value: string): Promise<void> {
const trimmed = value.trim();
if (!trimmed) return;
const key = poolKey(pool);
const current = await getJsonPool(key);
if (current.includes(trimmed)) return;
await updateJsonPool(key, [...current, trimmed]);
revalidatePath("/admin/impostazioni");
revalidatePath("/admin/offers");
}
export async function removePoolValue(pool: PoolName, value: string): Promise<void> {
const key = poolKey(pool);
const current = await getJsonPool(key);
await updateJsonPool(key, current.filter((v) => v !== value));
revalidatePath("/admin/impostazioni");
revalidatePath("/admin/offers");
}