mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 09:59:41 +05:00
frontend: add route to view other user profiles by id
This commit is contained in:
parent
9392345480
commit
78ca3ef054
4 changed files with 39 additions and 5 deletions
34
frontend/app/profile/[id]/page.js
Normal file
34
frontend/app/profile/[id]/page.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use client";
|
||||
import { UserProfile } from "@/app/components/UserProfile/UserProfile";
|
||||
import { endpoints } from "@/app/api/config";
|
||||
import { getData } from "@/app/api/api-utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export default function Profile(props) {
|
||||
const [profile, setProfile] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
async function _getProfile() {
|
||||
const _profile = await getData(
|
||||
`${endpoints.user.profile}/${props.params.id}`,
|
||||
);
|
||||
setProfile(_profile);
|
||||
}
|
||||
_getProfile();
|
||||
}, [props.params.id]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{profile ? (
|
||||
profile.profile ? (
|
||||
<UserProfile profile={profile.profile} />
|
||||
) : (
|
||||
notFound()
|
||||
)
|
||||
) : (
|
||||
<progress></progress>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue