gendesign/tradein-mvp/frontend/src/components/trade-in/TestPresets.tsx
lekss361 33c4c84467
All checks were successful
Deploy Trade-In / changes (push) Successful in 5s
Deploy Trade-In / build-backend (push) Successful in 44s
Deploy Trade-In / build-frontend (push) Successful in 1m53s
Deploy Trade-In / deploy (push) Successful in 44s
feat(tradein): этаж/этажность optional + best test presets по deal count (#558)
2026-05-24 21:44:44 +00:00

185 lines
5.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
/**
* TestPresets — кнопки быстрого заполнения формы тестовыми квартирами.
* Все эти квартиры дают medium / high confidence (хорошее покрытие в DB).
*/
import type { TradeInEstimateInput } from "@/types/trade-in";
interface Preset {
label: string;
hint: string;
data: TradeInEstimateInput;
}
const PRESETS: Preset[] = [
{
label: "Академика Ландау · 1к/38м²",
hint: "Академический новостройки · 686 сделок/год",
data: {
address: "Екатеринбург, ул. Академика Ландау, 27",
area_m2: 38,
rooms: 1,
floor: 12,
total_floors: 25,
year_built: 2015,
house_type: "monolith",
},
},
{
label: "Малышева 84 · 2к/55м²",
hint: "Центр · 36 аналогов",
data: {
address: "Екатеринбург, ул. Малышева, 84",
area_m2: 55,
rooms: 2,
floor: 4,
total_floors: 9,
year_built: 1990,
house_type: "brick",
},
},
{
label: "Краснолесья · 3к/75м²",
hint: "Академический эконом · 487 сделок/год",
data: {
address: "Екатеринбург, ул. Краснолесья, 30",
area_m2: 75,
rooms: 3,
floor: 7,
total_floors: 16,
year_built: 2010,
house_type: "panel",
},
},
{
label: "Космонавтов 50 · 2к/55м²",
hint: "Уралмаш бюджет · 415 сделок/год",
data: {
address: "Екатеринбург, ул. Космонавтов, 50",
area_m2: 55,
rooms: 2,
floor: 5,
total_floors: 9,
year_built: 1975,
house_type: "panel",
},
},
{
label: "8 Марта 80 · 1к/35м²",
hint: "Центр Ленинский · 305 сделок/год",
data: {
address: "Екатеринбург, ул. 8 Марта, 80",
area_m2: 35,
rooms: 1,
floor: 3,
total_floors: 9,
year_built: 1985,
house_type: "brick",
},
},
{
label: "Московская · 2к/55м²",
hint: "Центр премиум · 426 сделок/год",
data: {
address: "Екатеринбург, ул. Московская, 195",
area_m2: 55,
rooms: 2,
floor: 6,
total_floors: 9,
year_built: 1980,
house_type: "brick",
},
},
];
interface Props {
onPick: (data: TradeInEstimateInput) => void;
}
export function TestPresets({ onPick }: Props) {
return (
<div className="test-presets">
<div className="test-presets-label">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
</svg>
<span>Тестовые квартиры</span>
<span className="hint">кликни заполнится форма</span>
</div>
<div className="test-presets-grid">
{PRESETS.map((p, i) => (
<button
key={i}
type="button"
className="preset-chip"
onClick={() => onPick(p.data)}
>
<span className="preset-label">{p.label}</span>
<span className="preset-hint">{p.hint}</span>
</button>
))}
</div>
<style>{`
.test-presets {
margin-top: 16px;
padding: 12px 14px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: var(--radius);
}
.test-presets-label {
display: flex;
align-items: center;
gap: 8px;
font-size: 11px;
color: var(--fg-2);
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
margin-bottom: 10px;
}
.test-presets-label svg { color: var(--accent-2); }
.test-presets-label .hint {
font-weight: 400;
color: var(--muted-2);
text-transform: none;
letter-spacing: 0;
font-size: 11px;
margin-left: auto;
}
.test-presets-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 8px;
}
.preset-chip {
display: flex;
flex-direction: column;
gap: 2px;
padding: 8px 10px;
background: var(--surface);
border: 1px solid var(--border-2);
border-radius: var(--radius-sm);
cursor: pointer;
text-align: left;
font: 500 12px var(--font-sans);
color: var(--fg);
transition: border-color .12s, background .12s;
}
.preset-chip:hover {
border-color: var(--accent);
background: var(--accent-soft);
}
.preset-label {
font-weight: 600;
color: var(--fg);
}
.preset-hint {
font-size: 11px;
color: var(--muted);
}
`}</style>
</div>
);
}