success page build fix
This commit is contained in:
parent
952b0f10fa
commit
2dc03c85fe
1 changed files with 15 additions and 38 deletions
|
|
@ -1,11 +1,7 @@
|
|||
// app/submit/settings/success/page.tsx
|
||||
import Link from "next/link";
|
||||
|
||||
type Target =
|
||||
| "settings_fiber"
|
||||
| "settings_co2gan"
|
||||
| "settings_co2gal"
|
||||
| "settings_uv";
|
||||
type Target = "settings_fiber" | "settings_co2gan" | "settings_co2gal" | "settings_uv";
|
||||
|
||||
const TARGET_TO_LIST: Record<Target, string> = {
|
||||
settings_fiber: "/fiber-settings",
|
||||
|
|
@ -21,60 +17,41 @@ const TARGET_LABEL: Record<Target, string> = {
|
|||
settings_uv: "UV",
|
||||
};
|
||||
|
||||
export default function SuccessPage({
|
||||
export default async function SuccessPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Record<string, string | string[] | undefined>;
|
||||
// Next 15 types `searchParams` as a Promise
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const rawTarget = searchParams?.target;
|
||||
const rawId = searchParams?.id;
|
||||
const sp = await searchParams;
|
||||
|
||||
const rawTarget = sp?.target;
|
||||
const rawId = sp?.id;
|
||||
|
||||
const valid: Target[] = ["settings_fiber", "settings_co2gan", "settings_co2gal", "settings_uv"];
|
||||
const t: Target = (valid.includes(rawTarget as Target) ? (rawTarget as Target) : "settings_fiber");
|
||||
|
||||
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>
|
||||
<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}
|
||||
{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}
|
||||
>
|
||||
<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)}`}
|
||||
>
|
||||
<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="/">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue