code_runner/cmd/service_front/templates/profile.html

174 lines
4.8 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Профиль пользователя</title>
<style>
html {
height: 100%;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
height: 100%;
margin: 0;
padding: 20px;
}
.user-card {
width: 100%;
max-width: 800px;
margin: auto;
}
.toolbar {
background-color: #3f51b5;
padding: 15px 20px;
color: white;
border-radius: 8px 8px 0 0;
}
.toolbar-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.toolbar-title {
font-size: 20px;
font-weight: bold;
}
.toolbar-navigation {
margin-top: 10px;
}
.toolbar-btn {
background-color: #606fc7;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
text-decoration: none;
display: inline-block;
}
.toolbar-btn:hover {
background-color: #32408f;
}
.profile-container {
background-color: white;
padding: 30px;
border-radius: 0 0 8px 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.profile-header {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.avatar {
width: 80px;
height: 80px;
border-radius: 50%;
background-color: #3f51b5;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
margin-right: 20px;
}
.profile-info h2 {
margin: 0;
color: #333;
}
.profile-info p {
margin: 5px 0 0;
color: #666;
}
.profile-details {
margin-top: 30px;
}
.detail-row {
display: flex;
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid #eee;
}
.detail-label {
width: 150px;
font-weight: bold;
color: #555;
}
.detail-value {
flex: 1;
}
.logout-btn {
background-color: #696969;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.logout-btn:hover {
background-color: #424242;
}
</style>
</head>
<body>
<div class="user-card">
<div class="toolbar">
<div class="toolbar-header">
<div class="toolbar-title">Профиль пользователя</div>
<button class="logout-btn" id="logout-btn">Выйти</button>
</div>
<div class="toolbar-navigation">
<a href="/task" class="toolbar-btn">Задачи</a>
</div>
</div>
<div class="profile-container">
<div class="profile-header">
<div class="avatar" id="avatar">?</div>
<div class="profile-info">
<h2 id="user-email">{{ .userEmail }}</h2>
</div>
</div>
<div class="profile-details">
<div class="detail-row">
<div class="detail-label">Имя пользователя:</div>
<div class="detail-value" id="reg-date">{{ .userName }}</div>
</div>
<div class="detail-row">
<div class="detail-label">ID пользователя:</div>
<div class="detail-value" id="user-id">{{ .userId }}</div>
</div>
</div>
</div>
</div>
<script>
const userName = document.getElementById('reg-date').textContent;
const avatar = document.getElementById('avatar');
if (userName) {
const initials = userName.split(' ').map(n => n[0]).join('').toUpperCase();
avatar.textContent = initials || '?';
}
document.getElementById('logout-btn').addEventListener('click', async function () {
const response = await fetch('/logout', {
method: 'POST'
});
if (!response.ok) {
throw new Error('Ошибка выхода');
}
localStorage.removeItem('jwtToken');
localStorage.removeItem('userData');
window.location.href = '/';
});
</script>
</body>
</html>