= ({ userData }) => {
+ const firstName = userData.fullName;
+
+ return (
+
+
+
+
+
+ Hello {firstName}!
+
+
+
+
+
+
+
+
+ );
+};
+
+export default DashboardClient;
diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx
index 4320d8a..534f0e7 100644
--- a/app/dashboard/page.tsx
+++ b/app/dashboard/page.tsx
@@ -1,6 +1,6 @@
import { cookies } from 'next/headers';
-import { Container, Typography, Box } from '@mui/material';
-import ExampleEquations from 'app/components/ExampleEquations';
+import { redirect } from 'next/navigation';
+import DashboardClient from './DashboardClient';
interface UserData {
id: string;
@@ -14,41 +14,27 @@ const getUserData = (): UserData | null => {
const userDataCookie = cookieStore.get('user-data');
if (userDataCookie) {
- return JSON.parse(userDataCookie.value);
+ try {
+ return JSON.parse(userDataCookie.value);
+ } catch (error) {
+ console.error('Failed to parse user data cookie', error);
+ return null;
+ }
}
return null;
};
-const Dashboard = () => {
+const DashboardPage = () => {
const userData = getUserData();
if (!userData) {
- return (
-
- User not found. Please log in.
-
- );
+ redirect('/'); // Redirect to homepage if no user data is found
}
- const firstName = userData.fullName;
-
return (
-
-
-
-
-
- Hello {firstName}!
-
-
-
-
-
-
-
-
+
);
};
-export default Dashboard;
+export default DashboardPage;
\ No newline at end of file