({ query, removeAnimal })
| 48 | }; |
| 49 | |
| 50 | const List = ({ query, removeAnimal }) => { |
| 51 | const { data: animals } = useFirestoreCollectionData(query, { idField: 'id' }); |
| 52 | return ( |
| 53 | <> |
| 54 | <div className="h-20 overflow-x-scroll shadow-inner m-2 border border-black"> |
| 55 | <ul> |
| 56 | {(animals as Array<{ id: string; commonName: string }>).map((animal) => ( |
| 57 | <li key={animal.id}> |
| 58 | {animal.commonName} <button onClick={() => removeAnimal(animal.id)}>X</button> |
| 59 | </li> |
| 60 | ))} |
| 61 | </ul> |
| 62 | </div> |
| 63 | <ul> |
| 64 | {Array.from( |
| 65 | (animals as any[]).reduce((animalCountMap, animal) => { |
| 66 | const currentCount = animalCountMap.get(animal.commonName) ?? 0; |
| 67 | return animalCountMap.set(animal.commonName, currentCount + 1); |
| 68 | }, new Map<string, number>()) |
| 69 | ).map((animalStat) => { |
| 70 | const [animalName, animalCount] = (animalStat as [string, number]); |
| 71 | return ( |
| 72 | <li key={animalName}> |
| 73 | {animalName}: {animalCount} |
| 74 | </li> |
| 75 | ); |
| 76 | })} |
| 77 | </ul> |
| 78 | </> |
| 79 | ); |
| 80 | }; |
| 81 | |
| 82 | const FavoriteAnimals = (props) => { |
| 83 | const firestore = useFirestore(); |
nothing calls this directly
no test coverage detected