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

This commit is contained in:
Milo Schwartz
2024-10-19 17:01:23 -04:00
parent 57ba84eb02
commit e40328aeb7
5 changed files with 58 additions and 6 deletions

View File

@@ -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>
</>
);
}