47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
// 'use client';
|
|
// import React, { useEffect } from 'react';
|
|
|
|
// const Home = () => {
|
|
// useEffect(() => {
|
|
// console.log('Home component mounted on client');
|
|
// }, []);
|
|
|
|
// return <div>Welcome To Data4Autos Turn14 and eBay Integration</div>;
|
|
// };
|
|
|
|
// export default Home;
|
|
|
|
|
|
'use client';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import { useCookies } from 'react-cookie'; // If using 'react-cookie'
|
|
import { useRouter } from 'next/navigation';
|
|
|
|
const Home = () => {
|
|
const [cookies] = useCookies(['d4a_uid']); // Use correct cookie name
|
|
const [user, setUser] = useState(null);
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
const uid = cookies['d4a_uid'] || null; // Read cookie
|
|
if (!uid) {
|
|
router.push('/login'); // Redirect if not authenticated
|
|
} else {
|
|
setUser(uid); // Set user if authenticated
|
|
}
|
|
}, [cookies, router]);
|
|
|
|
if (!user) {
|
|
// Optional: Prevent flash of protected content
|
|
return <div>Checking authentication, please wait...</div>;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
Welcome To Data4Auto: Turn14 and eBay Integration
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Home; |