Skip to content

Commit 4428a3f

Browse files
committed
Added a connection to the frontend
1 parent 0d936c5 commit 4428a3f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

frontend/src/app/dashboard/page.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
1+
'use client';
22
import { Button } from '@/components/ui/button';
33
import { CustomCard } from '@/components/ui/CustomCard';
44
import { ArrowRight, BookMarked, Copy, HelpCircle, MessageSquareText, UploadCloud } from 'lucide-react';
55
import Link from 'next/link';
6+
import { useEffect } from 'react';
7+
import { useAuth } from '@/contexts/AuthContext';
68

79
export default function DashboardPage() {
10+
const { user, signOut } = useAuth();
811
const features = [
912
{
1013
title: 'Upload Material',
@@ -43,6 +46,38 @@ export default function DashboardPage() {
4346
},
4447
];
4548

49+
const userID = user || 'u_123';
50+
51+
52+
const makeSession = async () => {
53+
const session = await fetch('http://localhost:8000/apps/EduAssitant_Agents/users/' + userID + '/sessions/s_123', {
54+
method: 'POST',
55+
headers: {
56+
'Content-Type': 'application/json',
57+
},
58+
body: JSON.stringify({
59+
state: {
60+
key1: 'value1',
61+
key2: 42,
62+
}
63+
}),
64+
});
65+
66+
if (!session.ok) {
67+
throw new Error('Failed to create session');
68+
}
69+
70+
const session_id = (await session.json()).session_id;
71+
localStorage.setItem('session_id', session_id);
72+
console.log(session_id);
73+
}
74+
75+
useEffect(() => {
76+
console.log('Dashboard Page')
77+
makeSession();
78+
}, [])
79+
80+
4681
return (
4782
<div className="container mx-auto">
4883
<h1 className="mb-8 text-3xl font-bold font-headline tracking-tight text-foreground">

0 commit comments

Comments
 (0)