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." }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { redirect } from "next/navigation";
|
||||
|
||||
import { PortfolioCategoriesManager } from "@/components/admin/portfolio-categories-manager";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { readFlash } from "@/lib/admin-feedback";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminPortfolioCategories } from "@/lib/portfolio";
|
||||
@@ -23,7 +24,13 @@ const copy = {
|
||||
backToSite: "Zur Website",
|
||||
};
|
||||
|
||||
export default async function AdminPortfolioCategoriesPage() {
|
||||
export default async function AdminPortfolioCategoriesPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams?: Promise<{ success?: string; error?: string }>;
|
||||
}) {
|
||||
const flash = readFlash(await searchParams);
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
@@ -43,6 +50,7 @@ export default async function AdminPortfolioCategoriesPage() {
|
||||
<AdminDashboardShell
|
||||
copy={copy}
|
||||
active="portfolio"
|
||||
flash={flash}
|
||||
portfolioChild="categories"
|
||||
logoutAction={logoutAction}
|
||||
headerTitle={copy.title}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { readFlash } from "@/lib/admin-feedback";
|
||||
import { PortfolioProjectsOverview } from "@/components/admin/portfolio-projects-overview";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
@@ -32,6 +33,7 @@ type AdminPortfolioPageProps = {
|
||||
|
||||
export default async function AdminPortfolioPage({ searchParams }: AdminPortfolioPageProps) {
|
||||
const resolvedSearchParams = await searchParams;
|
||||
const flash = readFlash(resolvedSearchParams);
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect(getAdminAppPath("/"));
|
||||
@@ -62,6 +64,7 @@ export default async function AdminPortfolioPage({ searchParams }: AdminPortfoli
|
||||
<AdminDashboardShell
|
||||
copy={copy}
|
||||
active="portfolio"
|
||||
flash={flash}
|
||||
portfolioChild="overview"
|
||||
logoutAction={logoutAction}
|
||||
headerTitle={copy.title}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { MotionFade } from "@/components/motion-fade";
|
||||
import { PortfolioProjectForm } from "@/components/admin/portfolio-project-form";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { readFlash } from "@/lib/admin-feedback";
|
||||
import { AppCard } from "@/components/ui/app-card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CardContent } from "@/components/ui/card";
|
||||
@@ -48,11 +49,15 @@ type AdminPortfolioProjectPageProps = {
|
||||
params: Promise<{
|
||||
id: string;
|
||||
}>;
|
||||
searchParams?: Promise<{ success?: string; error?: string }>;
|
||||
};
|
||||
|
||||
export default async function AdminPortfolioProjectPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: AdminPortfolioProjectPageProps) {
|
||||
const flash = readFlash(await searchParams);
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
@@ -73,13 +78,14 @@ export default async function AdminPortfolioProjectPage({
|
||||
]);
|
||||
|
||||
if (!project) {
|
||||
redirect(`${getAdminAppPath("/portfolio")}?error=Project+not+found.`);
|
||||
redirect(getAdminAppPath("/portfolio"));
|
||||
}
|
||||
|
||||
return (
|
||||
<AdminDashboardShell
|
||||
copy={copy}
|
||||
active="portfolio"
|
||||
flash={flash}
|
||||
portfolioChild="projects"
|
||||
logoutAction={logoutAction}
|
||||
headerTitle={copy.title}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { MotionFade } from "@/components/motion-fade";
|
||||
import { PortfolioProjectForm } from "@/components/admin/portfolio-project-form";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { readFlash } from "@/lib/admin-feedback";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMediaOptions } from "@/lib/media";
|
||||
@@ -25,7 +26,13 @@ const copy = {
|
||||
backToSite: "Zur Website",
|
||||
};
|
||||
|
||||
export default async function AdminNewPortfolioProjectPage() {
|
||||
export default async function AdminNewPortfolioProjectPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams?: Promise<{ success?: string; error?: string }>;
|
||||
}) {
|
||||
const flash = readFlash(await searchParams);
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
@@ -46,6 +53,7 @@ export default async function AdminNewPortfolioProjectPage() {
|
||||
<AdminDashboardShell
|
||||
copy={copy}
|
||||
active="portfolio"
|
||||
flash={flash}
|
||||
portfolioChild="new-project"
|
||||
logoutAction={logoutAction}
|
||||
headerTitle={copy.title}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { redirect } from "next/navigation";
|
||||
|
||||
import { PortfolioProjectsOverview } from "@/components/admin/portfolio-projects-overview";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { readFlash } from "@/lib/admin-feedback";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminPortfolioCategories, getAdminPortfolioProjects } from "@/lib/portfolio";
|
||||
@@ -25,6 +26,8 @@ type AdminPortfolioProjectsPageProps = {
|
||||
searchParams?: Promise<{
|
||||
category?: string;
|
||||
status?: "all" | "draft" | "published";
|
||||
success?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
@@ -32,6 +35,7 @@ export default async function AdminPortfolioProjectsPage({
|
||||
searchParams,
|
||||
}: AdminPortfolioProjectsPageProps) {
|
||||
const resolvedSearchParams = await searchParams;
|
||||
const flash = readFlash(resolvedSearchParams);
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect(getAdminAppPath("/"));
|
||||
@@ -62,6 +66,7 @@ export default async function AdminPortfolioProjectsPage({
|
||||
<AdminDashboardShell
|
||||
copy={copy}
|
||||
active="portfolio"
|
||||
flash={flash}
|
||||
portfolioChild="projects"
|
||||
logoutAction={logoutAction}
|
||||
headerTitle={copy.title}
|
||||
|
||||
Reference in New Issue
Block a user