mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 01:19:41 +05:00
feat: add user profile page
This commit is contained in:
parent
32fc2e534d
commit
6fe7afd545
11 changed files with 383 additions and 23 deletions
17
app/profile/[id]/page.js
Normal file
17
app/profile/[id]/page.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { ProfilePage } from "@/app/pages/Profile";
|
||||
import { fetchDataViaGet } from "@/app/api/utils";
|
||||
import { ENDPOINTS } from "@/app/api/config";
|
||||
|
||||
export async function generateMetadata({ params }) {
|
||||
const id = params.id
|
||||
const profile = await fetchDataViaGet(`${ENDPOINTS.user.profile}/${id}`);
|
||||
|
||||
return {
|
||||
title: "Профиль " + profile.profile.login,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Search({ params }) {
|
||||
const id = params.id
|
||||
return <ProfilePage id={id} />;
|
||||
}
|
14
app/profile/page.js
Normal file
14
app/profile/page.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use client"
|
||||
import { useRouter } from "next/navigation";
|
||||
import { getJWT } from "../api/utils";
|
||||
|
||||
export default function myProfile() {
|
||||
const user = getJWT()
|
||||
const router = useRouter()
|
||||
|
||||
if (!user) {
|
||||
return router.push("/login")
|
||||
} else {
|
||||
return router.push(`/profile/${user.user_id}`)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue