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:
@@ -16,6 +16,7 @@ import {
|
||||
updateSiteSettings,
|
||||
} from "@/lib/app-config";
|
||||
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { withFlash } from "@/lib/admin-feedback";
|
||||
import {
|
||||
PAGE_TITLE_TOKEN,
|
||||
normalizeSiteDefaultLocale,
|
||||
@@ -38,12 +39,6 @@ async function ensureAdmin() {
|
||||
}
|
||||
}
|
||||
|
||||
function withMessage(pathname: string, type: "success" | "error", message: string) {
|
||||
const params = new URLSearchParams();
|
||||
params.set(type, message);
|
||||
|
||||
return `${pathname}?${params.toString()}`;
|
||||
}
|
||||
|
||||
function parseJsonObject(rawValue: FormDataEntryValue | null, key: string) {
|
||||
if (typeof rawValue !== "string" || rawValue.trim() === "") {
|
||||
@@ -260,7 +255,7 @@ export async function saveSiteBrandSettingsAction(formData: FormData) {
|
||||
});
|
||||
|
||||
await revalidateSiteSettingsPages(parsedSettings.defaultLocale);
|
||||
redirect(withMessage(getAdminAppPath("/site-settings/brand"), "success", "Einstellungen gespeichert."));
|
||||
redirect(withFlash(getAdminAppPath("/site-settings/brand"), { success: "Einstellungen gespeichert." }));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -273,7 +268,7 @@ export async function saveSiteBrandSettingsAction(formData: FormData) {
|
||||
? error.message
|
||||
: "Einstellungen konnten nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage(getAdminAppPath("/site-settings/brand"), "error", message));
|
||||
redirect(withFlash(getAdminAppPath("/site-settings/brand"), { error: message }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +318,7 @@ export async function saveSiteLocalizationSettingsAction(formData: FormData) {
|
||||
|
||||
await updateSiteSettings(parsedSettings);
|
||||
await revalidateSiteSettingsPages(parsedSettings.defaultLocale);
|
||||
redirect(withMessage(getAdminAppPath("/site-settings/localization"), "success", "Einstellungen gespeichert."));
|
||||
redirect(withFlash(getAdminAppPath("/site-settings/localization"), { success: "Einstellungen gespeichert." }));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -334,6 +329,6 @@ export async function saveSiteLocalizationSettingsAction(formData: FormData) {
|
||||
? error.message
|
||||
: "Einstellungen konnten nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage(getAdminAppPath("/site-settings/localization"), "error", message));
|
||||
redirect(withFlash(getAdminAppPath("/site-settings/localization"), { error: message }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user