feat: show catch method on spot detail
This commit is contained in:
@@ -270,6 +270,10 @@ def test_spot_detail_and_catches() -> None:
|
||||
assert len(catches.json()) == 3
|
||||
assert catches.json()[0]["source_system"] == "manual-import"
|
||||
assert catches.json()[0]["fishing_method"] == "spinning"
|
||||
fixture = client.get("/api/v1/spots/resolve?waterbody=test-lake&x=10&y=20")
|
||||
assert fixture.status_code == 200
|
||||
fixture_catches = client.get(f"/api/v1/spots/{fixture.json()['id']}/catches")
|
||||
assert fixture_catches.json()[0]["fishing_method"] == "spinning"
|
||||
resolved = client.get("/api/v1/spots/resolve?waterbody=test-lake&x=10&y=20")
|
||||
assert resolved.status_code == 200
|
||||
assert resolved.json()["id"] == spot_id
|
||||
|
||||
@@ -3,12 +3,13 @@ import SourceBadge from "./SourceBadge.astro";
|
||||
import { ago, kg, type Catch } from "../lib/api";
|
||||
import TackleGlyph from "./TackleGlyph.astro";
|
||||
const { catches } = Astro.props as { catches: Catch[] };
|
||||
const methodLabels: Record<string, string> = { spinning: "Спиннинг", bottom: "Донная", float: "Поплавочная" };
|
||||
---
|
||||
<div class="catch-list">
|
||||
{catches.map(item => {
|
||||
const timestamp = item.caught_at ?? item.reported_at;
|
||||
return <article>
|
||||
<div><strong>{item.fish}</strong><span class="tackle-label"><TackleGlyph name={item.bait} size={24}/><span>{item.bait ?? "Приманка не указана"}</span></span><SourceBadge source={item.source_system} href={item.source_url}/></div>
|
||||
<div><strong>{item.fish}</strong><span class="tackle-label"><TackleGlyph name={item.bait} size={24}/><span>{item.bait ?? "Приманка не указана"}</span></span>{item.fishing_method && <span>Метод: {methodLabels[item.fishing_method] ?? item.fishing_method}</span>}{item.retrieve_method && <span>Проводка: {item.retrieve_method}{item.retrieve_speed != null ? ` · скорость ${item.retrieve_speed}` : ""}</span>}<SourceBadge source={item.source_system} href={item.source_url}/></div>
|
||||
<div><strong>{kg(item.weight_g)}</strong><span>{item.player_name ?? "Анонимно"}</span><span>{item.caught_at ? "Время улова" : "Получено · время улова неизвестно"}</span><time datetime={timestamp}>{ago(timestamp)} · {new Date(timestamp).toLocaleString("ru-RU", { timeZone: "UTC" })} UTC</time></div>
|
||||
</article>;
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user