landing: динамический счётчик продуктов, телефон, защита email/телефона от ботов
This commit is contained in:
@@ -40,6 +40,15 @@ export function Landing() {
|
||||
const cta = content.sections.cta as Record<string, any>;
|
||||
const settings = content.settings;
|
||||
|
||||
// Реальное количество продуктов из БД + русское склонение
|
||||
const productCount = content.products.length;
|
||||
const pluralProducts = (n: number) => {
|
||||
const m10 = n % 10, m100 = n % 100;
|
||||
if (m10 === 1 && m100 !== 11) return 'ФЛАГМАНСКИЙ ПРОДУКТ';
|
||||
if (m10 >= 2 && m10 <= 4 && !(m100 >= 12 && m100 <= 14)) return 'ФЛАГМАНСКИХ ПРОДУКТА';
|
||||
return 'ФЛАГМАНСКИХ ПРОДУКТОВ';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="bg-white text-slate-900">
|
||||
<nav className="bg-white border-b border-slate-200">
|
||||
@@ -83,12 +92,17 @@ export function Landing() {
|
||||
|
||||
{Array.isArray(hero?.stats) && hero.stats.length > 0 && (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mt-14 pt-7 border-t border-slate-200">
|
||||
{hero.stats.map((stat: any, idx: number) => (
|
||||
<div key={idx}>
|
||||
<div className="text-3xl font-medium text-brand-800 tracking-tight">{stat.value}</div>
|
||||
<div className="text-xs text-slate-500 tracking-wider mt-1">{stat.label}</div>
|
||||
</div>
|
||||
))}
|
||||
{hero.stats.map((stat: any, idx: number) => {
|
||||
const isProd = typeof stat.label === 'string' && stat.label.toUpperCase().includes('ПРОДУКТ');
|
||||
const value = isProd ? String(productCount) : stat.value;
|
||||
const label = isProd ? pluralProducts(productCount) : stat.label;
|
||||
return (
|
||||
<div key={idx}>
|
||||
<div className="text-3xl font-medium text-brand-800 tracking-tight">{value}</div>
|
||||
<div className="text-xs text-slate-500 tracking-wider mt-1">{label}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -169,10 +183,23 @@ export function Landing() {
|
||||
<h2 className="text-3xl font-medium text-brand-900 tracking-tight mb-3">{cta?.title}</h2>
|
||||
<p className="text-sm text-slate-600 max-w-md mx-auto mb-6">{cta?.description}</p>
|
||||
<div className="inline-flex gap-2 items-center flex-wrap justify-center">
|
||||
{settings.contact_phone && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => { window.location.href = 'tel:' + settings.contact_phone.replace(/[^+\d]/g, ''); }}
|
||||
className="btn-secondary"
|
||||
>
|
||||
{settings.contact_phone}
|
||||
</button>
|
||||
)}
|
||||
{settings.contact_email && (
|
||||
<a href={`mailto:${settings.contact_email}`} className="btn-secondary">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => { window.location.href = 'mailto:' + settings.contact_email; }}
|
||||
className="btn-secondary"
|
||||
>
|
||||
{settings.contact_email}
|
||||
</a>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user