-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
345b785
commit 2d3911b
Showing
13 changed files
with
192 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import Header from "@/app/modules/header.module"; | ||
import { Users } from "./page"; | ||
import style_sidebar from "@/app/styles/me/sidebar.module.css"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { Bandage } from "@/app/interfaces"; | ||
import { SkinViewer } from "skinview3d"; | ||
import { Card, generateSkin } from "@/app/modules/card.module"; | ||
import styles from "@/app/styles/me/me.module.css"; | ||
import { Me } from "@/app/modules/me.module"; | ||
import Link from "next/link"; | ||
|
||
const UsersClient = ({ user }: { user: Users }) => { | ||
const [elements, setElements] = useState<JSX.Element[]>(null); | ||
|
||
useEffect(() => { | ||
if (user.works) { | ||
const skinViewer = new SkinViewer({ | ||
width: 300, | ||
height: 300, | ||
renderPaused: true | ||
}); | ||
skinViewer.camera.rotation.x = -0.4; | ||
skinViewer.camera.rotation.y = 0.8; | ||
skinViewer.camera.rotation.z = 0.29; | ||
skinViewer.camera.position.x = 17; | ||
skinViewer.camera.position.y = 6.5; | ||
skinViewer.camera.position.z = 11; | ||
skinViewer.loadBackground("/static/background.png").then(() => { | ||
Promise.all(user?.works.map(async (el) => { | ||
try { | ||
console.log(el.base64) | ||
const result = await generateSkin(el.base64, Object.values(el.categories).some(val => val.id == 3)); | ||
console.log(result) | ||
await skinViewer.loadSkin(result); | ||
skinViewer.render(); | ||
const image = skinViewer.canvas.toDataURL(); | ||
return <Card el={el} base64={image} key={el.id} className={styles} /> | ||
} catch (e) { | ||
console.error(e) | ||
return; | ||
} | ||
})) | ||
.then(results => setElements(results)) | ||
.catch(error => console.error('Error generating skins', error)) | ||
.finally(() => skinViewer.dispose()); | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<body> | ||
<title>{`${user.name} · Повязки Pepeland`}</title> | ||
<Header /> | ||
<Me user_data={user}> | ||
<div style={elements ? { opacity: "1", transform: "translateY(0)" } : { opacity: "0", transform: "translateY(50px)" }} className={styles.cont}> | ||
<div style={{ display: "flex", flexDirection: "column", alignItems: "center" }}> | ||
<div className={style_sidebar.skins_container}> | ||
{elements} | ||
</div> | ||
</div> | ||
</div> | ||
</Me> | ||
|
||
</body> | ||
); | ||
} | ||
|
||
export default UsersClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Bandage } from "@/app/interfaces"; | ||
import NotFound from "@/app/not-found"; | ||
import axios from "axios"; | ||
import { redirect } from "next/navigation"; | ||
import UsersClient from "./client_code"; | ||
import { headers } from "next/headers"; | ||
|
||
export interface Users { | ||
userID: number, | ||
discordID: number, | ||
username: string, | ||
name: string, | ||
joined_at: Date, | ||
avatar: string, | ||
banner_color: string, | ||
works: Bandage[], | ||
is_self: boolean | ||
} | ||
|
||
const Users = async ({ params }: { params: { name: string } }) => { | ||
const headersList = headers() | ||
const cookie = headersList.get('Cookie'); | ||
const userAgent = headersList.get('User-Agent'); | ||
|
||
const data_request = await axios.get(`${process.env.NEXT_PUBLIC_GLOBAL_API_URL}users/${params.name}`, { | ||
withCredentials: true, | ||
validateStatus: () => true, | ||
headers: { | ||
"Cookie": cookie, | ||
"User-Agent": userAgent, | ||
"Unique-Access": process.env.TOKEN | ||
} | ||
}); | ||
|
||
if (data_request.status !== 200) { | ||
return <NotFound /> | ||
} | ||
|
||
const data = data_request.data as Users; | ||
if (data.is_self) { | ||
redirect('/me'); | ||
} | ||
|
||
return <UsersClient user={data} /> | ||
|
||
} | ||
|
||
export default Users; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { redirect } from "next/navigation"; | ||
|
||
const Users = () => { | ||
redirect('/'); | ||
} | ||
|
||
export default Users; |
Oops, something went wrong.