Скорректировал счетчик посетителей

This commit is contained in:
Web-serfer 2026-05-01 23:12:00 +05:00
parent 95c7b64d4c
commit 18762aaaaf
10 changed files with 770 additions and 17 deletions

View file

@ -46,6 +46,13 @@ const title = 'Бесплатная консультация';
/>
</div>
<div class="consent-checkbox">
<input type="checkbox" id="consent" name="consent" required />
<label for="consent">
Я согласен на <a href="/privacy">обработку персональных данных</a> и принимаю <a href="/terms">условия использования</a>
</label>
</div>
<button type="submit" class="modal-submit">
Отправить заявку
</button>
@ -341,6 +348,38 @@ const title = 'Бесплатная консультация';
line-height: 1.4;
}
.consent-checkbox {
display: flex;
align-items: flex-start;
gap: 0.75rem;
margin-bottom: 0.5rem;
}
.consent-checkbox input[type="checkbox"] {
width: 18px;
height: 18px;
margin-top: 2px;
accent-color: #d4af37;
cursor: pointer;
flex-shrink: 0;
}
.consent-checkbox label {
font-size: 0.8rem;
color: #64748b;
line-height: 1.4;
cursor: pointer;
}
.consent-checkbox a {
color: #d4af37;
text-decoration: underline;
}
.consent-checkbox a:hover {
color: #b8962e;
}
.privacy-link {
color: #d4af37;
text-decoration: underline;

View file

@ -0,0 +1,183 @@
---
const COOKIE_KEY = 'cookie_consent';
---
<div id="cookie-banner" class="cookie-banner" role="dialog" aria-labelledby="cookie-title" aria-describedby="cookie-desc">
<div class="cookie-content">
<div class="cookie-text">
<h3 id="cookie-title">Использование файлов cookie</h3>
<p id="cookie-desc">
Мы используем файлы cookie для обеспечения работы сайта. Продолжая использовать сайт, вы соглашаетесь с
<a href="/privacy">политикой обработки персональных данных</a>.
</p>
</div>
<div class="cookie-actions">
<button id="cookie-reject" class="cookie-btn cookie-btn-secondary">
Отклонить
</button>
<button id="cookie-accept" class="cookie-btn cookie-btn-primary">
Принять
</button>
</div>
</div>
</div>
<script define:vars={{ COOKIE_KEY }}>
(function() {
const banner = document.getElementById('cookie-banner');
const acceptBtn = document.getElementById('cookie-accept');
const rejectBtn = document.getElementById('cookie-reject');
function hasConsent() {
return localStorage.getItem(COOKIE_KEY) !== null;
}
function saveConsent(accepted) {
localStorage.setItem(COOKIE_KEY, JSON.stringify({
accepted: accepted,
timestamp: new Date().toISOString()
}));
hideBanner();
}
function hideBanner() {
if (banner) {
banner.classList.remove('active');
setTimeout(() => {
banner.style.display = 'none';
}, 300);
}
}
function showBanner() {
if (banner) {
banner.style.display = 'block';
setTimeout(() => {
banner.classList.add('active');
}, 10);
}
}
acceptBtn?.addEventListener('click', () => saveConsent(true));
rejectBtn?.addEventListener('click', () => saveConsent(false));
if (!hasConsent()) {
showBanner();
}
})();
</script>
<style is:global>
.cookie-banner {
display: none;
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #ffffff;
border-top: 1px solid #e2e8f0;
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
z-index: 9998;
padding: 1.25rem 1.5rem;
transform: translateY(100%);
transition: transform 0.3s ease;
}
.cookie-banner.active {
transform: translateY(0);
}
.cookie-content {
max-width: 1200px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1.5rem;
flex-wrap: wrap;
}
.cookie-text {
flex: 1;
min-width: 280px;
}
.cookie-text h3 {
font-size: 1rem;
font-weight: 700;
color: #1e3050;
margin: 0 0 0.5rem 0;
}
.cookie-text p {
font-size: 0.85rem;
color: #64748b;
margin: 0;
line-height: 1.5;
}
.cookie-text a {
color: #d4af37;
text-decoration: underline;
}
.cookie-text a:hover {
color: #b8962e;
}
.cookie-actions {
display: flex;
gap: 0.75rem;
flex-shrink: 0;
}
.cookie-btn {
padding: 0.625rem 1.25rem;
border-radius: 8px;
font-size: 0.875rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
border: none;
}
.cookie-btn-primary {
background: linear-gradient(135deg, #d4af37 0%, #eac26e 100%);
color: #1e293b;
}
.cookie-btn-primary:hover {
box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
transform: translateY(-1px);
}
.cookie-btn-secondary {
background: #f1f5f9;
color: #64748b;
border: 1px solid #e2e8f0;
}
.cookie-btn-secondary:hover {
background: #e2e8f0;
color: #475569;
}
@media (max-width: 640px) {
.cookie-content {
flex-direction: column;
align-items: stretch;
}
.cookie-actions {
justify-content: stretch;
}
.cookie-btn {
flex: 1;
}
.cookie-text {
min-width: 100%;
}
}
</style>

View file

@ -45,6 +45,7 @@ export default function CommentForm(props: CommentFormProps) {
const [errors, setErrors] = createSignal<ValidationErrors>({});
const [touched, setTouched] = createSignal<{ [key: string]: boolean }>({});
const [showEmojiPicker, setShowEmojiPicker] = createSignal(false);
const [consent, setConsent] = createSignal(false);
const sanitizeInput = (input: string): string => {
return input
@ -124,7 +125,7 @@ export default function CommentForm(props: CommentFormProps) {
};
const isValid = () => {
return !errors().content && content().trim();
return !errors().content && content().trim() && consent();
};
return (
@ -213,6 +214,19 @@ export default function CommentForm(props: CommentFormProps) {
</div>
</div>
<div class="flex items-center gap-3 pt-2 pb-2">
<input
type="checkbox"
id="comment-consent"
checked={consent()}
onChange={(e) => setConsent(e.currentTarget.checked)}
class="w-4 h-4 accent-blue-600 cursor-pointer"
/>
<label for="comment-consent" class="text-sm text-gray-600 cursor-pointer">
Я согласен на <a href="/privacy" class="text-blue-600 hover:underline">обработку персональных данных</a>
</label>
</div>
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 pt-2">
<p class="text-sm text-gray-500">
{props.user

View file

@ -12,6 +12,7 @@ const sectionsLinks = [
const legalLinks = [
{ label: 'Политика конфиденциальности', href: '/privacy' },
{ label: 'Условия использования', href: '/terms' },
{ label: 'Согласие на обработку ПДн', href: '/consent' },
];
const otherLinks = [

View file

@ -58,6 +58,7 @@ export default function ReviewForm(props: ReviewFormProps) {
const [text, setText] = createSignal("");
const [errors, setErrors] = createSignal<ValidationErrors>({});
const [touched, setTouched] = createSignal<{ [key: string]: boolean }>({});
const [consent, setConsent] = createSignal(false);
createEffect(() => {
if (props.user?.name) {
@ -203,7 +204,7 @@ export default function ReviewForm(props: ReviewFormProps) {
return !errors().name && !errors().surname && !errors().profession &&
!errors().rating && !errors().text &&
name().trim() && surname().trim() && profession().trim() &&
rating() > 0 && text().trim();
rating() > 0 && text().trim() && consent();
};
const getFieldClass = (field: keyof ValidationErrors) => {
@ -350,15 +351,23 @@ export default function ReviewForm(props: ReviewFormProps) {
{text().length}/{MAX_TEXT_LENGTH}
</p>
</div>
<div class="moderation-notice">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span>Все отзывы проходят модерацию перед публикацией</span>
</div>
</div>
</div>
<div class="consent-section">
<label class="consent-label">
<input
type="checkbox"
checked={consent()}
onChange={(e) => setConsent(e.currentTarget.checked)}
class="consent-checkbox"
/>
<span class="consent-text">
Я согласен на <a href="/privacy">обработку персональных данных</a> и принимаю <a href="/terms">условия использования</a>
</span>
</label>
</div>
<button
type="submit"
disabled={!isValid()}
@ -614,6 +623,41 @@ export default function ReviewForm(props: ReviewFormProps) {
cursor: not-allowed;
}
.consent-section {
padding: 0.75rem 0;
}
.consent-label {
display: flex;
align-items: flex-start;
gap: 0.75rem;
cursor: pointer;
}
.consent-checkbox {
width: 18px;
height: 18px;
margin-top: 2px;
accent-color: #d4af37;
cursor: pointer;
flex-shrink: 0;
}
.consent-text {
font-size: 0.8rem;
color: #64748b;
line-height: 1.4;
}
.consent-text a {
color: #2563eb;
text-decoration: underline;
}
.consent-text a:hover {
color: #1d4ed8;
}
.privacy-note {
font-size: 0.75rem;
color: #94a3b8;