mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-06-29 14:56:46 +00:00
refactor: enhance authentication and signup flow with new providers, update middleware matcher, and improve type safety for API responses
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import SignUpForm from "@/components/auth/signup-form";
|
||||
import type { ApiResponse, Atoll, Island } from "@/lib/backend-types";
|
||||
import { getAtolls } from "@/queries/islands";
|
||||
import Image from "next/image";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
@ -8,11 +10,10 @@ export default async function SignupPage({
|
||||
searchParams: Promise<{ phone_number: string }>;
|
||||
}) {
|
||||
|
||||
const atolls = await getAtollsWithIslands();
|
||||
console.log(atolls.data);
|
||||
const phone_number = (await searchParams).phone_number;
|
||||
console.log({ phone_number })
|
||||
if (!phone_number) {
|
||||
return redirect("/login");
|
||||
return redirect("/auth/login");
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +27,7 @@ export default async function SignupPage({
|
||||
Pay for your devices and track your bills.
|
||||
</p>
|
||||
</div>
|
||||
<SignUpForm atolls={atolls.data} />
|
||||
<SignUpForm />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ApplicationLayout } from "@/components/auth/application-layout";
|
||||
import QueryProvider from "@/components/query-provider";
|
||||
import QueryProvider from "@/providers/query-provider";
|
||||
|
||||
export default function DashboardLayout({
|
||||
children,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ThemeProvider } from "@/components/theme-provider";
|
||||
import { ThemeProvider } from "@/providers/theme-provider";
|
||||
import { Provider } from "jotai";
|
||||
|
||||
import type { Metadata } from "next";
|
||||
@ -6,6 +6,10 @@ import { Barlow } from "next/font/google";
|
||||
import NextTopLoader from "nextjs-toploader";
|
||||
import { Toaster } from "sonner";
|
||||
import "./globals.css";
|
||||
import { AuthProvider } from "@/providers/AuthProvider";
|
||||
import QueryProvider from "@/providers/query-provider";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "./auth";
|
||||
const barlow = Barlow({
|
||||
subsets: ["latin"],
|
||||
weight: ["100", "300", "400", "500", "600", "700", "800", "900"],
|
||||
@ -17,27 +21,33 @@ export const metadata: Metadata = {
|
||||
description: "Sarlink Portal",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
const session = await getServerSession(authOptions);
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body className={`${barlow.variable} antialiased font-sans bg-gray-100 dark:bg-black`}>
|
||||
<Provider>
|
||||
<NextTopLoader color="#f49d1b" showSpinner={false} zIndex={9999} />
|
||||
<Toaster richColors />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</Provider>
|
||||
<AuthProvider session={session || undefined}>
|
||||
<Provider>
|
||||
<NextTopLoader color="#f49d1b" showSpinner={false} zIndex={9999} />
|
||||
<Toaster richColors />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
>
|
||||
<QueryProvider>
|
||||
{children}
|
||||
</QueryProvider>
|
||||
</ThemeProvider>
|
||||
</Provider>
|
||||
</AuthProvider>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user