QLFW-50: ссылки на магазины в блоке «Где купить книгу»
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 2с
peppa/test test: success за 1с
peppa/build build: success за 40с
ci / checks (pull_request) Successful in 1m14s
deploy / deploy (pull_request) Successful in 2m7s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-17 18:50:55 +05:00
parent c7d71d45f0
commit 52250be2e4
11 changed files with 55 additions and 19 deletions

View File

@ -0,0 +1 @@
Адреса — в src/lib/book-links.ts. Marwin и «Эрудит» — главные страницы (точные страницы книги не найдены), Flip — страница книги.

View File

@ -0,0 +1,10 @@
## Why
Посетитель должен дойти от карточки книги до покупки: названия магазинов в блоке «Где купить книгу» были простым текстом.
## What Changes
- Marwin, Flip.kz, «Эрудит» — ссылки; «Книжный мир» без ссылки, пока нет подтверждённого адреса.
- Блок одинаков на RU, KK, EN и показан также на странице книги.
- «Подробнее» уже ведёт на /projects/ermek-serkebayev.
## Impact
src/components/BookWhere.tsx, src/lib/book-links.ts, словари.

View File

@ -0,0 +1,3 @@
## 1. Реализация
- [x] 1.1 Ссылки на магазины и блок на странице книги
- [x] 1.2 Тесты

View File

@ -1,5 +1,6 @@
import { loadLegal } from '@/lib/content'
import { BookLink } from '@/components/BookLink'
import { BookWhere } from '@/components/BookWhere'
import Image from 'next/image'
import Link from 'next/link'
import { notFound } from 'next/navigation'
@ -38,6 +39,7 @@ export default async function BookProject({ params }: { params: Promise<{ locale
{[...t.book.paragraphs, ...t.book.additions].map(text => <p key={text} className="mt-5 leading-relaxed">{text}</p>)}
<p className="mt-6 font-medium">{t.book.organiser}</p>
<BookLink url={bookUrl} t={t.book} />
<BookWhere t={t.book} />
</div>
</article>
<section className="mt-16">

View File

@ -1,5 +1,12 @@
import React from 'react'
import type { Dict } from '@/i18n'
import { bookShopLinks } from '@/lib/book-links'
function Shop({ name }: { name: string }) {
const href = bookShopLinks[name]
if (!href) return <>{name}</>
return <a href={href} target="_blank" rel="noopener noreferrer" className="underline underline-offset-4">{name}</a>
}
export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
const buy = t.buy
@ -7,16 +14,15 @@ export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
return (
<div className="mt-8">
<h4 className="font-serif text-xl sm:text-2xl">{t.get}</h4>
{(
<>
<p className="mt-3 text-muted">{buy.intro}</p>
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
{buy.platforms.map((p) => <li key={p}>{p}</li>)}
</ul>
<p className="mt-3 text-muted">{buy.stores}</p>
<p className="mt-3 text-muted">{buy.note}</p>
</>
)}
<p className="mt-3 text-muted">{buy.intro}</p>
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
{buy.platforms.map((p) => <li key={p}><Shop name={p} /></li>)}
</ul>
<p className="mt-3 text-muted">{buy.storesIntro}</p>
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted">
{buy.stores.map((p) => <li key={p}><Shop name={p} /></li>)}
</ul>
<p className="mt-3 text-muted">{buy.note}</p>
</div>
)
}

View File

@ -10,20 +10,22 @@ const render = (l: 'ru' | 'kk' | 'en') => {
}
describe('Сценарий: где купить книгу', () => {
it('русский текст целиком, площадки списком без ссылок', () => {
it('русский текст целиком, площадки и магазины списком со ссылками', () => {
const html = render('ru')
expect(html).toContain('Где купить книгу')
expect(html).toContain('можно приобрести онлайн на платформах:')
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>')
expect(html).toContain('href="https://www.marwin.kz/"')
expect(html).toContain('href="https://www.flip.kz/catalog?prod=6364653')
expect(html).toContain('href="https://erudit.kz/"')
expect(html).toContain('Книжный мир')
expect(html).toContain('<p class="mt-3 text-muted">Наличие и стоимость книги уточняйте непосредственно у продавцов.</p>')
expect(html).not.toContain('<a')
})
it.each(['kk', 'en'] as const)('язык %s: те же магазины, без пометок', (l) => {
const html = render(l)
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>')
expect(html).toContain('href="https://www.marwin.kz/"')
expect(html).toContain('href="https://www.flip.kz/catalog?prod=6364653')
expect(html).toContain('Эрудит')
expect(html).toContain('Книжный мир')
expect(html).not.toContain(getDict(l).tbc)
expect(html).not.toContain('<a')
})
})

View File

@ -90,7 +90,8 @@ export const en: Dict = {
"buy": {
"intro": "Irina Serkebayeva’s book “Ermek Serkebayev. И жизнь, и молодость, и счастье. Новые страницы” is available online on these platforms:",
"platforms": ["Marwin", "Flip.kz"],
"stores": "It is also sold in the bookshops “Эрудит” and “Книжный мир”.",
"storesIntro": "It is also sold in the bookshops:",
"stores": ["Эрудит", "Книжный мир"],
"note": "Please check availability and price directly with the sellers."
},
"cover": "Cover",

View File

@ -90,7 +90,8 @@ export const kk: Dict = {
"buy": {
"intro": "Ирина Серкебаеваның «Ермек Серкебаев. И жизнь, и молодость, и счастье. Новые страницы» кітабын онлайн мына платформалардан сатып алуға болады:",
"platforms": ["Marwin", "Flip.kz"],
"stores": "Сондай-ақ «Эрудит» және «Книжный мир» кітап дүкендерінен.",
"storesIntro": "Сондай-ақ кітап дүкендерінен:",
"stores": ["Эрудит", "Книжный мир"],
"note": "Кітаптың бар-жоғы мен бағасын сатушылардан тікелей нақтылаңыз."
},
"cover": "Мұқаба",

View File

@ -90,7 +90,8 @@ export const ru: Dict = {
"buy": {
"intro": "Книгу Ирины Серкебаевой «Ермек Серкебаев. И жизнь, и молодость, и счастье. Новые страницы» можно приобрести онлайн на платформах:",
"platforms": ["Marwin", "Flip.kz"],
"stores": "А также в книжных магазинах «Эрудит» и «Книжный мир».",
"storesIntro": "А также в книжных магазинах:",
"stores": ["Эрудит", "Книжный мир"],
"note": "Наличие и стоимость книги уточняйте непосредственно у продавцов."
},
"cover": "Обложка",

View File

@ -13,7 +13,7 @@ export type Dict = {
mission: { title: string; text: string; missing: string }
directions: { title: string; items: { title: string; text: string }[] }
projects: { title: string; more: string }
book: { title: string; author: string; paragraphs: string[]; get: string; getNote: string; buy: { intro: string; platforms: string[]; stores: string; note: string } | null; cover: string; photo: string; role: string; organiser: string; translationReview: string; gallery: string; additions: string[] }
book: { title: string; author: string; paragraphs: string[]; get: string; getNote: string; buy: { intro: string; platforms: string[]; storesIntro: string; stores: string[]; note: string } | null; cover: string; photo: string; role: string; organiser: string; translationReview: string; gallery: string; additions: string[] }
news: { title: string; news: string; event: string }
collaboration: { title: string; text: string; write: string; instagram: string }
contacts: { title: string; description: string; lead: string; emailLabel: string }

9
src/lib/book-links.ts Normal file
View File

@ -0,0 +1,9 @@
import { bookUrl } from './home-model'
/** Адреса магазинов, где продаётся книга. Ключ — название на экране. */
export const bookShopLinks: Record<string, string | null> = {
Marwin: 'https://www.marwin.kz/',
'Flip.kz': bookUrl,
'Эрудит': 'https://erudit.kz/',
'Книжный мир': null, // адрес не подтверждён — показываем без ссылки
}