Forráskód Böngészése

add more resource columns and add org list to landing page for testing

Milo Schwartz 8 hónapja
szülő
commit
e40328aeb7

+ 3 - 5
src/app/[orgId]/components/TopbarNav.tsx

@@ -40,8 +40,8 @@ export function TopbarNav({
                     className={cn(
                         "px-2 py-3 text-md",
                         pathname.startsWith(item.href.replace("{orgId}", orgId))
-                            ? "border-b-2 border-secondary text-secondary font-medium"
-                            : "hover:secondary-primary text-muted-foreground font-medium",
+                            ? "border-b-2 border-primary text-primary font-medium"
+                            : "hover:text-primary text-muted-foreground font-medium",
                         "whitespace-nowrap",
                         disabled && "cursor-not-allowed",
                     )}
@@ -51,9 +51,7 @@ export function TopbarNav({
                 >
                     <div className="flex items-center gap-2">
                         {item.icon && (
-                            <div className="hidden md:block">
-                                {item.icon}
-                            </div>
+                            <div className="hidden md:block">{item.icon}</div>
                         )}
                         {item.title}
                     </div>

+ 22 - 0
src/app/[orgId]/resources/components/ResourcesTable.tsx

@@ -17,6 +17,8 @@ export type ResourceRow = {
     id: string;
     name: string;
     orgId: string;
+    domain: string;
+    site: string;
 };
 
 export const columns: ColumnDef<ResourceRow>[] = [
@@ -36,6 +38,26 @@ export const columns: ColumnDef<ResourceRow>[] = [
             );
         },
     },
+    {
+        accessorKey: "site",
+        header: ({ column }) => {
+            return (
+                <Button
+                    variant="ghost"
+                    onClick={() =>
+                        column.toggleSorting(column.getIsSorted() === "asc")
+                    }
+                >
+                    Site
+                    <ArrowUpDown className="ml-2 h-4 w-4" />
+                </Button>
+            );
+        },
+    },
+    {
+        accessorKey: "domain",
+        header: "Domain",
+    },
     {
         id: "actions",
         cell: ({ row }) => {

+ 2 - 0
src/app/[orgId]/resources/page.tsx

@@ -25,6 +25,8 @@ export default async function Page({ params }: ResourcesPageProps) {
             id: resource.resourceId.toString(),
             name: resource.name,
             orgId: params.orgId,
+            domain: resource.subdomain || "",
+            site: resource.siteName || "None",
         };
     });
 

+ 1 - 1
src/app/auth/layout.tsx

@@ -5,7 +5,7 @@ type AuthLayoutProps = {
 export default async function AuthLayout({ children }: AuthLayoutProps) {
     return (
         <>
-            <div className="mt-32">
+            <div className="p-3 md:mt-32">
                 {children}
             </div>
         </>

+ 30 - 0
src/app/page.tsx

@@ -1,5 +1,11 @@
+import { internal } from "@app/api";
+import { authCookieHeader } from "@app/api/cookies";
 import { verifySession } from "@app/lib/auth/verifySession";
 import { LandingProvider } from "@app/providers/LandingProvider";
+import { ListOrgsResponse } from "@server/routers/org";
+import { AxiosResponse } from "axios";
+import { ArrowUpLeft, ArrowUpRight } from "lucide-react";
+import Link from "next/link";
 import { redirect } from "next/navigation";
 
 export default async function Page() {
@@ -9,11 +15,35 @@ export default async function Page() {
         redirect("/auth/login");
     }
 
+    let orgs: ListOrgsResponse["orgs"] = [];
+    try {
+        const res = await internal.get<AxiosResponse<ListOrgsResponse>>(
+            `/orgs`,
+            authCookieHeader(),
+        );
+        if (res && res.data.data.orgs) {
+            orgs = res.data.data.orgs;
+        }
+    } catch (e) {
+        console.error("Error fetching orgs", e);
+    }
+
     return (
         <>
             <LandingProvider user={user}>
                 <p>Logged in as {user.email}</p>
             </LandingProvider>
+
+            <div className="mt-4">
+            {orgs.map((org) => (
+                <Link key={org.orgId} href={`/${org.orgId}`} className="text-primary underline">
+                    <div className="flex items-center">
+                        {org.name}
+                        <ArrowUpRight className="w-4 h-4"/>
+                    </div>
+                </Link>
+            ))}
+            </div>
         </>
     );
 }