mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-18 01:34:43 +02:00
more validation and redirects
This commit is contained in:
parent
0ff183796c
commit
57ba84eb02
18 changed files with 620 additions and 443 deletions
|
@ -1,8 +1,13 @@
|
|||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
import { Inter, Manrope, Open_Sans, Roboto } from "next/font/google";
|
||||
import { Inter } from "next/font/google";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { ThemeProvider } from "@app/providers/ThemeProvider";
|
||||
import { ListOrgsResponse } from "@server/routers/org";
|
||||
import { internal } from "@app/api";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { authCookieHeader } from "@app/api/cookies";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: process.env.NEXT_PUBLIC_APP_NAME,
|
||||
|
@ -16,6 +21,23 @@ export default async function RootLayout({
|
|||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (!orgs.length) {
|
||||
redirect(`/setup`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error fetching orgs", e);
|
||||
}
|
||||
|
||||
return (
|
||||
<html suppressHydrationWarning>
|
||||
<body className={`${font.className} pb-3`}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue