ui update
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { NextResponse, NextRequest } from 'next/server';
|
||||
import database from '../database';
|
||||
import { ObjectId } from 'mongodb';
|
||||
|
||||
// Account login
|
||||
// Email exists
|
||||
// Password is valid
|
||||
export async function GET(req: NextRequest) {
|
||||
const sessionId = new URL(req.url).searchParams.get('id');
|
||||
|
||||
if (typeof sessionId !== 'string')
|
||||
return NextResponse.json(
|
||||
{
|
||||
message: 'Invalid structure, required param `id=`',
|
||||
},
|
||||
{ status: 400 }
|
||||
);
|
||||
|
||||
const user = await database.sessions.findOne({
|
||||
_id: new ObjectId(sessionId),
|
||||
});
|
||||
|
||||
if (!user)
|
||||
return NextResponse.json(
|
||||
{
|
||||
message: 'Invalid session',
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
message: 'ok',
|
||||
dashboard: {
|
||||
engagement: [
|
||||
{ week: 'Mo', views: 7300 },
|
||||
{ week: 'Tuesday', views: 18000 },
|
||||
{ week: 'Wednesday', views: 12000 },
|
||||
{ week: 'Thursday', views: 12000 },
|
||||
{ week: 'Friday', views: 23000 },
|
||||
{ week: 'Saturday', views: 40000 },
|
||||
{ week: 'Sunday', views: 20000 },
|
||||
],
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
}
|
||||
@@ -38,9 +38,7 @@ function CalendarApp() {
|
||||
isDark: true,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
console.log(eventsService.getAll());
|
||||
}, [eventsService]);
|
||||
useEffect(() => {}, [eventsService]);
|
||||
|
||||
const [newPostDialogOpen, setNewPostDialogOpen] = useState(false);
|
||||
const [date, setDate] = useState<Date>(today);
|
||||
|
||||
@@ -4,8 +4,17 @@ import Ideas from '@/components/ideas';
|
||||
import RecentPosts from '@/components/recentPosts';
|
||||
import App from '@/components/app';
|
||||
import { Calendar } from '@/components/ui/calendar';
|
||||
import { cookies } from 'next/headers';
|
||||
import axios from 'axios';
|
||||
|
||||
export default async function Dashboard() {
|
||||
const cookieStore = await cookies();
|
||||
const sessionId = cookieStore.get('session_id')?.value;
|
||||
|
||||
const data = (
|
||||
await axios.get(`http:/localhost:3000/api/session/?id=${sessionId}`)
|
||||
).data.dashboard;
|
||||
|
||||
export default function Dashboard() {
|
||||
return (
|
||||
<App>
|
||||
<div className="flex flex-1 flex-col p-6 px-5 md:px-10 h-max">
|
||||
@@ -14,7 +23,7 @@ export default function Dashboard() {
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-5 flex flex-col xl:flex-row gap-5 items-stretch">
|
||||
<Engagement />
|
||||
<Engagement chartData={data.engagement} />
|
||||
<div className="w-full pb-7 border rounded-2xl">
|
||||
<Calendar
|
||||
className="h-full w-full flex"
|
||||
@@ -30,8 +39,8 @@ export default function Dashboard() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-5 flex gap-5">
|
||||
<div className="flex flex-col w-max gap-5">
|
||||
<div className="w-full mt-5 flex gap-5 flex-col xl:flex-row">
|
||||
<div className="flex flex-col w-full gap-5 xl:w-[400px]">
|
||||
<Ideas
|
||||
ideas={[
|
||||
{
|
||||
|
||||
@@ -58,10 +58,6 @@ export default function SignUp() {
|
||||
})
|
||||
.then(async (response) => {
|
||||
document.cookie = `session_id=${response.data.sessionId}`;
|
||||
console.log(
|
||||
'Account created with session',
|
||||
response.data
|
||||
);
|
||||
router.push('/dashboard');
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user