fix submit success page directory
This commit is contained in:
parent
9be0527a46
commit
952b0f10fa
2 changed files with 86 additions and 72 deletions
|
|
@ -1,72 +0,0 @@
|
|||
// app/submit/settings/success/page.tsx
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useMemo } from "react";
|
||||
|
||||
type Target =
|
||||
| "settings_fiber"
|
||||
| "settings_co2gan"
|
||||
| "settings_co2gal"
|
||||
| "settings_uv";
|
||||
|
||||
const TARGET_TO_LIST: Record<Target, string> = {
|
||||
settings_fiber: "/fiber-settings",
|
||||
settings_co2gan: "/co2-gantry-settings",
|
||||
settings_co2gal: "/co2-galvo-settings",
|
||||
settings_uv: "/uv-settings",
|
||||
};
|
||||
|
||||
const TARGET_LABEL: Record<Target, string> = {
|
||||
settings_fiber: "Fiber",
|
||||
settings_co2gan: "CO₂ Gantry",
|
||||
settings_co2gal: "CO₂ Galvo",
|
||||
settings_uv: "UV",
|
||||
};
|
||||
|
||||
export default function SuccessPage() {
|
||||
const sp = useSearchParams();
|
||||
const id = (sp.get("id") || "").trim();
|
||||
const target = (sp.get("target") || "settings_fiber") as Target;
|
||||
|
||||
const listHref = TARGET_TO_LIST[target] || "/projects";
|
||||
const targetLabel = TARGET_LABEL[target] || "Settings";
|
||||
|
||||
const title = useMemo(
|
||||
() => `Settings Submitted${id ? ` (#${id})` : ""}`,
|
||||
[id]
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="max-w-2xl mx-auto py-10 px-4 space-y-6">
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-semibold">{title}</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Your submission was received successfully.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<Link
|
||||
className="inline-flex items-center justify-center rounded border px-3 py-2 hover:bg-muted"
|
||||
href={`/submit/settings?target=${encodeURIComponent(target)}`}
|
||||
>
|
||||
Submit Another ({targetLabel})
|
||||
</Link>
|
||||
<Link
|
||||
className="inline-flex items-center justify-center rounded border px-3 py-2 hover:bg-muted"
|
||||
href={listHref}
|
||||
>
|
||||
Go to {targetLabel} Database
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{id ? (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Reference ID: <span className="font-mono">{id}</span>
|
||||
</p>
|
||||
) : null}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
86
app/submit/settings/success/page.tsx
Normal file
86
app/submit/settings/success/page.tsx
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
// app/submit/settings/success/page.tsx
|
||||
import Link from "next/link";
|
||||
|
||||
type Target =
|
||||
| "settings_fiber"
|
||||
| "settings_co2gan"
|
||||
| "settings_co2gal"
|
||||
| "settings_uv";
|
||||
|
||||
const TARGET_TO_LIST: Record<Target, string> = {
|
||||
settings_fiber: "/fiber-settings",
|
||||
settings_co2gan: "/co2-gantry-settings",
|
||||
settings_co2gal: "/co2-galvo-settings",
|
||||
settings_uv: "/uv-settings",
|
||||
};
|
||||
|
||||
const TARGET_LABEL: Record<Target, string> = {
|
||||
settings_fiber: "Fiber",
|
||||
settings_co2gan: "CO₂ Gantry",
|
||||
settings_co2gal: "CO₂ Galvo",
|
||||
settings_uv: "UV",
|
||||
};
|
||||
|
||||
export default function SuccessPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Record<string, string | string[] | undefined>;
|
||||
}) {
|
||||
const rawTarget = searchParams?.target;
|
||||
const rawId = searchParams?.id;
|
||||
|
||||
const targetStr = Array.isArray(rawTarget) ? rawTarget[0] : rawTarget;
|
||||
const id = Array.isArray(rawId) ? rawId[0] : rawId || "";
|
||||
|
||||
const validTargets: Target[] = [
|
||||
"settings_fiber",
|
||||
"settings_co2gan",
|
||||
"settings_co2gal",
|
||||
"settings_uv",
|
||||
];
|
||||
const t: Target = (validTargets.includes(targetStr as Target)
|
||||
? (targetStr as Target)
|
||||
: "settings_fiber");
|
||||
|
||||
const listHref = TARGET_TO_LIST[t];
|
||||
const label = TARGET_LABEL[t];
|
||||
|
||||
return (
|
||||
<div className="max-w-2xl mx-auto py-10 space-y-6">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-10 w-10 rounded-full bg-green-600 text-white flex items-center justify-center">
|
||||
✓
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold">Settings submitted!</h1>
|
||||
</div>
|
||||
|
||||
<p className="text-base">
|
||||
Your {label} submission has been received.
|
||||
{id ? (
|
||||
<>
|
||||
{" "}
|
||||
Reference ID: <span className="font-mono">{id}</span>.
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<Link
|
||||
className="px-3 py-2 rounded border"
|
||||
href={listHref}
|
||||
>
|
||||
View {label} database
|
||||
</Link>
|
||||
<Link
|
||||
className="px-3 py-2 rounded border"
|
||||
href={`/submit/settings?target=${encodeURIComponent(t)}`}
|
||||
>
|
||||
Submit another
|
||||
</Link>
|
||||
<Link className="px-3 py-2 rounded border" href="/">
|
||||
Home
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue