import { createT, isLocale, LOCALES, type Locale } from '@barev/i18n';
import { Logo } from '@barev/ui';
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
import { CONTACTS, languageAlternates } from '../lib/seo';
import { RichText } from './rich-text';
import { FooterContacts, LegalLine } from './seo';
/** Страницы с ценами и правилами: их требуют платёжные провайдеры при проверке сайта */
export const LEGAL_PAGES = ['pricing', 'terms', 'refund', 'privacy'] as const;
export type LegalPageId = (typeof LEGAL_PAGES)[number];
/** Ссылки на цены и правила — в подвал любой страницы */
export function LegalLinks({ locale }: { locale: Locale }) {
const t = createT(locale);
return (
<>
{LEGAL_PAGES.map((p) => (
{t(`landing.footer.${p}`)}
))}
>
);
}
/** Мета страницы: заголовок и описание из .title / .intro */
export async function legalMetadata(params: Promise<{ locale: string }>, ns: LegalPageId): Promise {
const { locale } = await params;
if (!isLocale(locale)) return {};
const t = createT(locale);
const title = `${t(`${ns}.title`)} — Barev Club`;
const description = t(`${ns}.intro`);
return {
title,
description,
alternates: { canonical: `/${locale}/${ns}`, languages: languageAlternates(`/${ns}`) },
// своё превью ссылки, иначе подставляется слоган из общего layout
openGraph: { title, description, locale, type: 'article', siteName: 'Barev Club' },
twitter: { card: 'summary_large_image', title, description },
};
}
/** Каркас: логотип, языки, заголовок, подвал с реквизитами и ссылками на остальные правила */
export function LegalShell({ locale, page, children }: { locale: Locale; page: LegalPageId; children: ReactNode }) {
const t = createT(locale);
return (
{t(`${page}.title`)}
{t(`${page}.updated`)}
{t(`${page}.intro`)}
{children}
);
}
/** Текст правил: оглавление и нумерованные разделы ..title / ..body */
export function LegalDocument({ locale, ns, sections }: { locale: Locale; ns: Exclude; sections: readonly string[] }) {
const t = createT(locale);
const vars = { email: CONTACTS.email, phone: CONTACTS.phoneDisplay, tin: CONTACTS.tin };
return (
{sections.map((s) => (
-
{t(`${ns}.${s}.title`)}
))}
{sections.map((s, i) => (
{i + 1}. {t(`${ns}.${s}.title`)}
))}
);
}