diff --git a/src/app/dashboard/(active)/account/loading.tsx b/src/app/dashboard/(active)/account/loading.tsx new file mode 100644 index 0000000..f67b7c1 --- /dev/null +++ b/src/app/dashboard/(active)/account/loading.tsx @@ -0,0 +1,34 @@ +import { Skeleton } from "@/components/ui/skeleton" +import { NewPasskeyButton } from "./passkey-button" + +export default function Loading() { + return ( +
+

Account

+
+ + +
+
+ Name: + +
+ +
+ Email: + +
+
+ Telegram: + +
+
+
+
+

Passkeys

+ + +
+
+ ) +} diff --git a/src/app/dashboard/(active)/account/page.tsx b/src/app/dashboard/(active)/account/page.tsx index a8f78d8..e6c00a0 100644 --- a/src/app/dashboard/(active)/account/page.tsx +++ b/src/app/dashboard/(active)/account/page.tsx @@ -22,12 +22,12 @@ export default async function Account() { const { user } = session return ( -
+

Account

- + {user.image && } - + {user.name ? getInitials(user.name) : } diff --git a/src/app/dashboard/(active)/azure/members/loading.tsx b/src/app/dashboard/(active)/azure/members/loading.tsx index ac43fc0..a6bd30c 100644 --- a/src/app/dashboard/(active)/azure/members/loading.tsx +++ b/src/app/dashboard/(active)/azure/members/loading.tsx @@ -2,7 +2,7 @@ import { SkeletonAssocTable } from "./table" export default function Loading() { return ( -
+
) diff --git a/src/app/dashboard/(active)/azure/members/page.tsx b/src/app/dashboard/(active)/azure/members/page.tsx index b0b276e..4a4d975 100644 --- a/src/app/dashboard/(active)/azure/members/page.tsx +++ b/src/app/dashboard/(active)/azure/members/page.tsx @@ -1,16 +1,14 @@ import { Suspense } from "react" import { ErrorBoundary } from "react-error-boundary" import { Spinner } from "@/components/spinner" -import { wait } from "@/lib/utils" import { getAzureMembers } from "@/server/actions/azure" import { AssocTable } from "./table" export default async function AssocMembers() { const members = await getAzureMembers() - // await wait(120_000) return ( -
+
Something went wrong
}> }> diff --git a/src/app/dashboard/(active)/azure/page.tsx b/src/app/dashboard/(active)/azure/page.tsx deleted file mode 100644 index 853533d..0000000 --- a/src/app/dashboard/(active)/azure/page.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { UsersRound } from "lucide-react" -import Image from "next/image" -import Link from "next/link" -import azureSvg from "@/assets/svg/azure.svg" -import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" - -export default function AssocIndex() { - return ( -
-

- azure logo - Azure -

-
- - - - - - Members - - Manage all @polinetwork.org accounts - - - -
-
- ) -} diff --git a/src/app/dashboard/(active)/breadcrumb.tsx b/src/app/dashboard/(active)/breadcrumb.tsx new file mode 100644 index 0000000..17052fe --- /dev/null +++ b/src/app/dashboard/(active)/breadcrumb.tsx @@ -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 ( + + + {items.map((item, i) => ( + + + {i === items.length - 1 ? ( + {item.title} + ) : item.url ? ( + {item.title} + ) : ( + item.title + )} + + {i < items.length - 1 && } + + ))} + + + ) +} + +function getBreadcrumbs(navMap: Map, 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 +} diff --git a/src/app/dashboard/(active)/complete-profile.tsx b/src/app/dashboard/(active)/complete-profile.tsx index 8de2c3f..89fc4ac 100644 --- a/src/app/dashboard/(active)/complete-profile.tsx +++ b/src/app/dashboard/(active)/complete-profile.tsx @@ -1,13 +1,17 @@ "use client" -import type { User } from "better-auth" import { UserRoundPenIcon } from "lucide-react" import Link from "next/link" import { Button } from "@/components/ui/button" +import { useSession } from "@/lib/auth" + +export function CompleteProfile() { + const { data, isPending } = useSession() + + if (!data || isPending) return null -export function CompleteProfile({ user }: { user: User }) { return ( - !user.name && ( + !data.user.name && (

Your profile is incomplete, please enter the missing information.

diff --git a/src/app/dashboard/(active)/layout.tsx b/src/app/dashboard/(active)/layout.tsx new file mode 100644 index 0000000..f0b6d5e --- /dev/null +++ b/src/app/dashboard/(active)/layout.tsx @@ -0,0 +1,41 @@ +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 cookieStore = await cookies() + const cookie = cookieStore.get(COOKIES.SIDEBAR_CATEGORY_STATE)?.value + const DSCategoryState = cookie ? parseCookie(cookie) : {} + + return ( + + + +
+ + +
+
+ {children} +
+
+ ) +} +// diff --git a/src/app/dashboard/(active)/page.tsx b/src/app/dashboard/(active)/page.tsx index db2caba..a0cb34b 100644 --- a/src/app/dashboard/(active)/page.tsx +++ b/src/app/dashboard/(active)/page.tsx @@ -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 && ( -
- -

Home

- -
- - - - - azure logo - Azure - - Manage Azure related things - - - - - - - - - telegram logo - Telegram - - Manage Telegram related things - - - -
-
- ) +
+ + + + Page under construction + Use the sidebar to access the sections + +
) } diff --git a/src/app/dashboard/(active)/telegram/grants/loading.tsx b/src/app/dashboard/(active)/telegram/grants/loading.tsx index f74f889..753f796 100644 --- a/src/app/dashboard/(active)/telegram/grants/loading.tsx +++ b/src/app/dashboard/(active)/telegram/grants/loading.tsx @@ -4,8 +4,8 @@ import { NewGrant } from "./new-grant" export default async function Loading() { return ( -
-
+
+

Telegram Grants

diff --git a/src/app/dashboard/(active)/telegram/grants/page.tsx b/src/app/dashboard/(active)/telegram/grants/page.tsx index 737f356..ce41ade 100644 --- a/src/app/dashboard/(active)/telegram/grants/page.tsx +++ b/src/app/dashboard/(active)/telegram/grants/page.tsx @@ -8,8 +8,8 @@ export default async function GrantsPage() { const { grants: scheduled } = await trpc.tg.grants.getScheduled.query() return ( -
-
+
+

Telegram Grants

diff --git a/src/app/dashboard/(active)/telegram/groups/group-row.tsx b/src/app/dashboard/(active)/telegram/groups/group-row.tsx index acc2bac..f5b6e9a 100644 --- a/src/app/dashboard/(active)/telegram/groups/group-row.tsx +++ b/src/app/dashboard/(active)/telegram/groups/group-row.tsx @@ -1,5 +1,5 @@ "use client" -import { Copy, Pen } from "lucide-react" +import { Copy } from "lucide-react" import { useRouter } from "next/navigation" import { toast } from "sonner" import { Badge } from "@/components/ui/badge" diff --git a/src/app/dashboard/(active)/telegram/groups/loading.tsx b/src/app/dashboard/(active)/telegram/groups/loading.tsx index 9bd5207..77b98c0 100644 --- a/src/app/dashboard/(active)/telegram/groups/loading.tsx +++ b/src/app/dashboard/(active)/telegram/groups/loading.tsx @@ -3,7 +3,7 @@ import { SearchInput } from "./search-input" export default async function Loading() { return ( -
+

Count:

diff --git a/src/app/dashboard/(active)/telegram/groups/page.tsx b/src/app/dashboard/(active)/telegram/groups/page.tsx index 6753e61..8987115 100644 --- a/src/app/dashboard/(active)/telegram/groups/page.tsx +++ b/src/app/dashboard/(active)/telegram/groups/page.tsx @@ -12,7 +12,7 @@ export default async function TgGroups({ searchParams }: { searchParams: Promise const sorted = rows.sort((a, b) => a.title.localeCompare(b.title)) return ( -
+

Count: {rows.length} diff --git a/src/app/dashboard/(active)/telegram/page.tsx b/src/app/dashboard/(active)/telegram/page.tsx deleted file mode 100644 index c9adc44..0000000 --- a/src/app/dashboard/(active)/telegram/page.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { MessageCircleMore, Sparkle, UserCog, Users } from "lucide-react" -import Image from "next/image" -import Link from "next/link" -import telegramSvg from "@/assets/svg/telegram.svg" -import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" - -export default function TelegramIndex() { - return ( -

-

- telegram logo - Telegram -

-
- - - - - - Groups - - Search groups and get links - - - - - - - - - - User Details - - Manage user roles and group admins - - - - - - - - - - User List - - See list of all our users - - - - - - - - - - Grants - - Manage grants - - - -
-
- ) -} diff --git a/src/app/dashboard/(active)/telegram/user-details/page.tsx b/src/app/dashboard/(active)/telegram/user-details/page.tsx index 40d1671..276ba7f 100644 --- a/src/app/dashboard/(active)/telegram/user-details/page.tsx +++ b/src/app/dashboard/(active)/telegram/user-details/page.tsx @@ -1,6 +1,5 @@ "use client" -import { ArrowLeft, RefreshCcw, Search, X } from "lucide-react" -import Link from "next/link" +import { RefreshCcw, Search, X } from "lucide-react" import { Suspense, useState, useTransition } from "react" import { Spinner } from "@/components/spinner" import { Button } from "@/components/ui/button" @@ -34,11 +33,7 @@ export default function TgUsers() { } return ( -
- - Back - - +