feat(app): add user profile settings

This commit is contained in:
Lars Hampe 2024-10-01 10:27:33 +02:00
parent d5034383b8
commit 417a382abe
5 changed files with 43 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import {
DropdownMenuTrigger, DropdownMenuTrigger,
} from '@boring.tools/ui' } from '@boring.tools/ui'
import { SignOutButton, useUser } from '@clerk/clerk-react' import { SignOutButton, useUser } from '@clerk/clerk-react'
import { Link } from '@tanstack/react-router'
import type { ReactNode } from 'react' import type { ReactNode } from 'react'
import { Navigation } from './Navigation' import { Navigation } from './Navigation'
import { NavigationMobile } from './NavigationMobile' import { NavigationMobile } from './NavigationMobile'
@ -23,7 +24,7 @@ export const Layout = ({ children }: { children: ReactNode | ReactNode[] }) => {
<div className="flex flex-col"> <div className="flex flex-col">
<header className="flex h-14 items-center gap-4 border-b bg-muted/40 px-4 lg:h-[60px] lg:px-6"> <header className="flex h-14 items-center gap-4 border-b bg-muted/40 px-4 lg:h-[60px] lg:px-6">
<NavigationMobile /> <NavigationMobile />
{/* <div className="w-full flex-1"></div> */} <div className="w-full flex-1" />
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button <Button
@ -35,7 +36,10 @@ export const Layout = ({ children }: { children: ReactNode | ReactNode[] }) => {
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end"> <DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel> <DropdownMenuLabel>Settings</DropdownMenuLabel>
<DropdownMenuItem asChild>
<Link to="/user">Profile</Link>
</DropdownMenuItem>
<DropdownMenuSeparator /> <DropdownMenuSeparator />
<DropdownMenuItem> <DropdownMenuItem>
<SignOutButton> <SignOutButton>

View File

@ -25,7 +25,7 @@ export const Navigation = () => {
<div className="flex-1"> <div className="flex-1">
<nav className="grid items-start px-2 text-sm font-medium lg:px-4"> <nav className="grid items-start px-2 text-sm font-medium lg:px-4">
<Link <Link
href="#" to="/"
className="flex items-center gap-3 rounded-lg px-3 py-2 transition-all hover:text-primary" className="flex items-center gap-3 rounded-lg px-3 py-2 transition-all hover:text-primary"
activeProps={{ className: 'bg-muted text-primary' }} activeProps={{ className: 'bg-muted text-primary' }}
> >

View File

@ -18,6 +18,7 @@ import { Route as rootRoute } from './routes/__root'
const AboutLazyImport = createFileRoute('/about')() const AboutLazyImport = createFileRoute('/about')()
const IndexLazyImport = createFileRoute('/')() const IndexLazyImport = createFileRoute('/')()
const UserIndexLazyImport = createFileRoute('/user/')()
// Create/Update Routes // Create/Update Routes
@ -31,6 +32,11 @@ const IndexLazyRoute = IndexLazyImport.update({
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route)) } as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
const UserIndexLazyRoute = UserIndexLazyImport.update({
path: '/user/',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/user/index.lazy').then((d) => d.Route))
// Populate the FileRoutesByPath interface // Populate the FileRoutesByPath interface
declare module '@tanstack/react-router' { declare module '@tanstack/react-router' {
@ -49,6 +55,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AboutLazyImport preLoaderRoute: typeof AboutLazyImport
parentRoute: typeof rootRoute parentRoute: typeof rootRoute
} }
'/user/': {
id: '/user/'
path: '/user'
fullPath: '/user'
preLoaderRoute: typeof UserIndexLazyImport
parentRoute: typeof rootRoute
}
} }
} }
@ -57,36 +70,41 @@ declare module '@tanstack/react-router' {
export interface FileRoutesByFullPath { export interface FileRoutesByFullPath {
'/': typeof IndexLazyRoute '/': typeof IndexLazyRoute
'/about': typeof AboutLazyRoute '/about': typeof AboutLazyRoute
'/user': typeof UserIndexLazyRoute
} }
export interface FileRoutesByTo { export interface FileRoutesByTo {
'/': typeof IndexLazyRoute '/': typeof IndexLazyRoute
'/about': typeof AboutLazyRoute '/about': typeof AboutLazyRoute
'/user': typeof UserIndexLazyRoute
} }
export interface FileRoutesById { export interface FileRoutesById {
__root__: typeof rootRoute __root__: typeof rootRoute
'/': typeof IndexLazyRoute '/': typeof IndexLazyRoute
'/about': typeof AboutLazyRoute '/about': typeof AboutLazyRoute
'/user/': typeof UserIndexLazyRoute
} }
export interface FileRouteTypes { export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/' | '/about' fullPaths: '/' | '/about' | '/user'
fileRoutesByTo: FileRoutesByTo fileRoutesByTo: FileRoutesByTo
to: '/' | '/about' to: '/' | '/about' | '/user'
id: '__root__' | '/' | '/about' id: '__root__' | '/' | '/about' | '/user/'
fileRoutesById: FileRoutesById fileRoutesById: FileRoutesById
} }
export interface RootRouteChildren { export interface RootRouteChildren {
IndexLazyRoute: typeof IndexLazyRoute IndexLazyRoute: typeof IndexLazyRoute
AboutLazyRoute: typeof AboutLazyRoute AboutLazyRoute: typeof AboutLazyRoute
UserIndexLazyRoute: typeof UserIndexLazyRoute
} }
const rootRouteChildren: RootRouteChildren = { const rootRouteChildren: RootRouteChildren = {
IndexLazyRoute: IndexLazyRoute, IndexLazyRoute: IndexLazyRoute,
AboutLazyRoute: AboutLazyRoute, AboutLazyRoute: AboutLazyRoute,
UserIndexLazyRoute: UserIndexLazyRoute,
} }
export const routeTree = rootRoute export const routeTree = rootRoute
@ -102,7 +120,8 @@ export const routeTree = rootRoute
"filePath": "__root.tsx", "filePath": "__root.tsx",
"children": [ "children": [
"/", "/",
"/about" "/about",
"/user/"
] ]
}, },
"/": { "/": {
@ -110,6 +129,9 @@ export const routeTree = rootRoute
}, },
"/about": { "/about": {
"filePath": "about.lazy.tsx" "filePath": "about.lazy.tsx"
},
"/user/": {
"filePath": "user/index.lazy.tsx"
} }
} }
} }

View File

@ -0,0 +1,10 @@
import { UserProfile } from '@clerk/clerk-react'
import { createLazyFileRoute } from '@tanstack/react-router'
const Component = () => {
return <UserProfile routing="virtual" />
}
export const Route = createLazyFileRoute('/user/')({
component: Component,
})

BIN
bun.lockb

Binary file not shown.