From f002eab1f6bcf6810d9834baa17f2dfd1a83624c Mon Sep 17 00:00:00 2001 From: mrhid6 Date: Fri, 24 Jul 2026 10:01:06 +0100 Subject: [PATCH] fix: Fixed compile error --- web/app/setup/page.tsx | 296 ++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 168 deletions(-) diff --git a/web/app/setup/page.tsx b/web/app/setup/page.tsx index fb10d27..eed1b3e 100644 --- a/web/app/setup/page.tsx +++ b/web/app/setup/page.tsx @@ -19,188 +19,148 @@ const MIN_PASSWORD_LENGTH = 8; * session cookie on the host their org actually lives on. */ function orgLoginUrlForSlug(slug: string): string { - if (typeof window === "undefined") return "/login"; - const { protocol, host } = window.location; - const [hostname, port] = host.split(":"); - const parts = hostname.split("."); + if (typeof window === "undefined") return "/login"; + const { protocol, host } = window.location; + const [hostname, port] = host.split(":"); + const parts = hostname.split("."); - if (parts.length < 2 || parts[parts.length - 1] === "localhost") return "/login"; + if (parts.length < 2 || parts[parts.length - 1] === "localhost") return "/login"; - const rest = parts[0] === "vantage" ? parts : parts.slice(1); - if (rest[0] !== "vantage") return "/login"; + const rest = parts[0] === "vantage" ? parts : parts.slice(1); + if (rest[0] !== "vantage") return "/login"; - const newHost = [slug, ...rest].join(".") + (port ? `:${port}` : ""); - return `${protocol} + const newHost = [slug, ...rest].join(".") + (port ? `:${port}` : ""); + return `${protocol}`; } export default function SetupPage() { - const [orgName, setOrgName] = useState(""); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - const [confirm, setConfirm] = useState(""); - const [validationError, setValidationError] = useState(null); - const [created, setCreated] = useState<{ slug: string; loginUrl: string } | null>(null); + const [orgName, setOrgName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirm, setConfirm] = useState(""); + const [validationError, setValidationError] = useState(null); + const [created, setCreated] = useState<{ slug: string; loginUrl: string } | null>(null); - - useEffect(() => { - auth - .bootstrapStatus() - .then((s) => { - if (!s.needs_setup) window.location.href = "/login"; - }) - .catch(() => { - - }); - }, []); + useEffect(() => { + auth.bootstrapStatus() + .then((s) => { + if (!s.needs_setup) window.location.href = "/login"; + }) + .catch(() => {}); + }, []); - const { mutate: bootstrap, isPending, error } = useMutation({ - mutationFn: () => auth.bootstrap({ org_name: orgName, email, password }), - onSuccess: (res) => { - setCreated({ slug: res.slug, loginUrl: orgLoginUrlForSlug(res.slug) }); - }, - }); + const { + mutate: bootstrap, + isPending, + error, + } = useMutation({ + mutationFn: () => auth.bootstrap({ org_name: orgName, email, password }), + onSuccess: (res) => { + setCreated({ slug: res.slug, loginUrl: orgLoginUrlForSlug(res.slug) }); + }, + }); - function handleSubmit(e: React.FormEvent) { - e.preventDefault(); - if (password.length < MIN_PASSWORD_LENGTH) { - setValidationError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`); - return; + function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + if (password.length < MIN_PASSWORD_LENGTH) { + setValidationError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`); + return; + } + if (password !== confirm) { + setValidationError("Passwords do not match."); + return; + } + setValidationError(null); + bootstrap(); } - if (password !== confirm) { - setValidationError("Passwords do not match."); - return; + + const message = validationError ?? (error ? (error as Error).message : null); + + const inputClass = "w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent/50 focus:outline-none focus:ring-1 focus:ring-accent/30"; + + if (created) { + return ( +
+
+
+

Organization created

+

Your owner account is ready. One more step to finish signing in.

+
+ + +

+ {created.slug} has its own address, and sign-in is kept separate per organization. Continue to your organization's sign-in page and log in with the email and password + you just chose. +

+ {created.loginUrl} + + + +
+
+
+ ); } - setValidationError(null); - bootstrap(); - } - - const message = validationError ?? (error ? (error as Error).message : null); - - const inputClass = - "w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent/50 focus:outline-none focus:ring-1 focus:ring-accent/30"; - - if (created) { return ( -
-
-
-

Organization created

-

- Your owner account is ready. One more step to finish signing in. -

-
+
+
+
+

Welcome to Vantage

+

Create your organization and its owner account to get started.

+
- -

- {created.slug} has its own address, and sign-in is kept separate per organization. Continue - to your organization's sign-in page and log in with the email and password you just - chose. -

- - {created.loginUrl} - - - - -
+ +
+
+ + setOrgName(e.target.value)} className={inputClass} /> +

Used to derive your organization's subdomain.

+
+ +
+ + setEmail(e.target.value)} className={inputClass} /> +
+ +
+ + setPassword(e.target.value)} + className={inputClass} + /> +

At least {MIN_PASSWORD_LENGTH} characters.

+
+ +
+ + setConfirm(e.target.value)} className={inputClass} /> +
+ + {message &&
{message}
} + + +
+
+
-
); - } - - return ( -
-
-
-

Welcome to Vantage

-

- Create your organization and its owner account to get started. -

-
- - -
-
- - setOrgName(e.target.value)} - className={inputClass} - /> -

- Used to derive your organization's subdomain. -

-
- -
- - setEmail(e.target.value)} - className={inputClass} - /> -
- -
- - setPassword(e.target.value)} - className={inputClass} - /> -

- At least {MIN_PASSWORD_LENGTH} characters. -

-
- -
- - setConfirm(e.target.value)} - className={inputClass} - /> -
- - {message && ( -
- {message} -
- )} - - -
-
-
-
- ); }