feat: add user profile page

This commit is contained in:
Kentai Radiquum 2024-07-19 09:47:29 +05:00
parent 32fc2e534d
commit 6fe7afd545
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
11 changed files with 383 additions and 23 deletions

17
app/profile/[id]/page.js Normal file
View 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
View 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}`)
}
}