diff --git a/frontend/src/app/(user)/perfil/[name]/layout.tsx b/frontend/src/app/(user)/perfil/[name]/layout.tsx index cfab721..d127b68 100644 --- a/frontend/src/app/(user)/perfil/[name]/layout.tsx +++ b/frontend/src/app/(user)/perfil/[name]/layout.tsx @@ -5,6 +5,7 @@ import { User } from "@/interfaces/user"; import Image from "next/image"; import Link from "next/link"; import NavBar from "@/ui/perfil/NavBar"; +import TopMenu from "@/ui/perfil/TopMenu"; interface Props { children: React.ReactNode @@ -27,15 +28,8 @@ export default async function PerfilLayout({ children, params }: Props) { return (
-
- - - -

Mi Perfil

- - - -
+ +
diff --git a/frontend/src/components/EditProfileForm.tsx b/frontend/src/components/EditProfileForm.tsx index 5192064..6e84166 100644 --- a/frontend/src/components/EditProfileForm.tsx +++ b/frontend/src/components/EditProfileForm.tsx @@ -7,6 +7,7 @@ import { SubmitButton } from "./SubmitButton" import { useState } from "react" import Image from "next/image" import { uploadSingleImage } from "@/services/uploadImageService" +import { useRouter } from "next/navigation" const INITIAL_STATE = { data: null, @@ -17,6 +18,14 @@ interface EditProfileProps { } const EditProfileForm: React.FC = ({ user }) => { + + const route = useRouter() + const token = localStorage.getItem("token") + + if (!token) { + route.push("/register") + } + const [profileImg, setProfileImg] = useState('imageUrl' in user ? user.imageUrl : '') const updateUserComplete = updateUserAction.bind(null, profileImg, user) const [formState, formAction] = useFormState( diff --git a/frontend/src/components/LoginForm.tsx b/frontend/src/components/LoginForm.tsx index 2c21cf2..6e4c72e 100644 --- a/frontend/src/components/LoginForm.tsx +++ b/frontend/src/components/LoginForm.tsx @@ -26,7 +26,7 @@ export default function LoginForm() { localStorage.setItem("userId", formState.id) if (formState.id) { - localStorage.setItem("user", formState.id) + localStorage.setItem("userId", formState.id) router.push(`/perfil/${formState.id}`) } } diff --git a/frontend/src/ui/perfil/NavBar.tsx b/frontend/src/ui/perfil/NavBar.tsx index d15e417..ce3ff7e 100644 --- a/frontend/src/ui/perfil/NavBar.tsx +++ b/frontend/src/ui/perfil/NavBar.tsx @@ -10,7 +10,7 @@ interface Props { export default function NavBar({ params }: Props) { const pathName = usePathname() - const userId = localStorage.getItem("user") + const userId = localStorage.getItem("userId") const listPerfil = [{ url: `/perfil/${params}`, title: "Album" }, { url: `/perfil/${params}/favorite`, title: "A visitar" }] diff --git a/frontend/src/ui/perfil/TopMenu.tsx b/frontend/src/ui/perfil/TopMenu.tsx new file mode 100644 index 0000000..6237f62 --- /dev/null +++ b/frontend/src/ui/perfil/TopMenu.tsx @@ -0,0 +1,27 @@ +"use client" + +import { BackArrow } from "@/components"; +import { IconConfig } from "@/components/icons"; +import Link from "next/link"; + +export default function TopMenu({ id }: { id: string }) { + + const token = localStorage.getItem("userId") + + + return ( +
+ + + +

+ { + token === id ? "Mi Perfil" : "Perfil" + } +

+ + + +
+ ) +}