mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-07 00:34:41 +00: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
4
TODO.md
4
TODO.md
|
@ -20,7 +20,3 @@
|
||||||
- [ ] Избранное
|
- [ ] Избранное
|
||||||
- [ ] История
|
- [ ] История
|
||||||
- [ ] ...
|
- [ ] ...
|
||||||
|
|
||||||
## интерфейс
|
|
||||||
|
|
||||||
- [X] Динамический цвет от аватарки
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ export const UserProfile = (props) => {
|
||||||
<Image
|
<Image
|
||||||
className="circle"
|
className="circle"
|
||||||
src={props.profile.avatar}
|
src={props.profile.avatar}
|
||||||
alt="Ваш профиль"
|
alt=""
|
||||||
width="512"
|
width="512"
|
||||||
height="512"
|
height="512"
|
||||||
style={{ blockSize: "7rem", inlineSize: "7rem" }}
|
style={{ blockSize: "7rem", inlineSize: "7rem" }}
|
||||||
|
|
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>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -7,6 +7,10 @@ const nextConfig = {
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
hostname: "anixstatic.com",
|
hostname: "anixstatic.com",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
protocol: "https",
|
||||||
|
hostname: "i.imgur.com",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue