Skip to content

Commit

Permalink
WOOO FIXED THE PROFILE PAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
lryanle committed Dec 2, 2023
1 parent fbf1817 commit c3aa66d
Show file tree
Hide file tree
Showing 74 changed files with 1,096 additions and 982 deletions.
4 changes: 4 additions & 0 deletions frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"WillLuke.nextjs.addTypesOnSave": true,
"WillLuke.nextjs.hasPrompted": true
}
20 changes: 10 additions & 10 deletions frontend/app/api/auth/[...nextauth]/authOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const authOptions: NextAuthOptions = {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code"
}
}
response_type: "code",
},
},
}),
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID as string,
Expand Down Expand Up @@ -69,13 +69,13 @@ export const authOptions: NextAuthOptions = {
// };
// },
authorization: {
params: { scope: 'openid profile email' },
params: { scope: "openid profile email" },
},
issuer: 'https://www.linkedin.com',
jwks_endpoint: 'https://www.linkedin.com/oauth/openid/jwks',
issuer: "https://www.linkedin.com",
jwks_endpoint: "https://www.linkedin.com/oauth/openid/jwks",
profile(profile, tokens) {
const defaultImage =
'https://cdn-icons-png.flaticon.com/512/174/174857.png';
"https://cdn-icons-png.flaticon.com/512/174/174857.png";
return {
id: profile.sub,
name: profile.name,
Expand All @@ -94,8 +94,8 @@ export const authOptions: NextAuthOptions = {
// // Find your user in the database using MongoDBAdapter
// const client = await clientPromise;
// const users = client.db("auth").collection("users");
// // Find user with the email

// // Find user with the email
// const result = await users.findOne({
// email: credentials?.email,
// });
Expand Down Expand Up @@ -148,4 +148,4 @@ export const authOptions: NextAuthOptions = {
return session;
},
},
};
};
1 change: 0 additions & 1 deletion frontend/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ import { authOptions } from "./authOptions";

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };

45 changes: 26 additions & 19 deletions frontend/app/api/user/route.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import prisma from '@/lib/prisma'; // adjust the import path as needed
import { getSession, useSession } from 'next-auth/react'
import { NextRequest } from 'next/server';
import useSWR from 'swr';
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@/lib/prisma"; // adjust the import path as needed
import { getSession, useSession } from "next-auth/react";
import { NextRequest } from "next/server";
import useSWR from "swr";

const fetcher = (url: string) => fetch(url, { next: { revalidate: 60 }}).then((res) => res.json())
const fetcher = (url: string) =>
fetch(url, { next: { revalidate: 60 } }).then((res) => res.json());

export async function GET(request: NextRequest) {
const session = request.nextUrl.searchParams.get('userId')
const { data } = useSWR(`/api/auth/session`, fetcher);
console.log(data)

const userId = request.nextUrl.searchParams.get("userId");
const email = request.nextUrl.searchParams.get("email");
const name = request.nextUrl.searchParams.get("name");

const session = { userId: userId, name: name, email: email };

try {
if (session) {
const provRaw = await prisma.account.findMany({ select: { provider: true } }, { where: {id: session }})

const provArray = provRaw.map((prov: {provider: string}) => {
return prov.provider
})
return Response.json(provArray);
const provRaw = await prisma.account.findMany(
{ select: { provider: true } },
{ where: { id: session.userId } }
);

const provArray = provRaw.map((prov: { provider: string }) => {
return prov.provider;
});

return Response.json({ name: name, providers: provArray, email: email });
} else {
return Response.json({ message: 'Unauthorized' })
return Response.json(session);
}
} catch (error) {
return Response.json({ message: 'Server error' });
return Response.json({ message: "Server error" });
}
}
}
250 changes: 132 additions & 118 deletions frontend/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,34 @@ import {
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ui/tabs";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { redirect } from "next/navigation";
import { Activity, Book, CalendarDays, Clock4, FileText, ShieldAlert, TableProperties } from "lucide-react";
import {
Activity,
Book,
CalendarDays,
Clock4,
FileText,
ShieldAlert,
TableProperties,
} from "lucide-react";

export const metadata: Metadata = {
title: "Dashboard",
description: "Example dashboard app built using the components.",
}
};

export default async function DashboardPage() {
const session = await getServerSession(authOptions);
if (!session) { redirect('/api/auth/signin') }
if (!session) {
redirect("/api/auth/signin");
}

return (session && (
<div className="py-24 w-10/12">
<div className="bg-whitehidden flex-col md:flex">
{/* <div className="border-b">
return (
session && (
<div className="py-24 w-10/12">
<div className="bg-whitehidden flex-col md:flex">
{/* <div className="border-b">
<div className="flex h-16 items-center px-4">
<TeamSwitcher />
<MainNav className="mx-6" />
Expand All @@ -45,112 +51,120 @@ export default async function DashboardPage() {
</div>
</div>
</div> */}
<div className="flex-1 space-y-4 p-8 pt-6">
<div className="flex flex-col md:flex-row justify-center items-center md:justify-between text-center md:text-left space-y-2">
<h2 className="text-3xl font-bold tracking-tight">Marketplace Listings Dashboard</h2>
<div className="flex items-center space-x-2">
<CalendarDateRangePicker />
<Button>Download</Button>
<div className="flex-1 space-y-4 p-8 pt-6">
<div className="flex flex-col md:flex-row justify-center items-center md:justify-between text-center md:text-left space-y-2">
<h2 className="text-3xl font-bold tracking-tight">
Marketplace Listings Dashboard
</h2>
<div className="flex items-center space-x-2">
<CalendarDateRangePicker />
<Button>Download</Button>
</div>
</div>
<Tabs
defaultValue="overview"
className="space-y-4 flex-col md:flex-row"
>
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="analytics" disabled>
Analytics
</TabsTrigger>
<TabsTrigger value="reports" disabled>
Reports
</TabsTrigger>
<TabsTrigger value="notifications" disabled>
Notifications
</TabsTrigger>
<TabsTrigger value="search" disabled>
Search
</TabsTrigger>
</TabsList>
<TabsContent value="overview" className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Total Listings
</CardTitle>
<FileText size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">286</div>
<p className="text-xs text-muted-foreground">
+1098% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Flagged Listings
</CardTitle>
<ShieldAlert size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+0</div>
<p className="text-xs text-muted-foreground">
+0% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
New Listings
</CardTitle>
<CalendarDays size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+243</div>
<p className="text-xs text-muted-foreground">
+876% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Listings Today
</CardTitle>
<Clock4 size={16} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+36</div>
<p className="text-xs text-muted-foreground">
+36 from last 24 hours
</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
<Card className="col-span-4">
<CardHeader>
<CardTitle>Overview</CardTitle>
</CardHeader>
<CardContent className="pl-2">
<Overview />
</CardContent>
</Card>
<Card className="col-span-3">
<CardHeader>
<CardTitle>Recent Listings</CardTitle>
<CardDescription>
8 listings flagged in the last 24 hours
</CardDescription>
</CardHeader>
<CardContent>
<RecentListings />
</CardContent>
</Card>
</div>
</TabsContent>
</Tabs>
</div>
<Tabs defaultValue="overview" className="space-y-4 flex-col md:flex-row">
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="analytics" disabled>
Analytics
</TabsTrigger>
<TabsTrigger value="reports" disabled>
Reports
</TabsTrigger>
<TabsTrigger value="notifications" disabled>
Notifications
</TabsTrigger>
<TabsTrigger value="search" disabled>
Search
</TabsTrigger>
</TabsList>
<TabsContent value="overview" className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Total Listings
</CardTitle>
<FileText size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">286</div>
<p className="text-xs text-muted-foreground">
+1098% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Flagged Listings
</CardTitle>
<ShieldAlert size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+0</div>
<p className="text-xs text-muted-foreground">
+0% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">New Listings</CardTitle>
<CalendarDays size={16} strokeWidth={2} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+243</div>
<p className="text-xs text-muted-foreground">
+876% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Listings Today
</CardTitle>
<Clock4 size={16} />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+36</div>
<p className="text-xs text-muted-foreground">
+36 from last 24 hours
</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
<Card className="col-span-4">
<CardHeader>
<CardTitle>Overview</CardTitle>
</CardHeader>
<CardContent className="pl-2">
<Overview />
</CardContent>
</Card>
<Card className="col-span-3">
<CardHeader>
<CardTitle>Recent Listings</CardTitle>
<CardDescription>
8 listings flagged in the last 24 hours
</CardDescription>
</CardHeader>
<CardContent>
<RecentListings />
</CardContent>
</Card>
</div>
</TabsContent>
</Tabs>
</div>
</div>
</div>
))
}
)
);
}
2 changes: 1 addition & 1 deletion frontend/app/error.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client' // Error components must be Client Components
"use client"; // Error components must be Client Components

import Meta, { defaultMetaProps } from "@/components/layout/meta";
import { useEffect } from "react";
Expand Down
Loading

0 comments on commit c3aa66d

Please sign in to comment.