-
-
-
-
SAR Link Portal
-
Pay for your devices and track your bills.
+export default async function LoginPage() {
+ const session = await auth.api.getSession({
+ headers: await headers(),
+ });
+ if (session) {
+ return redirect("/devices");
+ }
+ return (
+
+
+
+
+
SAR Link Portal
+
+ Pay for your devices and track your bills.
+
+
+
-
-
;
+ );
}
-
-
diff --git a/app/(auth)/signup/page.tsx b/app/(auth)/signup/page.tsx
index 30268e3..315300e 100644
--- a/app/(auth)/signup/page.tsx
+++ b/app/(auth)/signup/page.tsx
@@ -1,25 +1,51 @@
import SignUpForm from "@/components/auth/signup-form";
+import { auth } from "@/lib/auth";
import prisma from "@/lib/db";
+import { headers } from "next/headers";
import Image from "next/image";
+import { redirect } from "next/navigation";
import React from "react";
-export default async function LoginPage() {
- const atolls = await prisma.atoll.findMany({
- include: {
- islands: true
- }
- })
- return
-
-
-
+export default async function SignupPage({
+ searchParams,
+}: {
+ searchParams: Promise<{ phone_number: string }>;
+}) {
+ const session = await auth.api.getSession({
+ headers: await headers(),
+ });
+ if (session) {
+ return redirect("/devices");
+ }
-
SAR Link Portal
-
Pay for your devices and track your bills.
-
-
-
-
;
+ const phone_number = (await searchParams).phone_number;
+ if (!phone_number) {
+ return redirect("/login");
+ }
+ const atolls = await prisma.atoll.findMany({
+ include: {
+ islands: true,
+ },
+ });
+
+ return (
+
+
+
+
+
SAR Link Portal
+
+ Pay for your devices and track your bills.
+
+
+
+
+
+ );
}
-
-
diff --git a/app/(auth)/verify-otp/page.tsx b/app/(auth)/verify-otp/page.tsx
index 8a53726..79f1221 100644
--- a/app/(auth)/verify-otp/page.tsx
+++ b/app/(auth)/verify-otp/page.tsx
@@ -1,24 +1,34 @@
import VerifyOTPForm from "@/components/auth/verify-otp-form";
import Image from "next/image";
+import { redirect } from "next/navigation";
import React from "react";
export default async function VerifyOTP({
- searchParams,
+ searchParams,
}: {
- searchParams: Promise<{ phone_number: string }>
+ searchParams: Promise<{ phone_number: string }>;
}) {
- const phone_number = (await searchParams).phone_number
- return
-
-
-
+ const phone_number = (await searchParams).phone_number;
+ if (!phone_number) {
+ return redirect("/login");
+ }
+ console.log(
+ "phone number from server page params (verify otp page)",
+ phone_number,
+ );
-
SAR Link Portal
-
Pay for your devices and track your bills.
-
-
-
-
;
+ return (
+
+
+
+
+
SAR Link Portal
+
+ Pay for your devices and track your bills.
+
+
+
+
+
+ );
}
-
-
diff --git a/app/(dashboard)/devices/page.tsx b/app/(dashboard)/devices/page.tsx
index eeae826..028e529 100644
--- a/app/(dashboard)/devices/page.tsx
+++ b/app/(dashboard)/devices/page.tsx
@@ -1,5 +1,15 @@
+import { auth } from "@/lib/auth";
+import { headers } from "next/headers";
+
export default async function Devices() {
- return
-
Devices
- ;
+ const session = await auth.api.getSession({
+ headers: await headers(),
+ });
+
+ return (
+
+
Server session
+
{JSON.stringify(session?.user, null, 2)}
+
+ );
}
diff --git a/app/(dashboard)/payments/page.tsx b/app/(dashboard)/payments/page.tsx
index 90bbe8d..0d3e249 100644
--- a/app/(dashboard)/payments/page.tsx
+++ b/app/(dashboard)/payments/page.tsx
@@ -1,17 +1,14 @@
-'use client'
-import { PhoneInput } from '@/components/ui/phone-input'
-import React from 'react'
+"use client";
+import { authClient } from "@/lib/auth-client";
+import React from "react";
export default function MyPayments() {
- return (
-
+ const session = authClient.useSession();
- )
+ return (
+
+
Client session
+
{JSON.stringify(session.data, null, 2)}
+
+ );
}
diff --git a/app/(dashboard)/user-devices/page.tsx b/app/(dashboard)/user-devices/page.tsx
new file mode 100644
index 0000000..f874294
--- /dev/null
+++ b/app/(dashboard)/user-devices/page.tsx
@@ -0,0 +1,5 @@
+import React from "react";
+
+export default function UserDevices() {
+ return
UserDevices
;
+}
diff --git a/app/(dashboard)/user-payments/page.tsx b/app/(dashboard)/user-payments/page.tsx
new file mode 100644
index 0000000..0b2ccae
--- /dev/null
+++ b/app/(dashboard)/user-payments/page.tsx
@@ -0,0 +1,11 @@
+import { AdminAuthGuard } from "@/lib/auth-guard";
+import React from "react";
+
+export default async function UserPayments() {
+ await AdminAuthGuard();
+ return (
+
+
User Payments
+
+ );
+}
diff --git a/app/(dashboard)/users/page.tsx b/app/(dashboard)/users/page.tsx
new file mode 100644
index 0000000..a69f105
--- /dev/null
+++ b/app/(dashboard)/users/page.tsx
@@ -0,0 +1,56 @@
+import Filter from "@/components/filter";
+import Search from "@/components/search";
+import { UsersTable } from "@/components/user-table";
+import { AdminAuthGuard } from "@/lib/auth-guard";
+import { CheckCheck, Hourglass, Minus } from "lucide-react";
+import React, { Suspense } from "react";
+export default async function AdminUsers({
+ searchParams,
+}: {
+ searchParams: Promise<{
+ query: string;
+ page: number;
+ sortBy: string;
+ status: string;
+ }>;
+}) {
+ await AdminAuthGuard();
+
+ return (
+
+
+ Users
+
+
+
+ ,
+ },
+ {
+ value: "unverified",
+ label: "Unverfieid",
+ icon: ,
+ },
+ {
+ value: "verified",
+ label: "Verified",
+ icon: ,
+ },
+ ]}
+ defaultOption="all"
+ queryParamKey="status"
+ />
+
+
+
+
+
+ );
+}
diff --git a/app/layout.tsx b/app/layout.tsx
index 7d0e3f9..4de9a08 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,10 +1,11 @@
-import type { Metadata } from "next";
-import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
-import { Barlow } from "next/font/google";
-import NextTopLoader from 'nextjs-toploader';
-import { Toaster } from 'sonner'
+import type { Metadata } from "next";
+import { Barlow } from "next/font/google";
+import NextTopLoader from "nextjs-toploader";
+import { Toaster } from "sonner";
+import "./globals.css";
+import QueryProvider from "@/components/query-provider";
const barlow = Barlow({
subsets: ["latin"],
weight: ["100", "300", "400", "500", "600", "700", "800", "900"],
@@ -32,7 +33,7 @@ export default function RootLayout({
enableSystem
disableTransitionOnChange
>
- {children}
+
{children}