final user account polish
This commit is contained in:
parent
86fdd403b0
commit
aba6727306
3 changed files with 34 additions and 34 deletions
|
|
@ -3,21 +3,24 @@ import { cookies } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import SignIn from "./sign-in";
|
import SignIn from "./sign-in";
|
||||||
|
|
||||||
export default async function SignInPage(
|
export default async function SignInPage({
|
||||||
props: { searchParams: Promise<Record<string, string | string[] | undefined>> }
|
searchParams,
|
||||||
) {
|
}: {
|
||||||
const sp = await props.searchParams;
|
searchParams?: Record<string, string | string[] | undefined>;
|
||||||
|
}) {
|
||||||
|
const sp = searchParams ?? {};
|
||||||
|
|
||||||
const nextParam = Array.isArray(sp.next) ? sp.next[0] : sp.next;
|
const nextParam = Array.isArray(sp.next) ? sp.next[0] : sp.next;
|
||||||
const nextPath = nextParam && nextParam.startsWith("/") ? nextParam : "/portal";
|
const nextPath =
|
||||||
|
nextParam && String(nextParam).startsWith("/") ? String(nextParam) : "/portal";
|
||||||
|
|
||||||
const reauthParam = Array.isArray(sp.reauth) ? sp.reauth[0] : sp.reauth;
|
const reauthParam = Array.isArray(sp.reauth) ? sp.reauth[0] : sp.reauth;
|
||||||
const forceParam = Array.isArray(sp.force) ? sp.force[0] : sp.force;
|
const forceParam = Array.isArray(sp.force) ? sp.force[0] : sp.force;
|
||||||
const reauth = reauthParam === "1" || forceParam === "1";
|
const reauth = reauthParam === "1" || forceParam === "1";
|
||||||
|
|
||||||
// If reauth is requested, always render the form (no redirect).
|
// If reauth is requested, always render the form (no redirect).
|
||||||
if (!reauth) {
|
if (!reauth) {
|
||||||
const at = (await cookies()).get("ma_at")?.value;
|
const at = cookies().get("ma_at")?.value;
|
||||||
if (at) redirect("/portal");
|
if (at) redirect("/portal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,17 @@ const TARGET_LABEL: Record<Target, string> = {
|
||||||
export default async function SuccessPage({
|
export default async function SuccessPage({
|
||||||
searchParams,
|
searchParams,
|
||||||
}: {
|
}: {
|
||||||
// Next 15 types `searchParams` as a Promise
|
searchParams?: Record<string, string | string[] | undefined>;
|
||||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
||||||
}) {
|
}) {
|
||||||
const sp = await searchParams;
|
const sp = searchParams ?? {};
|
||||||
|
|
||||||
const rawTarget = sp?.target;
|
const rawTarget = sp?.target;
|
||||||
const rawId = sp?.id;
|
const rawId = sp?.id;
|
||||||
|
|
||||||
const valid: Target[] = ["settings_fiber", "settings_co2gan", "settings_co2gal", "settings_uv"];
|
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 t: Target = valid.includes(rawTarget as Target)
|
||||||
|
? (rawTarget as Target)
|
||||||
|
: "settings_fiber";
|
||||||
|
|
||||||
const id = Array.isArray(rawId) ? rawId[0] : rawId || "";
|
const id = Array.isArray(rawId) ? rawId[0] : rawId || "";
|
||||||
const listHref = TARGET_TO_LIST[t];
|
const listHref = TARGET_TO_LIST[t];
|
||||||
|
|
@ -38,20 +39,28 @@ export default async function SuccessPage({
|
||||||
return (
|
return (
|
||||||
<div className="max-w-2xl mx-auto py-10 space-y-6">
|
<div className="max-w-2xl mx-auto py-10 space-y-6">
|
||||||
<div className="flex items-center gap-3">
|
<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-9 w-9 rounded-full bg-green-600 text-white flex items-center justify-center">✓</div>
|
||||||
<h1 className="text-2xl font-semibold">Settings submitted!</h1>
|
<h1 className="text-xl font-semibold">Submission received</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-base">
|
<p className="text-base">
|
||||||
Your {label} submission has been received.
|
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>
|
</p>
|
||||||
|
|
||||||
<div className="flex flex-wrap gap-3">
|
<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
|
View {label} database
|
||||||
</Link>
|
</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
|
Submit another
|
||||||
</Link>
|
</Link>
|
||||||
<Link className="px-3 py-2 rounded border" href="/">
|
<Link className="px-3 py-2 rounded border" href="/">
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": [
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext"
|
|
||||||
],
|
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": false,
|
"strict": false,
|
||||||
|
|
@ -13,22 +9,16 @@
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "bundler",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": ["./*"]
|
||||||
"./*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [{ "name": "next" }],
|
||||||
{
|
"target": "ES2022"
|
||||||
"name": "next"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"target": "ES2017"
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
|
|
@ -36,7 +26,5 @@
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx"
|
"**/*.tsx"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": ["node_modules"]
|
||||||
"node_modules"
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue