diff --git a/demo/nextjs/app/dashboard/page.tsx b/demo/nextjs/app/dashboard/page.tsx index d94dbb5a..d97959ae 100644 --- a/demo/nextjs/app/dashboard/page.tsx +++ b/demo/nextjs/app/dashboard/page.tsx @@ -3,21 +3,28 @@ import { headers } from "next/headers"; import { redirect } from "next/navigation"; import UserCard from "./user-card"; import { OrganizationCard } from "./organization-card"; +import AccountSwitcher from "@/components/account-swtich"; export default async function DashboardPage() { - const [session, activeSessions] = await Promise.all([ + const [session, activeSessions, deviceSessions] = await Promise.all([ auth.api.getSession({ headers: await headers(), }), auth.api.listSessions({ headers: await headers(), }), + auth.api.listDeviceSessions({ + headers: await headers(), + }), ]).catch((e) => { throw redirect("/sign-in"); }); return (
+ { + return; + }, + }); + const { data: currentUser } = useSession(); + const [open, setOpen] = useState(false); + + const handleUserSelect = (user: Session) => { + // setCurrentUser(user); + setOpen(false); + }; + + const handleAddAccount = () => { + // Implement add account logic here + console.log("Add account clicked"); + setOpen(false); + }; + const router = useRouter(); + return ( + + + + + + + + + {}} + className="text-sm w-full justify-between" + key={currentUser?.user.id} + > +
+ + + + {currentUser?.user.name.charAt(0)} + + + {currentUser?.user.name} +
+
+
+ + + {sessions + .filter((s) => s.user.id !== currentUser?.user.id) + .map((u, i) => ( + { + await client.multiSession.setActive({ + sessionId: u.session.id, + }); + setOpen(false); + }} + className="text-sm" + > + + + {u.user.name.charAt(0)} + +
+
+

{u.user.name}

+

({u.user.email})

+
+
+
+ ))} +
+
+ + + + { + router.push("/sign-in"); + setOpen(false); + }} + className="cursor-pointer text-sm" + > + + Add Account + + + +
+
+
+ ); +} diff --git a/demo/nextjs/components/ui/password-input.tsx b/demo/nextjs/components/ui/password-input.tsx index b18c5954..db6f1188 100644 --- a/demo/nextjs/components/ui/password-input.tsx +++ b/demo/nextjs/components/ui/password-input.tsx @@ -16,10 +16,12 @@ const PasswordInput = React.forwardRef( return (