Skip to content

Commit

Permalink
logo
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilliam96 committed Sep 16, 2024
1 parent 3da6cc5 commit 6796053
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
12 changes: 3 additions & 9 deletions frontend/src/app/(user)/perfil/[name]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,15 +28,8 @@ export default async function PerfilLayout({ children, params }: Props) {

return (
<div>
<div className="flex justify-between bg-[#D9D9D9] pt-10 pb-2 px-2 text-[#979797]">
<Link href={'/'}>
<BackArrow />
</Link>
<h1 className=" font-bold text-xl text-black">Mi Perfil</h1>
<Link href={'/edit/' + profile._id}>
<IconConfig />
</Link>
</div>

<TopMenu id={profile._id} />

<div className="flex items-center ml-8 gap-3 my-6">
<figure className="relative size-20 rounded-full overflow-hidden">
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/EditProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -17,6 +18,14 @@ interface EditProfileProps {
}

const EditProfileForm: React.FC<EditProfileProps> = ({ user }) => {

const route = useRouter()
const token = localStorage.getItem("token")

if (!token) {
route.push("/register")
}

const [profileImg, setProfileImg] = useState<string>('imageUrl' in user ? user.imageUrl : '')
const updateUserComplete = updateUserAction.bind(null, profileImg, user)
const [formState, formAction] = useFormState(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ui/perfil/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]

Expand Down
27 changes: 27 additions & 0 deletions frontend/src/ui/perfil/TopMenu.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="flex justify-between bg-[#D9D9D9] pt-10 pb-2 px-2 text-[#979797]">
<Link href={'/'}>
<BackArrow />
</Link>
<h1 className=" font-bold text-xl text-black">
{
token === id ? "Mi Perfil" : "Perfil"
}
</h1>
<Link href={'/edit/' + id}>
<IconConfig />
</Link>
</div>
)
}

0 comments on commit 6796053

Please sign in to comment.