MCPcopy
hub / github.com/wandb/openui / Register

Function Register

frontend/src/components/Register.tsx:16–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14import { sessionAtom } from 'state'
15
16export default function Register() {
17 const [error, setError] = useState<string | undefined>()
18 const [open, setOpen] = useState(false)
19 const setSessionData = useSetAtom(sessionAtom)
20
21 useEffect(() => {
22 const restoreSession = async () => {
23 const session = await getSession()
24 // Check if the response was a 404
25 if (session === undefined) {
26 setSessionData(undefined)
27 setOpen(true)
28 } else {
29 setSessionData(session)
30 setOpen(false)
31 }
32 }
33 const errorMessage = Cookies.get('error')
34 if (errorMessage) {
35 setError(errorMessage)
36 Cookies.remove('error')
37 }
38 restoreSession().catch((error_: unknown) => console.error(error_))
39 }, [setSessionData])
40
41 const title = 'Login'
42
43 return (
44 <Dialog
45 open={open}
46 onOpenChange={(op: boolean) => {
47 // TODO: should reload the page when in mid-registration
48 console.log(op)
49 }}
50 >
51 <DialogContent noClose className='sm:max-w-[425px]'>
52 <DialogHeader>
53 <DialogTitle>{title}</DialogTitle>
54 {error ? (
55 <DialogDescription className='mb-2 text-red-500 dark:text-red-400'>
56 {error}
57 </DialogDescription>
58 ) : (
59 <DialogDescription>
60 To enforce usage quotas an account is required.
61 </DialogDescription>
62 )}
63 </DialogHeader>
64 <div className='items-center'>
65 <Button asChild>
66 <a href='/v1/login'>
67 <GitHubLogoIcon className='mr-2' /> Login with GitHub
68 </a>
69 </Button>
70 </div>
71 </DialogContent>
72 </Dialog>
73 )

Callers

nothing calls this directly

Calls 2

restoreSessionFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected