diff --git a/src/app/components/Input.tsx b/src/app/components/Input.tsx new file mode 100644 index 0000000..c9e960c --- /dev/null +++ b/src/app/components/Input.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +interface InputProps { + id: string; + label: string; + value: string; + setChange: (event: React.ChangeEvent) => void; + required?: boolean; + type?: string; + placeholder?: string; +} + +const Input: React.FC = ({ id, label, value, setChange, required = false, type = "text", placeholder }) => { + return ( +
+ + +
+ ); +}; + +export default Input; diff --git a/src/app/components/MyUserButton.tsx b/src/app/components/MyUserButton.tsx new file mode 100644 index 0000000..a380397 --- /dev/null +++ b/src/app/components/MyUserButton.tsx @@ -0,0 +1,36 @@ +// components/MyUserButton.tsx + +'use client'; + +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; + +const MyUserButton = () => { + const [isLoggedIn, setIsLoggedIn] = useState(false); + const router = useRouter(); + + useEffect(() => { + // Check if the user is logged in (assuming token is stored in localStorage or cookies) + const token = localStorage.getItem('access_token'); // Or use cookies if you store the token there + if (token) { + setIsLoggedIn(true); + } + }, []); + + const handleNavigation = () => { + if (isLoggedIn) { + router.push('/dashboard'); + } else { + router.push('/user/register'); + } + }; + + return ( + + ); +}; + +export default MyUserButton;