better approach to documents indicator
- SHA
cc2b939d847b4f0d0504cee743f806d584eea1aa- Parents
-
62cb8d8 - Tree
a95dfe0
cc2b939
cc2b939d847b4f0d0504cee743f806d584eea1aa62cb8d8
a95dfe0| Status | File | + | - |
|---|---|---|---|
| M |
app/memorial/conflict/[id]/page.tsx
|
2 | 2 |
| M |
app/memorial/page.tsx
|
2 | 10 |
| M |
app/memorial/search/page.tsx
|
2 | 2 |
| M |
lib/api.ts
|
2 | 2 |
app/memorial/conflict/[id]/page.tsxmodified@@ -3,7 +3,7 @@ | |||
| 3 | import { useState, useEffect } from 'react'; | 3 | import { useState, useEffect } from 'react'; |
| 4 | import Link from 'next/link'; | 4 | import Link from 'next/link'; |
| 5 | import { useParams } from 'next/navigation'; | 5 | import { useParams } from 'next/navigation'; |
| 6 | -import { getConflicts, getPeopleByConflict, Conflict, Person } from '@/lib/api'; | 6 | +import { getConflicts, getPeopleByConflict, Conflict, PersonDetail } from '@/lib/api'; |
| 7 | import Header from '@/components/Header'; | 7 | import Header from '@/components/Header'; |
| 8 | import DocumentIcon from '@/components/DocumentIcon'; | 8 | import DocumentIcon from '@/components/DocumentIcon'; |
| 9 | 9 | ||
@@ -12,7 +12,7 @@ export default function ConflictPage() { | |||
| 12 | const conflictId = parseInt(params.id as string); | 12 | const conflictId = parseInt(params.id as string); |
| 13 | 13 | ||
| 14 | const [conflict, setConflict] = useState<Conflict | null>(null); | 14 | const [conflict, setConflict] = useState<Conflict | null>(null); |
| 15 | - const [people, setPeople] = useState<Person[]>([]); | 15 | + const [people, setPeople] = useState<PersonDetail[]>([]); |
| 16 | const [loading, setLoading] = useState(true); | 16 | const [loading, setLoading] = useState(true); |
| 17 | const [error, setError] = useState<string | null>(null); | 17 | const [error, setError] = useState<string | null>(null); |
| 18 | 18 | ||
app/memorial/page.tsxmodified@@ -4,15 +4,7 @@ import { useState, useEffect } from 'react'; | |||
| 4 | import Link from 'next/link'; | 4 | import Link from 'next/link'; |
| 5 | import Header from '@/components/Header'; | 5 | import Header from '@/components/Header'; |
| 6 | import DocumentIcon from '@/components/DocumentIcon'; | 6 | import DocumentIcon from '@/components/DocumentIcon'; |
| 7 | - | 7 | +import { PersonDetail } from '@/lib/api'; |
| 8 | -interface Person { | ||
| 9 | - id: number; | ||
| 10 | - display_name: string; | ||
| 11 | - rank: string; | ||
| 12 | - unit: string; | ||
| 13 | - death_description?: string; | ||
| 14 | - pdf_key?: string; | ||
| 15 | -} | ||
| 16 | 8 | ||
| 17 | interface ConflictWithCasualties { | 9 | interface ConflictWithCasualties { |
| 18 | id: number; | 10 | id: number; |
@@ -21,7 +13,7 @@ interface ConflictWithCasualties { | |||
| 21 | end_year: number | null; | 13 | end_year: number | null; |
| 22 | description: string; | 14 | description: string; |
| 23 | casualty_count: number; | 15 | casualty_count: number; |
| 24 | - casualties: Person[]; | 16 | + casualties: PersonDetail[]; |
| 25 | } | 17 | } |
| 26 | 18 | ||
| 27 | export default function MemorialIndexPage() { | 19 | export default function MemorialIndexPage() { |
app/memorial/search/page.tsxmodified@@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | import { useState, useEffect } from 'react'; | 3 | import { useState, useEffect } from 'react'; |
| 4 | import Link from 'next/link'; | 4 | import Link from 'next/link'; |
| 5 | -import { searchPeople, getSearchFilters, PersonSearchResult, SearchFilters } from '@/lib/api'; | 5 | +import { searchPeople, getSearchFilters, PersonDetail, SearchFilters } from '@/lib/api'; |
| 6 | import Header from '@/components/Header'; | 6 | import Header from '@/components/Header'; |
| 7 | import DocumentIcon from '@/components/DocumentIcon'; | 7 | import DocumentIcon from '@/components/DocumentIcon'; |
| 8 | 8 | ||
@@ -16,7 +16,7 @@ export default function MemorialSearchPage() { | |||
| 16 | const [noDate, setNoDate] = useState(false); | 16 | const [noDate, setNoDate] = useState(false); |
| 17 | 17 | ||
| 18 | // Results state | 18 | // Results state |
| 19 | - const [results, setResults] = useState<PersonSearchResult[]>([]); | 19 | + const [results, setResults] = useState<PersonDetail[]>([]); |
| 20 | const [totalCount, setTotalCount] = useState(0); | 20 | const [totalCount, setTotalCount] = useState(0); |
| 21 | const [loading, setLoading] = useState(false); | 21 | const [loading, setLoading] = useState(false); |
| 22 | const [hasSearched, setHasSearched] = useState(false); | 22 | const [hasSearched, setHasSearched] = useState(false); |
lib/api.tsmodified@@ -139,7 +139,7 @@ export async function getConflicts(): Promise<Conflict[]> { | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | // Fetch people by conflict | 141 | // Fetch people by conflict |
| 142 | -export async function getPeopleByConflict(conflictId: number): Promise<Person[]> { | 142 | +export async function getPeopleByConflict(conflictId: number): Promise<PersonDetail[]> { |
| 143 | const response = await fetch(`${API_BASE_URL}/memorial/persons/?conflict=${conflictId}`); | 143 | const response = await fetch(`${API_BASE_URL}/memorial/persons/?conflict=${conflictId}`); |
| 144 | if (!response.ok) { | 144 | if (!response.ok) { |
| 145 | throw new Error('Failed to fetch people'); | 145 | throw new Error('Failed to fetch people'); |
@@ -167,7 +167,7 @@ export async function getMemorialIndex(): Promise<Conflict[]> { | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | // Search people with filters | 169 | // Search people with filters |
| 170 | -export async function searchPeople(params: SearchParams): Promise<{ count: number; results: PersonSearchResult[] }> { | 170 | +export async function searchPeople(params: SearchParams): Promise<{ count: number; results: PersonDetail[] }> { |
| 171 | const queryParams = new URLSearchParams(); | 171 | const queryParams = new URLSearchParams(); |
| 172 | 172 | ||
| 173 | if (params.q) queryParams.append('q', params.q); | 173 | if (params.q) queryParams.append('q', params.q); |