Files
hotel777-manager/public/client.html
2026-05-03 16:36:18 +05:00

65 lines
2.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="ru" data-title="Карточка клиента" data-description="Профиль клиента и его заявки">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header></header>
<main>
<h1>Профиль клиента</h1>
<div id="clientInfo"></div>
<h2>Заявки (сортировка: сначала новые, потом по статусу А-Я)</h2>
<table id="clientBookingsTable">
<thead>
<tr><th>ID внеш.</th><th>Имя</th><th>Даты</th><th>Статус</th><th>Комментарий</th></tr>
</thead>
<tbody></tbody>
</table>
<p><a href="clients.html">← Назад к списку</a></p>
</main>
<script src="nav.js"></script>
<script src="seo.js"></script>
<script>
fetch('/api/me').then(r => r.json()).then(data => {
if (!data.isAdmin) window.location.href = '/login.html';
});
const params = new URLSearchParams(window.location.search);
const clientId = params.get('id');
if (!clientId) {
document.body.innerHTML = '<h1>Не указан ID клиента</h1>';
throw new Error('No id');
}
async function loadClient() {
const res = await fetch(`/api/clients/${clientId}`);
if (!res.ok) {
document.getElementById('clientInfo').innerHTML = '<p>Клиент не найден</p>';
return;
}
const data = await res.json();
document.getElementById('clientInfo').innerHTML = `
<p><strong>Телефон:</strong> ${data.client.phone}</p>
<p><strong>Имя:</strong> ${data.client.name || 'не указано'}</p>
`;
const tbody = document.querySelector('#clientBookingsTable tbody');
tbody.innerHTML = '';
data.bookings.forEach(b => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${b.external_id || '-'}</td>
<td>${b.name}</td>
<td>${b.checkin_date} ${b.checkout_date}</td>
<td>${b.status}</td>
<td>${b.comments || ''}</td>
`;
tbody.appendChild(tr);
});
}
loadClient();
</script>
</body>
</html>