Skip to content

Commit

Permalink
afegits nous detalls del país
Browse files Browse the repository at this point in the history
  • Loading branch information
eloicasamayor committed Nov 15, 2024
1 parent 40d6ee7 commit 1ba9690
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ function App() {
type countryInfoT = {
capital: string;
languages: object;
flags: {
svg: string;
};
name: {
official: string;
};
};
const [countryInfo, setCountryInfo] = useState<countryInfoT>({
capital: "",
languages: {},
flags: {
svg: "",
},
name: {
official: "",
},
});

useEffect(() => {
Expand Down Expand Up @@ -51,17 +63,23 @@ function App() {
}
return (
<>
<p>{country}</p>
<Map />
<div>
<p>
<strong>Capital:</strong> {countryInfo?.capital}
</p>
<p>
<strong>Languages:</strong>{" "}
{Object.values(countryInfo?.languages).map((l) => l + ", ")}
</p>
</div>
{countryInfo && (
<div>
<h2>{country}</h2>
<p>
<strong>Official name:</strong> {countryInfo.name.official}
</p>
<p>
<strong>Capital:</strong> {countryInfo?.capital}
</p>
<p>
<strong>Languages:</strong>{" "}
{Object.values(countryInfo?.languages).map((l) => l + ", ")}
</p>
<img width={"100%"} src={countryInfo.flags.svg} />
</div>
)}
</>
);
}
Expand Down

0 comments on commit 1ba9690

Please sign in to comment.