Создана страница OtherProfile, создан CSS к странице OtherProfile
This commit is contained in:
@@ -1,19 +1,51 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import React, {useState, useEffect} from 'react';
|
||||
import './css/OtherProfile.css';
|
||||
import {useParams, useNavigate} from 'react-router-dom';
|
||||
import axios from 'axios';
|
||||
import Header from './Header';
|
||||
|
||||
const OtherProfile = () => {
|
||||
const { id } = useParams();
|
||||
const {id} = useParams('');
|
||||
const [user, setUser] = useState(null);
|
||||
const [avatar, setAvatar] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
|
||||
return (
|
||||
<><Header />
|
||||
<div className="">
|
||||
|
||||
</div></>
|
||||
);
|
||||
}
|
||||
const navigate = useNavigate();
|
||||
const [user_description, setUserDescription] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
const checkSession = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/users/' + id);
|
||||
setUser(response.data.display_name);
|
||||
setAvatar(response.data.avatar_url);
|
||||
if (response.data.user_description === '') {
|
||||
setUserDescription('Описание отсутствует')
|
||||
} else {
|
||||
setUserDescription(response.data.user_description);
|
||||
}
|
||||
} catch (err) {
|
||||
setError('Вы не авторизованы');
|
||||
setTimeout(() => {
|
||||
navigate('/login');
|
||||
}, 1500);
|
||||
}
|
||||
};
|
||||
checkSession();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<><Header/>
|
||||
<div className="profile-page user-info">
|
||||
{error && <div className="error">{error}</div>}
|
||||
<div className="profile-info">
|
||||
<div className="name-with-avatar">
|
||||
<div className="user-name">{user}</div>
|
||||
<img className="profile-avatar" src={avatar}/>
|
||||
</div>
|
||||
<div className="user-description">{user_description}</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
export default OtherProfile;
|
||||
Reference in New Issue
Block a user