Open History to see the last commit
1import { UserButton, useAuth } from "@clerk/react";
2import { LogInIcon, ServerIcon, SmartphoneIcon } from "lucide-react";
3
4import { hasCloudPublicConfig } from "../../cloud/publicConfig";
5import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "../ui/sidebar";
6import { MobileClientsUserProfilePage } from "./MobileClientsUserProfilePage";
7import { T3ConnectUserProfilePage } from "./T3ConnectUserProfilePage";
8import { useT3ConnectAuthPrompt } from "./useT3ConnectAuthPrompt";
9
10export function T3ConnectSidebarSignIn() {
11 if (!hasCloudPublicConfig()) return null;
12
13 return <ConfiguredT3ConnectSidebarSignIn />;
14}
15
16export function T3ConnectSidebarAvatar() {
17 if (!hasCloudPublicConfig()) return null;
18
19 return <ConfiguredT3ConnectSidebarAvatar />;
20}
21
22function ConfiguredT3ConnectSidebarAvatar() {
23 const { isLoaded, isSignedIn } = useAuth();
24
25 if (!isLoaded || !isSignedIn) return null;
26
27 return (
28 <UserButton
29 appearance={{
30 elements: {
31 avatarBox: "size-7",
32 userButtonTrigger: "rounded-lg p-1 hover:bg-sidebar-row-hover",
33 },
34 }}
35 >
36 <UserButton.UserProfilePage
37 label="Mobile clients"
38 labelIcon={<SmartphoneIcon className="size-4" />}
39 url="mobile-clients"
40 >
41 <MobileClientsUserProfilePage />
42 </UserButton.UserProfilePage>
43 <UserButton.UserProfilePage
44 label="T3 Connect"
45 labelIcon={<ServerIcon className="size-4" />}
46 url="t3-connect"
47 >
48 <T3ConnectUserProfilePage />
49 </UserButton.UserProfilePage>
50 </UserButton>
51 );
52}
53
54function ConfiguredT3ConnectSidebarSignIn() {
55 const { isLoaded, isSignedIn } = useAuth();
56 const { authPrompt, openAuthPrompt } = useT3ConnectAuthPrompt();
57
58 if (!isLoaded || isSignedIn) return null;
59
60 return (
61 <>
62 <SidebarMenu>
63 <SidebarMenuItem>
64 <SidebarMenuButton onClick={openAuthPrompt}>
65 <LogInIcon />
66 <span>Sign in to T3 Connect</span>
67 </SidebarMenuButton>
68 </SidebarMenuItem>
69 </SidebarMenu>
70 {authPrompt}
71 </>
72 );
73}