-
Notifications
You must be signed in to change notification settings - Fork 0
feat: sidebar #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feat: sidebar #39
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
3ac11aa
style: update (dark) sidebar css variables
lorenzocorallo aaed723
feat: sidebar boilerplate and breadcrumb header
lorenzocorallo da6760c
some refactor
lorenzocorallo 1d485af
feat: use collapsible
lorenzocorallo ef68226
fix: add tg/grants and remove boilerplate
lorenzocorallo c8ad53a
feat: storage hooks and cookies utility
lorenzocorallo 24828cd
feat: user nav, category open state persistence
lorenzocorallo 1a5d70d
fix: cookie expiration, use <Link> instead of <a>
lorenzocorallo fba8bd3
chore: remove zustand, remove old i18n, biome fixes
lorenzocorallo 73acf8f
feat: sidebar item icons, type cleanup
lorenzocorallo 6099b46
feat: remove category pages, adjust page padding
lorenzocorallo ec3c62e
chore: biome
lorenzocorallo 454e9db
style: adjust destructive color variable
lorenzocorallo fc32ad7
style: container mx-auto by default
lorenzocorallo 51e171e
fix: remove category pages, dont create link for category in breadcrumb
lorenzocorallo 6362566
fix: re-render issue with the use-cookie-storage hook
lorenzocorallo 075f156
fix: same as previous commit, but for use-session-storage
lorenzocorallo 21c64c5
fix: coderabbit suggestion
lorenzocorallo e9fd9e7
fix: match also subroutes in category items
lorenzocorallo 60d3617
fix: catch JSON parse error
lorenzocorallo 2510a36
fix: rename column in groups
lorenzocorallo f6e4fa3
style: move breadcrumb to center
lorenzocorallo fd76b34
fix: cleanup home
lorenzocorallo d7388b5
style: button icon svg size
lorenzocorallo ba20b0b
Merge branch 'main' into sidebar
lorenzocorallo 57d3a23
style: fix padding mismatch between pages and loadings
lorenzocorallo 5003e80
feat: loading skeleton for account page
lorenzocorallo 0b1596c
perf: make dashboard homepage static for now
lorenzocorallo c266bae
feat: add associations management with card component and delete dialog
BIA3IA c78ecdb
feat: add No association found message for empty state
BIA3IA dff8b4d
Connect getAllAssociations and move client logic from page
BIA3IA c3eb226
Refactor AssociationsList integration
BIA3IA 009bc1a
feat: update association card to display initials when logo is not pr…
BIA3IA a24b0af
refactor: integrate AssociationsList functionality directly into Asso…
BIA3IA 2e6279e
feat: implement create, edit, and delete association functionalities
BIA3IA cdcf54a
fix: improve getInitials function to remove "-"
BIA3IA 37b7e07
feat: error handling for delete, save, edit
BIA3IA ff68966
feat: add loading state to save and cancel actions
BIA3IA aee00a8
feat: update button variants for success and error states in UI compo…
BIA3IA 5b24e28
feat: implement association links management with dialog and save fun…
BIA3IA 585f6f6
fix: review
lorenzocorallo 4797e44
fix: bring back user details page, link from user list
lorenzocorallo 61bfddb
feat: add back user search, make container flex(col) with pb-6
lorenzocorallo ce7da3c
fix: missing notFound in user-details, loading style
lorenzocorallo 8f351d4
fix: not found page
lorenzocorallo df0ae86
fix: add a11y to user details button
lorenzocorallo 73f8223
feat: update icon for Web section in navigation
BIA3IA 1df7f77
Merge commit 'df0ae868e2d0e0381ec4e74cff75d0df42367827' into web/asso…
BIA3IA fc4fbf8
fix: validate user ID and update last messages limit
BIA3IA ecefa99
Merge commit '1df7f77252231489983eb493e1eb7f6f4c5d5652' into sidebar
BIA3IA c4b9b7d
Revert "Merge commit '1df7f77252231489983eb493e1eb7f6f4c5d5652' into …
BIA3IA 6e1be95
Merge commit '4336f8a364b30dfca54284f482565e6486e84737' into sidebar
BIA3IA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { Skeleton } from "@/components/ui/skeleton" | ||
| import { NewPasskeyButton } from "./passkey-button" | ||
|
|
||
| export default function Loading() { | ||
| return ( | ||
| <main className="container"> | ||
| <h2 className="text-accent-foreground mb-4 text-3xl font-bold">Account</h2> | ||
| <div className="flex gap-4 mb-12"> | ||
| <Skeleton className="h-32 w-32 rounded-full" /> | ||
|
|
||
| <div className="flex flex-col gap-2"> | ||
| <div className="flex items-center gap-2"> | ||
| <span className="text-accent-foreground/70">Name:</span> | ||
| <Skeleton className="w-40 h-5" /> | ||
| </div> | ||
|
|
||
| <div className="flex items-center gap-2"> | ||
| <span className="text-accent-foreground/70">Email:</span> | ||
| <Skeleton className="w-70 h-5" /> | ||
| </div> | ||
| <div className="flex items-center gap-2"> | ||
| <span className="text-accent-foreground/70">Telegram:</span> | ||
| <Skeleton className="w-60 h-5" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-col gap-4 justify-start items-start"> | ||
| <h3>Passkeys</h3> | ||
| <Skeleton className="w-full h-10" /> | ||
| <NewPasskeyButton /> | ||
| </div> | ||
| </main> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| "use client" | ||
| import { usePathname } from "next/navigation" | ||
| import { Fragment, useMemo } from "react" | ||
| import { NAV_MAP } from "@/components/dashboard-sidebar/data" | ||
| import { | ||
| BreadcrumbItem as BreadcrumbItemComponent, | ||
| BreadcrumbLink, | ||
| BreadcrumbList, | ||
| BreadcrumbPage, | ||
| Breadcrumb as BreadcrumbRoot, | ||
| BreadcrumbSeparator, | ||
| } from "@/components/ui/breadcrumb" | ||
|
|
||
| export type BreadcrumbItem = { | ||
| title: string | ||
| url?: string | ||
| } | ||
|
|
||
| export function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) { | ||
| const pathname = usePathname() | ||
| const items = useMemo(() => getBreadcrumbs(NAV_MAP, pathname), [pathname]) | ||
|
|
||
| return ( | ||
| <BreadcrumbRoot className={className} {...props}> | ||
| <BreadcrumbList> | ||
| {items.map((item, i) => ( | ||
| <Fragment key={`breadcrumb-item-${i}`}> | ||
| <BreadcrumbItemComponent className="hidden md:block"> | ||
| {i === items.length - 1 ? ( | ||
| <BreadcrumbPage>{item.title}</BreadcrumbPage> | ||
| ) : item.url ? ( | ||
| <BreadcrumbLink href={item.url}>{item.title}</BreadcrumbLink> | ||
| ) : ( | ||
| item.title | ||
| )} | ||
| </BreadcrumbItemComponent> | ||
| {i < items.length - 1 && <BreadcrumbSeparator className="hidden md:block" />} | ||
| </Fragment> | ||
| ))} | ||
| </BreadcrumbList> | ||
| </BreadcrumbRoot> | ||
| ) | ||
| } | ||
|
|
||
| function getBreadcrumbs(navMap: Map<string, string>, pathname: string): BreadcrumbItem[] { | ||
| const segments = pathname.split("/").filter(Boolean) | ||
| const breadcrumbs: BreadcrumbItem[] = [] | ||
|
|
||
| let currentPath = "" | ||
| let i = 0 | ||
|
|
||
| for (const segment of segments) { | ||
| currentPath += `/${segment}` | ||
| let title = navMap.get(currentPath) | ||
| if (!title) { | ||
| if (isUUIDorId(segment)) { | ||
| title = "Details" | ||
| } else { | ||
| title = segment.charAt(0).toUpperCase() + segment.slice(1) | ||
| } | ||
| } | ||
|
|
||
| // note: at the moment we do not plan to make category pages. | ||
| // If such pages are made in the future, this logic can be removed | ||
| breadcrumbs.push({ title, url: i !== 1 ? currentPath : undefined }) | ||
| i++ | ||
| } | ||
|
|
||
| return breadcrumbs | ||
| } | ||
|
|
||
| function isUUIDorId(segment: string) { | ||
| return !Number.isNaN(Number(segment)) || segment.length > 20 // Regex custom a seconda dei tuoi ID | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { cookies } from "next/headers" | ||
| import { DashboardSidebar } from "@/components/dashboard-sidebar" | ||
| import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar" | ||
| import { COOKIES } from "@/constants" | ||
| import { Breadcrumb } from "./breadcrumb" | ||
|
|
||
| function parseCookie(cookie: string) { | ||
| try { | ||
| const parsed = JSON.parse(cookie) | ||
| return parsed | ||
| } catch (_e) { | ||
| return {} | ||
| } | ||
| } | ||
|
|
||
| export default async function AdminLayout({ children }: { children: React.ReactNode }) { | ||
| const sidebarCookies = await getSidebarCookies() | ||
|
|
||
| return ( | ||
| <SidebarProvider | ||
| defaultOpen={sidebarCookies.open} | ||
| style={ | ||
| { | ||
| "--sidebar-width": "19rem", | ||
| } as React.CSSProperties | ||
| } | ||
| > | ||
| <DashboardSidebar categoryState={sidebarCookies.state} /> | ||
| <SidebarInset className="px-4"> | ||
| <header className="flex h-16 shrink-0 relative items-center justify-between gap-2 border-b mb-8"> | ||
| <SidebarTrigger className="-ml-1" size="icon" /> | ||
| <Breadcrumb className="absolute left-1/2 -translate-x-1/2" /> | ||
|
lorenzocorallo marked this conversation as resolved.
|
||
| <div></div> | ||
| </header> | ||
| {children} | ||
| </SidebarInset> | ||
| </SidebarProvider> | ||
| ) | ||
| } | ||
|
|
||
| async function getSidebarCookies() { | ||
| const cookieStore = await cookies() | ||
|
|
||
| const sidebarCategoryStateCookie = cookieStore.get(COOKIES.SIDEBAR_CATEGORY_STATE)?.value | ||
| const sidebarOpenCookie = cookieStore.get(COOKIES.SIDEBAR_OPEN)?.value | ||
| const state: Record<string, boolean> = sidebarCategoryStateCookie ? parseCookie(sidebarCategoryStateCookie) : {} | ||
| const open: boolean = sidebarOpenCookie !== undefined ? parseCookie(sidebarOpenCookie) : true | ||
|
BIA3IA marked this conversation as resolved.
|
||
|
|
||
| return { state, open } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import Link from "next/link" | ||
| import { Button } from "@/components/ui/button" | ||
|
|
||
| export default function NotFound() { | ||
| return ( | ||
| <div className="flex flex-1 flex-col items-center justify-center gap-8 px-4"> | ||
| <div className="flex flex-col items-center gap-2 text-center"> | ||
| <h1 className="font-heading text-[12rem] leading-none font-bold tracking-tight text-primary">404</h1> | ||
| <h2 className="font-heading text-2xl font-semibold text-foreground">Not found</h2> | ||
| <p className="max-w-sm text-muted-foreground"> | ||
| The resource you're looking for doesn't exist or has been moved. | ||
| </p> | ||
| </div> | ||
| <Link href="."> | ||
| <Button>Go Back</Button> | ||
| </Link> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,16 @@ | ||
| import Image from "next/image" | ||
| import Link from "next/link" | ||
| import azureSvg from "@/assets/svg/azure.svg" | ||
| import telegramSvg from "@/assets/svg/telegram.svg" | ||
| import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" | ||
| import { getServerSession } from "@/server/auth" | ||
| import { InfoIcon } from "lucide-react" | ||
| import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" | ||
| import { CompleteProfile } from "./complete-profile" | ||
|
|
||
| export default async function AdminHome() { | ||
| const { data: session } = await getServerSession() | ||
| export default function AdminHome() { | ||
| return ( | ||
| session && ( | ||
| <div className="container py-8 px-2"> | ||
| <CompleteProfile user={session.user} /> | ||
| <h2 className="text-accent-foreground mb-4 text-3xl font-bold">Home</h2> | ||
|
|
||
| <div className="gap-4 flex justify-start flex-wrap items-center"> | ||
| <Link href="/dashboard/azure"> | ||
| <Card className="w-90 hover:bg-accent transition-colors"> | ||
| <CardHeader> | ||
| <CardTitle className="flex gap-2"> | ||
| <Image alt="azure logo" src={azureSvg} className="size-5" /> | ||
| Azure | ||
| </CardTitle> | ||
| <CardDescription>Manage Azure related things</CardDescription> | ||
| </CardHeader> | ||
| </Card> | ||
| </Link> | ||
|
|
||
| <Link href="/dashboard/telegram"> | ||
| <Card className="w-90 hover:bg-accent transition-colors"> | ||
| <CardHeader> | ||
| <CardTitle className="flex gap-2"> | ||
| <Image alt="telegram logo" src={telegramSvg} className="size-5" /> | ||
| Telegram | ||
| </CardTitle> | ||
| <CardDescription>Manage Telegram related things</CardDescription> | ||
| </CardHeader> | ||
| </Card> | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| ) | ||
| <div className="container"> | ||
| <CompleteProfile /> | ||
| <Alert variant="info"> | ||
| <InfoIcon /> | ||
| <AlertTitle>Page under construction</AlertTitle> | ||
| <AlertDescription>Use the sidebar to access the sections</AlertDescription> | ||
| </Alert> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.