v1.2
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
<title>Отклик | Rabota.Today</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
/* Стили аналогичные предыдущим страницам */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -64,6 +63,10 @@
|
||||
border-radius: 30px;
|
||||
}
|
||||
|
||||
.nav a:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.nav .active {
|
||||
background: #3b82f6;
|
||||
}
|
||||
@@ -89,6 +92,8 @@
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #dee9f5;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
@@ -189,6 +194,33 @@
|
||||
background: transparent;
|
||||
border: 2px solid #dee9f5;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 60px;
|
||||
color: #4f7092;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background: #fee2e2;
|
||||
color: #b91c1c;
|
||||
padding: 20px;
|
||||
border-radius: 30px;
|
||||
text-align: center;
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
.view-counter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
background: #eef4fa;
|
||||
padding: 5px 15px;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
color: #1f3f60;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -199,7 +231,7 @@
|
||||
Rabota.Today
|
||||
</div>
|
||||
<div class="nav" id="nav">
|
||||
<!-- Навигация -->
|
||||
<!-- Навигация будет заполнена динамически -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -211,33 +243,101 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE_URL = 'http://localhost:8000/api';
|
||||
const API_BASE_URL = window.location.protocol + '//' + window.location.host + '/api';
|
||||
const token = localStorage.getItem('accessToken');
|
||||
const pathParts = window.location.pathname.split('/');
|
||||
const applicationId = pathParts[pathParts.length - 1];
|
||||
|
||||
if (!token) window.location.href = '/login';
|
||||
let currentUser = null; // Объявляем переменную
|
||||
|
||||
if (!token) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
|
||||
// Функция для обновления навигации
|
||||
async function updateNavigation() {
|
||||
const nav = document.getElementById('nav');
|
||||
|
||||
if (!currentUser) {
|
||||
nav.innerHTML = `
|
||||
<a href="/">Главная</a>
|
||||
<a href="/vacancies">Вакансии</a>
|
||||
<a href="/resumes">Резюме</a>
|
||||
<a href="/login">Войти</a>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
const firstName = currentUser.full_name ? currentUser.full_name.split(' ')[0] : 'Профиль';
|
||||
const adminBadge = currentUser.is_admin ? '<span class="admin-badge">Admin</span>' : '';
|
||||
|
||||
nav.innerHTML = `
|
||||
<a href="/">Главная</a>
|
||||
<a href="/vacancies">Вакансии</a>
|
||||
<a href="/resumes">Резюме</a>
|
||||
<a href="/favorites">Избранное</a>
|
||||
<a href="/applications">Отклики</a>
|
||||
<a href="/profile" style="background: #3b82f6;">
|
||||
<i class="fas fa-user-circle"></i> ${firstName} ${adminBadge}
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
// Загрузка информации о пользователе
|
||||
async function loadCurrentUser() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/user`, {
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
currentUser = await response.json();
|
||||
await updateNavigation();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading user:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка отклика
|
||||
async function loadApplication() {
|
||||
try {
|
||||
console.log('Loading application:', applicationId);
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/applications/${applicationId}`, {
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Ошибка загрузки');
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Ошибка загрузки');
|
||||
}
|
||||
|
||||
const app = await response.json();
|
||||
console.log('Application loaded:', app);
|
||||
|
||||
renderApplication(app);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
console.error('Error loading application:', error);
|
||||
document.getElementById('applicationDetail').innerHTML = `
|
||||
<div class="error-message">
|
||||
<i class="fas fa-exclamation-circle"></i>
|
||||
Ошибка загрузки: ${error.message}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
// Отображение отклика
|
||||
function renderApplication(app) {
|
||||
const container = document.getElementById('applicationDetail');
|
||||
const isEmployer = app.employer_id === currentUser?.id;
|
||||
|
||||
// Определяем, кто просматривает (работодатель или соискатель)
|
||||
const isEmployerViewing = currentUser && app.employer_id === currentUser.id;
|
||||
const isEmployeeViewing = currentUser && app.user_id === currentUser.id;
|
||||
|
||||
// Статус на русском
|
||||
const statusText = {
|
||||
'pending': 'Ожидает',
|
||||
'viewed': 'Просмотрено',
|
||||
@@ -245,16 +345,22 @@
|
||||
'rejected': 'Отклонено'
|
||||
}[app.status] || app.status;
|
||||
|
||||
// Форматирование дат
|
||||
const createdDate = new Date(app.created_at).toLocaleString('ru-RU');
|
||||
const viewedDate = app.viewed_at ? new Date(app.viewed_at).toLocaleString('ru-RU') : null;
|
||||
const responseDate = app.response_at ? new Date(app.response_at).toLocaleString('ru-RU') : null;
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="status-bar">
|
||||
<span class="status-badge ${app.status}">${statusText}</span>
|
||||
<span class="date">Создано: ${new Date(app.created_at).toLocaleString()}</span>
|
||||
<span class="date">Создано: ${createdDate}</span>
|
||||
</div>
|
||||
|
||||
<h2>${escapeHtml(app.vacancy_title)}</h2>
|
||||
<h2 style="margin-bottom: 20px;">${escapeHtml(app.vacancy_title)}</h2>
|
||||
|
||||
<!-- Информация о вакансии -->
|
||||
<div class="section">
|
||||
<h3>Информация о вакансии</h3>
|
||||
<h3>📋 Информация о вакансии</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<i class="fas fa-building"></i>
|
||||
@@ -271,54 +377,96 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h3>Информация о соискателе</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<i class="fas fa-user"></i>
|
||||
<span>${escapeHtml(app.applicant_name)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-envelope"></i>
|
||||
<span>${escapeHtml(app.applicant_email)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-phone"></i>
|
||||
<span>${escapeHtml(app.applicant_phone || '—')}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fab fa-telegram"></i>
|
||||
<span>${escapeHtml(app.applicant_telegram || '—')}</span>
|
||||
<!-- Информация о соискателе (для работодателя) -->
|
||||
${isEmployerViewing ? `
|
||||
<div class="section">
|
||||
<h3>👤 Информация о соискателе</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<i class="fas fa-user"></i>
|
||||
<span>${escapeHtml(app.applicant_name)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-envelope"></i>
|
||||
<span>${escapeHtml(app.applicant_email)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-phone"></i>
|
||||
<span>${escapeHtml(app.applicant_phone || '—')}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fab fa-telegram"></i>
|
||||
<span>${escapeHtml(app.applicant_telegram || '—')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<!-- Информация о работодателе (для соискателя) -->
|
||||
${isEmployeeViewing ? `
|
||||
<div class="section">
|
||||
<h3>🏢 Информация о работодателе</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<i class="fas fa-user"></i>
|
||||
<span>${escapeHtml(app.employer_name)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-envelope"></i>
|
||||
<span>${escapeHtml(app.employer_email)}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fab fa-telegram"></i>
|
||||
<span>${escapeHtml(app.employer_telegram || '—')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<!-- Сопроводительное письмо -->
|
||||
${app.message ? `
|
||||
<div class="message-box">
|
||||
<strong>Сопроводительное письмо:</strong>
|
||||
<p>${escapeHtml(app.message)}</p>
|
||||
<strong>✉️ Сопроводительное письмо:</strong>
|
||||
<p style="margin-top: 10px;">${escapeHtml(app.message)}</p>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<!-- Ответ работодателя -->
|
||||
${app.response_message ? `
|
||||
<div class="response-box">
|
||||
<strong>Ответ работодателя:</strong>
|
||||
<p>${escapeHtml(app.response_message)}</p>
|
||||
<small>${new Date(app.response_at).toLocaleString()}</small>
|
||||
<strong>💬 Ответ работодателя:</strong>
|
||||
<p style="margin-top: 10px;">${escapeHtml(app.response_message)}</p>
|
||||
${responseDate ? `<small style="display: block; margin-top: 10px;">Ответ дан: ${responseDate}</small>` : ''}
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
${isEmployer && app.status === 'pending' ? `
|
||||
<!-- Информация о просмотре -->
|
||||
${viewedDate ? `
|
||||
<div style="color: #4f7092; font-size: 14px; margin-top: 20px; padding: 10px; background: #f9fcff; border-radius: 10px;">
|
||||
<i class="fas fa-eye"></i> Просмотрено: ${viewedDate}
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<!-- Кнопки для работодателя -->
|
||||
${isEmployerViewing && app.status === 'pending' ? `
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-success" onclick="updateStatus('accepted')">Принять</button>
|
||||
<button class="btn btn-danger" onclick="updateStatus('rejected')">Отклонить</button>
|
||||
<button class="btn btn-success" onclick="updateStatus('accepted')">✅ Принять</button>
|
||||
<button class="btn btn-danger" onclick="updateStatus('rejected')">❌ Отклонить</button>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
${isEmployerViewing && app.status === 'viewed' ? `
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-success" onclick="updateStatus('accepted')">✅ Принять</button>
|
||||
<button class="btn btn-danger" onclick="updateStatus('rejected')">❌ Отклонить</button>
|
||||
</div>
|
||||
` : ''}
|
||||
`;
|
||||
}
|
||||
|
||||
// Обновление статуса отклика
|
||||
async function updateStatus(status) {
|
||||
const message = prompt('Введите сообщение (необязательно):');
|
||||
const message = prompt('Введите сообщение для соискателя (необязательно):');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/applications/${applicationId}/status`, {
|
||||
@@ -335,13 +483,17 @@
|
||||
|
||||
if (response.ok) {
|
||||
alert('Статус обновлен');
|
||||
loadApplication();
|
||||
loadApplication(); // Перезагружаем страницу
|
||||
} else {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Ошибка обновления');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Ошибка');
|
||||
alert('Ошибка: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Экранирование HTML
|
||||
function escapeHtml(unsafe) {
|
||||
if (!unsafe) return '';
|
||||
return unsafe.toString()
|
||||
@@ -352,7 +504,13 @@
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
loadApplication();
|
||||
// Инициализация
|
||||
async function init() {
|
||||
await loadCurrentUser();
|
||||
await loadApplication();
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user