QLFW-18: ссылка на политику в согласии у форм только при полном тексте
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 3с
peppa/test test: success за 1с
peppa/build build: success за 42с
ci / checks (pull_request) Successful in 1m26s
deploy / deploy (pull_request) Successful in 2m5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-17 17:45:51 +05:00
parent 0ee0b669b5
commit 62987ce4b8
3 changed files with 12 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import { Footer } from '@/components/Footer'
import { Header } from '@/components/Header'
import { getDict, isLocale, locales } from '@/i18n'
import { loadContent, loadLegal } from '@/lib/content'
import { isLegalPublished } from '@/lib/legal-model'
import { FALLBACK_EMAIL } from '@/lib/inquiry'
export const dynamic = 'force-dynamic'
@ -30,6 +31,7 @@ export default async function ContactsPage({ params }: Props) {
if (!isLocale(locale)) notFound()
const t = getDict(locale)
const { home } = await loadContent(locale)
const legal = await loadLegal(locale)
const email = home?.contactEmail?.trim() || FALLBACK_EMAIL
return (
<>
@ -43,10 +45,10 @@ export default async function ContactsPage({ params }: Props) {
{t.contacts.emailLabel}: <a href={`mailto:${email}`} className="text-burgundy underline underline-offset-4 hover:no-underline">{email}</a>
</p>
<div className="mt-10">
<ContactForm t={t} locale={locale} email={email} />
<ContactForm t={t} locale={locale} email={email} privacyLink={isLegalPublished(legal?.privacy)} />
</div>
</main>
<Footer t={t} locale={locale} legal={await loadLegal(locale)} />
<Footer t={t} locale={locale} legal={legal} />
</>
)
}

View File

@ -1,5 +1,5 @@
import { isLegalPublished } from '@/lib/legal-model'
import { loadLegal } from '@/lib/content'
import { isLegalPublished } from '@/lib/legal-model'
import Image from 'next/image'
import { notFound } from 'next/navigation'
import { BookWhere } from '@/components/BookWhere'
@ -41,6 +41,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
const { home, news } = await loadContent(locale)
const m = buildHomeModel(home, news, t)
const email = m.collaboration.email ?? FALLBACK_EMAIL
const legal = await loadLegal(locale)
const fmt = new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' })
return (
@ -119,7 +120,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
<h2 className="font-serif text-3xl sm:text-5xl">{t.collaboration.title}</h2>
<p className="mt-8 max-w-2xl text-lg text-paper/75">{m.collaboration.text}</p>
<div className="mt-10">
<ContactForm t={t} locale={locale} email={email} dark />
<ContactForm t={t} locale={locale} email={email} dark privacyLink={isLegalPublished(legal?.privacy)} />
</div>
<a href="https://www.instagram.com/serkebayev_book/" className="mt-6 inline-flex min-h-11 items-center gap-3 underline underline-offset-4 hover:text-paper/75">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" className="h-6 w-6 shrink-0">
@ -132,7 +133,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
</div>
</section>
</main>
<Footer t={t} locale={locale} legal={await loadLegal(locale)} />
<Footer t={t} locale={locale} legal={legal} />
</>
)
}

View File

@ -6,7 +6,7 @@ import { submitInquiry, type InquiryState } from '@/app/actions/inquiry'
import type { Dict, Locale } from '@/i18n'
/** Форма обращения. dark — на тёмном фоне блока «Сотрудничество». Тексты — из словаря, ошибки по полям. */
export function ContactForm({ t, locale, email, dark = false }: { t: Dict; locale: Locale; email: string; dark?: boolean }) {
export function ContactForm({ t, locale, email, dark = false, privacyLink = false }: { t: Dict; locale: Locale; email: string; dark?: boolean; privacyLink?: boolean }) {
const [state, action, pending] = useActionState<InquiryState, FormData>(submitInquiry, { status: 'idle' })
const openedAt = useRef(0)
const errors = state.status === 'error' ? state.errors : []
@ -55,7 +55,9 @@ export function ContactForm({ t, locale, email, dark = false }: { t: Dict; local
<input name="consent" type="checkbox" required className="mt-1 h-4 w-4 shrink-0 accent-[#7a1f2b]" {...bad('consent')} />
<span>
{f.consent}
<Link href={`/${locale}/privacy`} className="underline underline-offset-4 hover:no-underline">{t.legal.consentLink}</Link>
{privacyLink
? <Link href={`/${locale}/privacy`} className="underline underline-offset-4 hover:no-underline">{t.legal.consentLink}</Link>
: t.legal.consentLink}
{t.legal.consentAfter}
</span>
</label>