added components, removed username from user

This commit is contained in:
2024-10-14 05:22:41 +00:00
parent 25b1e3a389
commit f5207dd2ec
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import React from 'react';
interface InputProps {
id: string;
label: string;
value: string;
setChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
required?: boolean;
type?: string;
placeholder?: string;
}
const Input: React.FC<InputProps> = ({ id, label, value, setChange, required = false, type = "text", placeholder }) => {
return (
<div className="mb-4">
<label htmlFor={id} className="block text-sm font-medium text-gray-700">
{label}
</label>
<input
type={type}
id={id}
value={value}
onChange={setChange}
name={id}
placeholder={placeholder}
className="mt-1 p-2 block w-full border border-gray-300 rounded-md shadow-sm"
required={required}
/>
</div>
);
};
export default Input;

View File

@ -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 (
<button
onClick={handleNavigation} className='hover:text-gray-400'>
My User
</button>
);
};
export default MyUserButton;