-
Notifications
You must be signed in to change notification settings - Fork 329
/
Copy pathsign-up-debug.tsx
54 lines (46 loc) · 1.86 KB
/
sign-up-debug.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use client';
import { SignedIn } from '@clerk/clerk-react';
import { useSignUpActorRef_internal, useSignUpSelector_internal } from '@clerk/elements/sign-up';
import { SignOutButton } from '@clerk/nextjs';
import { Button } from './design';
function SignUpActiveState() {
const activeState = useSignUpSelector_internal(state => state.value);
const state = activeState ? (typeof activeState === 'string' ? activeState : JSON.stringify({ ...activeState })) : '';
return (
<div className='flex gap-4 bottom-0 w-screen justify-center'>
<pre suppressHydrationWarning>Active State: {state}</pre>
</div>
);
}
export function SignUpLogButtons() {
const ref = useSignUpActorRef_internal();
return (
<>
<Button onClick={() => console.dir(ref.getSnapshot().context.formRef.getSnapshot().context.fields)}>
Log Fields
</Button>
<Button onClick={() => console.dir(ref.getSnapshot().context)}>Log Context</Button>
<Button onClick={() => console.dir(ref.getSnapshot().context.currentFactor)}>Log Current Factor</Button>
{/* @ts-expect-error - Intentionally not in exported clerk-js types */}
<Button onClick={() => console.dir(ref.getSnapshot().context.clerk.__unstable__environment)}>
Log Environment
</Button>
<Button onClick={() => console.dir(ref.getSnapshot().context.resource)}>Log Resource</Button>
</>
);
}
export function SignUpDebug() {
return (
<div className='absolute text-xs flex flex-col p-4 gap-4 bottom-0 justify-center bg-secondary border-tertiary border-t w-full overflow-hidden'>
<SignUpActiveState />
<div className='flex gap-4 bottom-0 w-screen justify-center'>
<SignUpLogButtons />
<SignedIn>
<SignOutButton redirectUrl='/sign-up'>
<Button>Sign Out</Button>
</SignOutButton>
</SignedIn>
</div>
</div>
);
}