mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 20:51:17 +00:00
new clients functionality
This commit is contained in:
parent
9dbacf4d45
commit
5edd697056
25 changed files with 1268 additions and 56 deletions
29
app/admin/clients/[id]/layout.tsx
Normal file
29
app/admin/clients/[id]/layout.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { notFound, redirect } from "next/navigation";
|
||||
import { createAdminClient } from "@/lib/supabase/admin";
|
||||
import { verifySession } from "@/lib/supabase/dal";
|
||||
|
||||
type Params = Promise<{ id: string }>;
|
||||
|
||||
export default async function ClientDetailLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: Params;
|
||||
}) {
|
||||
const session = await verifySession();
|
||||
if (!session.isAdmin) redirect("/client/dashboard");
|
||||
|
||||
const { id } = await params;
|
||||
const supabase = createAdminClient();
|
||||
const { data: client } = await supabase
|
||||
.from("profiles")
|
||||
.select("id")
|
||||
.eq("id", id)
|
||||
.eq("role", "client")
|
||||
.single();
|
||||
|
||||
if (!client) notFound();
|
||||
|
||||
return children;
|
||||
}
|
||||
26
app/admin/clients/[id]/page.tsx
Normal file
26
app/admin/clients/[id]/page.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { notFound } from "next/navigation";
|
||||
import { createAdminClient } from "@/lib/supabase/admin";
|
||||
|
||||
type Params = Promise<{ id: string }>;
|
||||
|
||||
const ClientDetailPage = async ({ params }: { params: Params }) => {
|
||||
const { id } = await params;
|
||||
const supabase = createAdminClient();
|
||||
const { data: client } = await supabase
|
||||
.from("profiles")
|
||||
.select("id, name, email")
|
||||
.eq("id", id)
|
||||
.eq("role", "client")
|
||||
.single();
|
||||
|
||||
if (!client) notFound();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<h1 className="text-3xl font-semibold">{client.name}</h1>
|
||||
<p className="text-muted-foreground">{client.email}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ClientDetailPage
|
||||
12
app/admin/clients/page.tsx
Normal file
12
app/admin/clients/page.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { verifySession } from "@/lib/supabase/dal"
|
||||
import ClientListViewPage from "@/modules/admin/ui/views/client-list-view";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
const Clients = async () => {
|
||||
const session = await verifySession();
|
||||
if (!session.isAdmin) redirect("/client/dashboard");
|
||||
|
||||
return <ClientListViewPage/>
|
||||
}
|
||||
|
||||
export default Clients
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { Metadata } from "next";
|
||||
import { Inter, JetBrains_Mono } from "next/font/google";
|
||||
import { ThemeProvider } from "@/components/theme-provider";
|
||||
import "./globals.css";
|
||||
|
||||
const inter = Inter({
|
||||
|
|
@ -22,8 +23,11 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
|||
<html
|
||||
lang="en"
|
||||
className={`${inter.variable} ${jetbrainsMono.variable} h-full antialiased`}
|
||||
suppressHydrationWarning
|
||||
>
|
||||
<body className="min-h-full flex flex-col">{children}</body>
|
||||
<body className="min-h-full flex flex-col">
|
||||
<ThemeProvider>{children}</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue