diff --git a/src/app/access/page.tsx b/src/app/access/page.tsx
index 772d4b31..ee51bcce 100644
--- a/src/app/access/page.tsx
+++ b/src/app/access/page.tsx
@@ -15,16 +15,15 @@ function AccessForm() {
const [error, setError] = useState("");
useEffect(() => {
- if (!ready) return;
- if (!authenticated || !user) return;
+ if (!ready || !authenticated || !user) return;
const email =
- user.email?.address ||
- (user.linkedAccounts.find((a) => a.type === "email") as { address?: string } | undefined)?.address ||
+ (user as { email?: { address?: string } }).email?.address ??
+ (user.linkedAccounts?.find((a) => a.type === "email") as { address?: string } | undefined)?.address ??
null;
const xHandle =
- (user.linkedAccounts.find((a) => a.type === "twitter_oauth") as { username?: string } | undefined)?.username ||
+ (user.linkedAccounts?.find((a) => a.type === "twitter_oauth") as { username?: string } | undefined)?.username ??
null;
setIsLoading(true);
@@ -33,10 +32,10 @@ function AccessForm() {
fetch("/api/access", {
method: "POST",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ privy: true, userId: user.id, email, xHandle }),
+ body: JSON.stringify({ userId: user.id, email, xHandle }),
})
.then((res) => res.json())
- .then((data) => {
+ .then((data: { ok?: boolean; error?: string }) => {
if (data.ok) {
window.location.assign(nextPath.startsWith("/") ? nextPath : "/dashboard");
} else {
@@ -82,7 +81,7 @@ function AccessForm() {
{error && {error}
}
@@ -99,7 +98,7 @@ function AccessForm() {
Something went wrong
{error}
-