Skip to content

Commit 4137700

Browse files
committed
build error fix.
1 parent fe7a3de commit 4137700

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

‎apps/codebility/app/auth/2fa-challenge/_components/TwoFactorForm.tsx‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
import { useState, useEffect } from "react";
44
import { useRouter, useSearchParams } from "next/navigation";
5-
import { getClientSupabase } from "@/utils/supabase/client";
5+
import { createClientClientComponent } from "@/utils/supabase/client";
66
import { Button } from "@/components/ui/button";
77
import { Input } from "@codevs/ui/input";
88
import { ArrowLeft } from "lucide-react";
99
import toast from "react-hot-toast";
1010

1111
export default function TwoFactorForm() {
12-
const [supabase] = useState(() => getClientSupabase());
1312
const [code, setCode] = useState("");
1413
const [isLoading, setIsLoading] = useState(false);
1514
const [factorId, setFactorId] = useState<string | null>(null);
@@ -18,6 +17,9 @@ export default function TwoFactorForm() {
1817

1918
useEffect(() => {
2019
async function loadFactors() {
20+
const supabase = createClientClientComponent();
21+
if (!supabase) return;
22+
2123
try {
2224
const { data, error } = await supabase.auth.mfa.listFactors();
2325
if (error) throw error;
@@ -35,7 +37,7 @@ export default function TwoFactorForm() {
3537
}
3638
}
3739
loadFactors();
38-
}, [supabase, router]);
40+
}, [router]);
3941

4042
const handleSubmit = async (e: React.FormEvent) => {
4143
e.preventDefault();
@@ -51,6 +53,13 @@ export default function TwoFactorForm() {
5153

5254
setIsLoading(true);
5355

56+
const supabase = createClientClientComponent();
57+
if (!supabase) {
58+
toast.error("Authentication service unavailable");
59+
setIsLoading(false);
60+
return;
61+
}
62+
5463
try {
5564
// Standard TOTP Challenge & Verify
5665
const { data, error } = await supabase.auth.mfa.challengeAndVerify({
@@ -74,6 +83,9 @@ export default function TwoFactorForm() {
7483
};
7584

7685
const handleSignOut = async () => {
86+
const supabase = createClientClientComponent();
87+
if (!supabase) return;
88+
7789
await supabase.auth.signOut();
7890
router.push("/auth/sign-in");
7991
};

‎apps/codebility/app/auth/2fa-challenge/page.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Logo from "@/components/shared/Logo";
33
import { Toaster } from "@/components/ui/toaster";
44
import TwoFactorForm from "./_components/TwoFactorForm";
55

6+
export const dynamic = "force-dynamic";
7+
68
export default function TwoFactorChallengePage() {
79
return (
810
<>

‎apps/codebility/app/home/account-settings/_components/AccountSettings2FA.tsx‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useEffect, useState } from "react";
4-
import { getClientSupabase } from "@/utils/supabase/client";
4+
import { createClientClientComponent } from "@/utils/supabase/client";
55
import { ShieldCheck, ShieldAlert, CheckCircle2, Copy, QrCode, Key, Lock } from "lucide-react";
66
import toast from "react-hot-toast";
77

@@ -25,7 +25,6 @@ interface Factor {
2525
}
2626

2727
export default function AccountSettings2FA() {
28-
const [supabase] = useState(() => getClientSupabase());
2928
const [loading, setLoading] = useState(true);
3029
const [factors, setFactors] = useState<Factor[]>([]);
3130
const [activeFactor, setActiveFactor] = useState<Factor | null>(null);
@@ -43,6 +42,12 @@ export default function AccountSettings2FA() {
4342
const [submitting, setSubmitting] = useState(false);
4443

4544
const fetchMfaFactors = async () => {
45+
const supabase = createClientClientComponent();
46+
if (!supabase) {
47+
setLoading(false);
48+
return;
49+
}
50+
4651
try {
4752
setLoading(true);
4853
const { data, error } = await supabase.auth.mfa.listFactors();
@@ -65,6 +70,12 @@ export default function AccountSettings2FA() {
6570
}, []);
6671

6772
const handleStartEnrollment = async () => {
73+
const supabase = createClientClientComponent();
74+
if (!supabase) {
75+
toast.error("Authentication service unavailable");
76+
return;
77+
}
78+
6879
try {
6980
setSubmitting(true);
7081
setVerificationCode("");
@@ -96,6 +107,12 @@ export default function AccountSettings2FA() {
96107
return;
97108
}
98109

110+
const supabase = createClientClientComponent();
111+
if (!supabase) {
112+
toast.error("Authentication service unavailable");
113+
return;
114+
}
115+
99116
try {
100117
setSubmitting(true);
101118

@@ -125,6 +142,12 @@ export default function AccountSettings2FA() {
125142
const handleDisable2FA = async () => {
126143
if (!activeFactor) return;
127144

145+
const supabase = createClientClientComponent();
146+
if (!supabase) {
147+
toast.error("Authentication service unavailable");
148+
return;
149+
}
150+
128151
try {
129152
setSubmitting(true);
130153
const { error } = await supabase.auth.mfa.unenroll({

0 commit comments

Comments
 (0)