feat: created UserPage.tsx
All checks were successful
Build and Deploy Go App / build (push) Successful in 6m33s
Build and Deploy Go App / deploy (push) Successful in 2m52s

This commit is contained in:
nihonium 2025-10-11 05:24:11 +03:00
parent 827431bb2f
commit fd0ca4411b
Signed by: nihonium
GPG key ID: 0251623741027CFC
3 changed files with 160 additions and 34 deletions

View file

@ -1,39 +1,8 @@
import React, { useEffect, useState } from "react";
import { DefaultService } from "./api/services/DefaultService"; // adjust path if needed
import type { User } from "./api/models/User"; // adjust path if needed
import React from "react";
import UserPage from "./components/UserPage/UserPage";
const App: React.FC = () => {
const [user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const getUserInfo = async () => {
try {
const userInfo = await DefaultService.getUsers("1", "all");
setUser(userInfo);
} catch (err) {
console.error(err);
setError("Failed to fetch user info.");
} finally {
setLoading(false);
}
};
getUserInfo();
}, []);
if (loading) return <div>Loading...</div>;
if (error) return <div>{error}</div>;
if (!user) return <div>No user found.</div>;
return (
<div style={{ padding: "2rem" }}>
<h1>User Info</h1>
<p><strong>ID:</strong> {user.user_id}</p>
<p><strong>Name:</strong> {user.nickname}</p>
<p><strong>Email:</strong> {user.mail}</p>
</div>
);
return <UserPage />;
};
export default App;