added components, removed username from user
This commit is contained in:
33
src/app/components/Input.tsx
Normal file
33
src/app/components/Input.tsx
Normal 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;
|
||||||
36
src/app/components/MyUserButton.tsx
Normal file
36
src/app/components/MyUserButton.tsx
Normal 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;
|
||||||
Reference in New Issue
Block a user