({ ids }: { ids: Array<number> })
| 17 | }) |
| 18 | |
| 19 | function Characters({ ids }: { ids: Array<number> }) { |
| 20 | const characters = useQueries({ |
| 21 | queries: ids.map((id) => charactersQueries.detail(id)), |
| 22 | }) |
| 23 | |
| 24 | return characters.map((character, index) => { |
| 25 | if (character.status === 'pending') { |
| 26 | return 'Loading...' |
| 27 | } |
| 28 | if (character.status === 'error') { |
| 29 | return 'Error...' |
| 30 | } |
| 31 | if (character.data === null) { |
| 32 | return 'Not found ...' |
| 33 | } |
| 34 | |
| 35 | return ( |
| 36 | <div key={String(index)} style={{ display: 'flex' }}> |
| 37 | <img |
| 38 | width={100} |
| 39 | height={100} |
| 40 | alt={character.data.image} |
| 41 | src={character.data.image} |
| 42 | /> |
| 43 | <div style={{ paddingLeft: 10, textAlign: 'left' }}> |
| 44 | <h5 style={{ marginTop: 0, marginBottom: 5 }}> |
| 45 | {character.data.name} (#{character.data.id}) |
| 46 | </h5> |
| 47 | <p style={{ marginTop: 0, marginBottom: 2 }}> |
| 48 | Status: {character.data.status} |
| 49 | </p> |
| 50 | <p style={{ marginTop: 0, marginBottom: 2 }}> |
| 51 | Species: {character.data.species} |
| 52 | </p> |
| 53 | <p style={{ marginTop: 0, marginBottom: 2 }}> |
| 54 | Gender: {character.data.gender} |
| 55 | </p> |
| 56 | </div> |
| 57 | </div> |
| 58 | ) |
| 59 | }) |
| 60 | } |
| 61 | |
| 62 | function App() { |
| 63 | const [ids, setIds] = useState<Array<number>>([]) |
nothing calls this directly
no test coverage detected