diff --git a/src/app/account/page.tsx b/src/app/account/page.tsx new file mode 100644 index 0000000..d3d9507 --- /dev/null +++ b/src/app/account/page.tsx @@ -0,0 +1,50 @@ +"use client"; +import { useEffect, useState } from "react"; +import styles from "../../styles/dashboard.module.css"; + +interface AccountData { + id: number; + login: string; + name: string | null; + email: string | null; + balance: number; +} + +export default function AccountPage() { + const [account, setAccount] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + fetch("/api/account") + .then((res) => { + if (!res.ok) throw new Error("Ошибка загрузки данных аккаунта"); + return res.json(); + }) + .then((data) => { + setAccount(data); + setLoading(false); + }) + .catch((err) => { + setError(err.message); + setLoading(false); + }); + }, []); + + if (loading) return
Загрузка...
; + if (error) return
Ошибка: {error}
; + if (!account) return
Нет данных
; + + return ( +
+

Аккаунт

+
+
ID: {account.id}
+
Логин: {account.login}
+
Имя: {account.name || "-"}
+
Email: {account.email || "-"}
+
Баланс: {account.balance.toLocaleString("ru-RU", { style: "currency", currency: "RUB" })}
+
+
+ ); +} \ No newline at end of file