Skip to content

Commit bed2d71

Browse files
committed
fix(*): update the invite page
1 parent 44cd484 commit bed2d71

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

app/(auth)/invite/page.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function InviteContent() {
1919
const { loginWithToken } = useAuth();
2020
const [status, setStatus] = useState<Status>("verifying");
2121
const [error, setError] = useState("");
22+
const [progress, setProgress] = useState(0);
2223

2324
useEffect(() => {
2425
const token = searchParams.get("token");
@@ -50,10 +51,6 @@ function InviteContent() {
5051

5152
loginWithToken(data.data.access_token, data.data.user);
5253
setStatus("success");
53-
54-
setTimeout(() => {
55-
if (!cancelled) router.push("/evaluations");
56-
}, 2000);
5754
} catch {
5855
if (!cancelled) {
5956
setStatus("error");
@@ -65,7 +62,28 @@ function InviteContent() {
6562
return () => {
6663
cancelled = true;
6764
};
68-
}, [searchParams, router, loginWithToken]);
65+
}, [searchParams, loginWithToken]);
66+
67+
useEffect(() => {
68+
if (status !== "success") return;
69+
70+
const duration = 2000;
71+
const interval = 30;
72+
let elapsed = 0;
73+
74+
const timer = setInterval(() => {
75+
elapsed += interval;
76+
const pct = Math.min((elapsed / duration) * 100, 100);
77+
setProgress(pct);
78+
79+
if (elapsed >= duration) {
80+
clearInterval(timer);
81+
router.push("/evaluations");
82+
}
83+
}, interval);
84+
85+
return () => clearInterval(timer);
86+
}, [status, router]);
6987

7088
return (
7189
<div className="min-h-screen bg-bg-secondary flex flex-col items-center justify-center p-4 relative overflow-hidden">
@@ -144,7 +162,10 @@ function InviteContent() {
144162
{status === "success" && (
145163
<div className="mt-6 flex justify-center">
146164
<div className="h-1 w-32 rounded-full bg-neutral-100 overflow-hidden">
147-
<div className="h-full bg-green-500 rounded-full animate-[progress_2s_ease-in-out]" />
165+
<div
166+
className="h-full bg-green-500 rounded-full transition-[width] duration-75 ease-linear"
167+
style={{ width: `${progress}%` }}
168+
/>
148169
</div>
149170
</div>
150171
)}

0 commit comments

Comments
 (0)