diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx
index 2cdc3a8..5a6cd1a 100644
--- a/app/auth/login/page.tsx
+++ b/app/auth/login/page.tsx
@@ -1,12 +1,20 @@
+'use client';
+
+import { useState, FormEvent } from 'react';
+import { useAuth } from '@/lib/auth';
+import { API_URL } from '@/lib/api';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Input } from '@/components/ui/input';
+
const LoginPage = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const auth = useAuth();
- // In a real app, you'd use Next.js's useRouter
const [isLoggedIn, setIsLoggedIn] = useState(false);
- const handleSubmit = async (e) => {
+ const handleSubmit = async (e: FormEvent) => {
e.preventDefault();
setError('');
try {
@@ -27,17 +35,15 @@ const LoginPage = () => {
const { id_token, uid } = await response.json();
- // A real app would fetch user details here, but we'll mock it
- const userDetails = { uid, email, role: 'user' }; // Assume 'user' for now
+ const userDetails = { uid, email, role: 'user' };
auth.login(id_token, userDetails);
- setIsLoggedIn(true); // Simulate redirect
- } catch (err) {
+ setIsLoggedIn(true);
+ } catch (err: any) {
setError(err.message);
}
};
if (isLoggedIn || auth.isAuthenticated) {
- // In a real app, this would be a redirect to '/'
return
Redirecting...
;
}
@@ -64,4 +70,6 @@ const LoginPage = () => {
);
- };
\ No newline at end of file
+ };
+
+ export default LoginPage;
\ No newline at end of file
diff --git a/app/main/admin/page.tsx b/app/main/admin/page.tsx
index 2a510a2..d002f5c 100644
--- a/app/main/admin/page.tsx
+++ b/app/main/admin/page.tsx
@@ -1,3 +1,11 @@
+'use client';
+
+import { useState } from 'react';
+import { useAuth } from '@/lib/auth';
+import { apiRequest } from '@/lib/api';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+
const AdminPage = () => {
const [message, setMessage] = useState('');
const [error, setError] = useState('');
@@ -9,12 +17,11 @@ const AdminPage = () => {
try {
const data = await apiRequest('/videos/scan', { method: 'POST', token: auth.token });
setMessage(data.message);
- } catch (err) {
+ } catch (err: any) {
setError(err.message);
}
};
- // In a real app, you'd fetch users and votes here
const users = [{email: 'admin@example.com', role: 'admin'}, {email: 'user@example.com', role: 'user'}];
const votes = [{video_id: 'xyz', decision: 'approve', reason: 'Good clip'}];
@@ -38,7 +45,6 @@ const AdminPage = () => {
Users
- {/* User list would be rendered here */}
User list functionality would go here.
@@ -46,10 +52,11 @@ const AdminPage = () => {
Votes
- {/* Vote list would be rendered here */}
Vote list functionality would go here.
);
-};
\ No newline at end of file
+};
+
+export default AdminPage;
\ No newline at end of file
diff --git a/app/main/layout.tsx b/app/main/layout.tsx
index d506ae5..76eb0c2 100644
--- a/app/main/layout.tsx
+++ b/app/main/layout.tsx
@@ -1,8 +1,14 @@
-const MainLayout = ({ children }) => {
+'use client';
+
+import React from 'react';
+import { useAuth } from '@/lib/auth';
+import LoginPage from '@/app/auth/login/page';
+import { Button } from '@/components/ui/button';
+
+const MainLayout = ({ children }: { children: React.ReactNode }) => {
const auth = useAuth();
if (!auth.isAuthenticated) {
- // This would be a redirect in a real Next.js app
return ;
}
@@ -13,7 +19,7 @@ const MainLayout = ({ children }) => {