QLFW-44: ссылки на Flip.kz и Marwin в «Где купить книгу»

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-17 18:35:22 +05:00
parent 7b4de503b5
commit 92b48a7e8a
5 changed files with 30 additions and 15 deletions

View File

@ -0,0 +1,4 @@
## Why
Marwin и Flip.kz в «Где купить книгу» были просто словами.
## What
Flip.kz — ссылка (новая вкладка) на страницу книги на всех языках. Адреса Marwin в проекте нет: `marwinUrl` в home-model пуст, пока пуст — показывается просто название. Фраза про наличие и стоимость не менялась.

View File

@ -0,0 +1 @@
- [x] ссылки, тест

View File

@ -1,5 +1,8 @@
import React from 'react' import React from 'react'
import type { Dict } from '@/i18n' import type { Dict } from '@/i18n'
import { bookUrl, marwinUrl } from '@/lib/home-model'
const storeUrls: Record<string, string> = { Marwin: marwinUrl, 'Flip.kz': bookUrl }
export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) { export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
const buy = t.buy const buy = t.buy
@ -7,16 +10,19 @@ export function BookWhere({ t }: { t: Dict['book']; tbc?: string }) {
return ( return (
<div className="mt-8"> <div className="mt-8">
<h4 className="font-serif text-xl sm:text-2xl">{t.get}</h4> <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">
<p className="mt-3 text-muted">{buy.intro}</p> {buy.platforms.map((p) => {
<ul className="mt-3 list-disc space-y-1 pl-6 text-muted"> const href = storeUrls[p]
{buy.platforms.map((p) => <li key={p}>{p}</li>)} return (
</ul> <li key={p}>
<p className="mt-3 text-muted">{buy.stores}</p> {href ? <a href={href} target="_blank" rel="noopener noreferrer" className="underline">{p}</a> : p}
<p className="mt-3 text-muted">{buy.note}</p> </li>
</> )
)} })}
</ul>
<p className="mt-3 text-muted">{buy.stores}</p>
<p className="mt-3 text-muted">{buy.note}</p>
</div> </div>
) )
} }

View File

@ -2,6 +2,7 @@ import { createElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server' import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest' import { describe, expect, it } from 'vitest'
import { getDict } from '@/i18n' import { getDict } from '@/i18n'
import { bookUrl } from '@/lib/home-model'
import { BookWhere } from './BookWhere' import { BookWhere } from './BookWhere'
const render = (l: 'ru' | 'kk' | 'en') => { const render = (l: 'ru' | 'kk' | 'en') => {
@ -10,20 +11,21 @@ const render = (l: 'ru' | 'kk' | 'en') => {
} }
describe('Сценарий: где купить книгу', () => { describe('Сценарий: где купить книгу', () => {
it('русский текст целиком, площадки списком без ссылок', () => { it('русский текст целиком, Flip.kz — ссылка в новой вкладке, Marwin без адреса — просто текст', () => {
const html = render('ru') const html = render('ru')
expect(html).toContain('Где купить книгу') expect(html).toContain('Где купить книгу')
expect(html).toContain('можно приобрести онлайн на платформах:') expect(html).toContain('можно приобрести онлайн на платформах:')
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>') expect(html).toContain('<li>Marwin</li>')
expect(html).toContain(`<a href="${bookUrl.replace(/&/g, '&amp;')}" target="_blank" rel="noopener noreferrer" class="underline">Flip.kz</a>`)
expect(html).toContain('<p class="mt-3 text-muted">Наличие и стоимость книги уточняйте непосредственно у продавцов.</p>') expect(html).toContain('<p class="mt-3 text-muted">Наличие и стоимость книги уточняйте непосредственно у продавцов.</p>')
expect(html).not.toContain('<a')
}) })
it.each(['kk', 'en'] as const)('язык %s: те же магазины, без пометок', (l) => { it.each(['kk', 'en'] as const)('язык %s: те же магазины, без пометок', (l) => {
const html = render(l) const html = render(l)
expect(html).toContain('<li>Marwin</li><li>Flip.kz</li>') expect(html).toContain('<li>Marwin</li>')
expect(html).toContain('target="_blank"')
expect(html).toContain('>Flip.kz</a>')
expect(html).toContain('Эрудит') expect(html).toContain('Эрудит')
expect(html).toContain('Книжный мир') expect(html).toContain('Книжный мир')
expect(html).not.toContain(getDict(l).tbc) expect(html).not.toContain(getDict(l).tbc)
expect(html).not.toContain('<a')
}) })
}) })

View File

@ -21,6 +21,8 @@ export type HomeModel = {
} }
export const foundationEmail = 'qazaqlegacy@gmail.com' export const foundationEmail = 'qazaqlegacy@gmail.com'
// Адрес книги на Marwin; пока пусто — ссылка не показывается.
export const marwinUrl = ''
export const bookUrl = 'https://www.flip.kz/catalog?prod=6364653&utm_source=ig&utm_medium=social&utm_content=link_in_bio' export const bookUrl = 'https://www.flip.kz/catalog?prod=6364653&utm_source=ig&utm_medium=social&utm_content=link_in_bio'
const clean = (v?: string | null) => (v && v.trim() ? v.trim() : null) const clean = (v?: string | null) => (v && v.trim() ? v.trim() : null)