Skip to content

Commit dea57dd

Browse files
Merge pull request #52 from hack4impact/feature/51-dashboard-layout
feat: Dashboard Layout
2 parents 43805ed + 1b8d1c9 commit dea57dd

21 files changed

Lines changed: 1294 additions & 80 deletions

File tree

__tests__/sanity.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen } from "@testing-library/react";
2-
import DashboardPage from "@/app/dashboard/page";
2+
import DashboardPage from "@/app/(authenticated)/dashboard/page";
33

44
describe("jest setup", () => {
55
it("runs React + Testing Library", async () => {
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function FinancePage() {
2+
return (
3+
<main className="flex min-h-screen flex-col p-8">
4+
<h1 className="text-3xl font-bold">Finance</h1>
5+
</main>
6+
);
7+
}

app/(authenticated)/layout.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { redirect } from "next/navigation";
2+
import { createClient } from "@/utils/supabase/server";
3+
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
4+
import { TooltipProvider } from "@/components/ui/tooltip";
5+
import { AppSidebar } from "@/components/app-sidebar";
6+
7+
export default async function AuthenticatedLayout({
8+
children,
9+
}: {
10+
children: React.ReactNode;
11+
}) {
12+
const supabase = await createClient();
13+
const {
14+
data: { user },
15+
} = await supabase.auth.getUser();
16+
17+
if (!user) {
18+
redirect("/login");
19+
}
20+
21+
return (
22+
<TooltipProvider>
23+
<SidebarProvider>
24+
<AppSidebar />
25+
<SidebarInset>
26+
<div className="flex flex-1 flex-col gap-4 p-4">
27+
{children}
28+
</div>
29+
</SidebarInset>
30+
</SidebarProvider>
31+
</TooltipProvider>
32+
);
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function MembershipsPage() {
2+
return (
3+
<main className="flex min-h-screen flex-col p-8">
4+
<h1 className="text-3xl font-bold">Memberships</h1>
5+
</main>
6+
)
7+
}

app/page.tsx renamed to app/(authenticated)/page.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createClient } from "@/utils/supabase/server";
2-
import { signout } from "./login/actions";
2+
import { signout } from "@/app/login/actions";
33
import { getSubscriptionDetails } from "@/lib/stripe";
4-
import { hasUserPurchased } from "@/lib/purchases";
54
import {
65
Card,
76
CardContent,
@@ -23,17 +22,15 @@ export default async function Page() {
2322

2423
if (!user) return null;
2524

26-
const [subscription, ownsProduct] = await Promise.all([
27-
getSubscriptionDetails(user.id),
28-
hasUserPurchased(user.id, PRODUCT_PRICE_ID),
29-
]);
25+
const [subscription] = await Promise.all([getSubscriptionDetails(user.id)]);
26+
const ownsProduct = false;
3027

3128
return (
32-
<main className="flex min-h-screen items-center justify-center p-4">
33-
<div className="w-full max-w-md space-y-4">
34-
<Card>
29+
<main className="min-h-screen p-4 w-full">
30+
<div className="flex flex-row gap-4 w-full">
31+
<Card className="flex-1">
3532
<CardHeader>
36-
<CardTitle className="text-2xl">Welcome</CardTitle>
33+
<CardTitle className="text-2xl">Welcome t</CardTitle>
3734
<CardDescription>You are signed in as</CardDescription>
3835
</CardHeader>
3936
<CardContent className="space-y-4">
@@ -46,7 +43,7 @@ export default async function Page() {
4643
</CardContent>
4744
</Card>
4845

49-
<Card>
46+
<Card className="flex-1">
5047
<CardHeader>
5148
<CardTitle>Subscription</CardTitle>
5249
<CardDescription>
@@ -107,7 +104,7 @@ export default async function Page() {
107104
</CardContent>
108105
</Card>
109106

110-
<Card>
107+
<Card className="flex-1">
111108
<CardHeader>
112109
<CardTitle>Product</CardTitle>
113110
<CardDescription>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function ServicesPage() {
2+
return (
3+
<main className="flex min-h-screen flex-col p-8">
4+
<h1 className="text-3xl font-bold">Services</h1>
5+
</main>
6+
)
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function SettingsPage() {
2+
return (
3+
<main className="flex min-h-screen flex-col p-8">
4+
<h1 className="text-3xl font-bold">Settings</h1>
5+
</main>
6+
);
7+
}

0 commit comments

Comments
 (0)