refactor: drop toast + over-engineered extras, add inline admin feedback
CI / quality (push) Waiting to run
CI / quality (push) Waiting to run
Phase 1 cleanup of the personal-site revamp. Backend/architecture untouched; changes are limited to removing unused complexity and restoring feedback. Removals - Toast system: delete react-hot-toast, Toaster, QueryToastBridge, lib/toast, the toggle/easter-egg calls, related i18n keys and the dependency. - Contact protection: remove Turnstile + per-IP rate limiting (lib/contact-guard, lib/contact-protection, admin screen, form widget, app-config wiring, nav entry, test). - Speculative specs: delete orders, products, downloads, project-inquiry. Inline feedback (replaces toast, no new deps) - Add lib/admin-feedback (withFlash/readFlash) and components/admin/admin-flash, rendered centrally by AdminDashboardShell. - Emit success/error messages for media, site-settings, portfolio, smtp, marquee and maintenance actions; pages read them via searchParams. - Contact form shows validation/delivery errors inline; success still redirects to /success. Docs - Fix stale paths in frontend-system-* (components/root -> components/admin, lib/root-navigation -> lib/admin-navigation, drop phantom src/) and remove contact-protection references from docs and CLAUDE.md. - Add docs/PHASE0_DIAGNOSIS.md (diagnosis report). Note: proxy.ts self-fetch kept intentionally; it also drives maintenance mode.
This commit is contained in:
@@ -8,6 +8,7 @@ import { ZodError } from "zod";
|
||||
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { withFlash } from "@/lib/admin-feedback";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { deleteEntityMediaUsages, replaceEntityMediaUsages } from "@/lib/media";
|
||||
import { resolveMediaSelection } from "@/lib/media-service";
|
||||
@@ -35,12 +36,6 @@ function getRedirectPath(formData: FormData, fallbackPath: string) {
|
||||
return String(formData.get("redirectPath") ?? fallbackPath);
|
||||
}
|
||||
|
||||
function withMessage(pathname: string, type: "success" | "error", message: string) {
|
||||
const params = new URLSearchParams();
|
||||
params.set(type, message);
|
||||
|
||||
return `${pathname}?${params.toString()}`;
|
||||
}
|
||||
|
||||
function normalizeCheckboxValue(formData: FormData, key: string) {
|
||||
return isCheckedFormValue(formData.get(key));
|
||||
@@ -139,7 +134,7 @@ export async function upsertCategoryAction(formData: FormData) {
|
||||
}
|
||||
|
||||
await revalidatePortfolioPages();
|
||||
redirect(withMessage(redirectPath, "success", "Kategorie gespeichert."));
|
||||
redirect(withFlash(redirectPath, { success: "Kategorie gespeichert." }));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -152,7 +147,7 @@ export async function upsertCategoryAction(formData: FormData) {
|
||||
? "Kategorie Slug muss eindeutig sein."
|
||||
: "Kategorie konnte nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage(redirectPath, "error", message));
|
||||
redirect(withFlash(redirectPath, { error: message }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +165,7 @@ export async function deleteCategoryAction(formData: FormData) {
|
||||
});
|
||||
|
||||
if (projectCount > 0) {
|
||||
redirect(withMessage(redirectPath, "error", "Kategorie mit Projekten kann nicht geloescht werden."));
|
||||
redirect(withFlash(redirectPath, { error: "Kategorie mit Projekten kann nicht geloescht werden." }));
|
||||
}
|
||||
|
||||
await prisma.category.delete({
|
||||
@@ -180,13 +175,13 @@ export async function deleteCategoryAction(formData: FormData) {
|
||||
});
|
||||
|
||||
await revalidatePortfolioPages();
|
||||
redirect(withMessage(redirectPath, "success", "Kategorie geloescht."));
|
||||
redirect(withFlash(redirectPath, { success: "Kategorie geloescht." }));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
redirect(withMessage(redirectPath, "error", "Kategorie konnte nicht geloescht werden."));
|
||||
redirect(withFlash(redirectPath, { error: "Kategorie konnte nicht geloescht werden." }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +524,9 @@ export async function saveProjectAction(formData: FormData) {
|
||||
}
|
||||
|
||||
redirect(
|
||||
withMessage(getAdminAppPath(`/portfolio/projects/${projectResult.project.id}`), "success", "Projekt gespeichert."),
|
||||
withFlash(getAdminAppPath(`/portfolio/projects/${projectResult.project.id}`), {
|
||||
success: "Projekt gespeichert.",
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
@@ -562,7 +559,7 @@ export async function saveProjectAction(formData: FormData) {
|
||||
},
|
||||
});
|
||||
}
|
||||
redirect(withMessage(redirectPath, "error", message));
|
||||
redirect(withFlash(redirectPath, { error: message }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +579,7 @@ export async function deleteProjectAction(formData: FormData) {
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "error", "Projekt nicht gefunden."));
|
||||
redirect(withFlash(getAdminAppPath("/portfolio"), { error: "Projekt nicht gefunden." }));
|
||||
}
|
||||
|
||||
await prisma.portfolioProject.delete({
|
||||
@@ -600,12 +597,12 @@ export async function deleteProjectAction(formData: FormData) {
|
||||
revalidatePath(getLocalizedPath(locale, `/portfolio/${project.slug}`, siteSettings.defaultLocale));
|
||||
}
|
||||
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "success", "Project deleted."));
|
||||
redirect(withFlash(getAdminAppPath("/portfolio"), { success: "Projekt geloescht." }));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "error", "Unable to delete project."));
|
||||
redirect(withFlash(getAdminAppPath("/portfolio"), { error: "Projekt konnte nicht geloescht werden." }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user