Skip to content

Commit

Permalink
refactor to import existing countries object
Browse files Browse the repository at this point in the history
  • Loading branch information
tawandamoyo committed Sep 3, 2024
1 parent e4f449a commit 4f3424b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/pages/TermsAndConditions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import { Helmet } from "react-helmet";
import Header from "../layout/Header";
import Footer from "../layout/Footer";
import useCountryId from "../hooks/useCountryId";
import { COUNTRY_NAMES } from "../data/countries";

export default function TACPage() {
const mobile = useMobile();

const countries = {
ca: "Canada",
uk: "the United Kingdom",
us: "the United States",
};
const countryId = useCountryId();
const country = countries[countryId] || "the United States";
const DEFAULT_COUNTRY = "the United Kingdom";

const getCountryName = (id) => {
const country = COUNTRY_NAMES[id];

if (country) {
return country.phrasal || country.standard;
}
return DEFAULT_COUNTRY;
};

const countryName = getCountryName(countryId);

return (
<>
Expand Down Expand Up @@ -97,7 +104,7 @@ export default function TACPage() {
<h4>Governing Law</h4>
<p>
9.1 These Terms shall be governed by and construed in accordance with
the laws of {country}.
the laws of {countryName}.
</p>
<h4>Changes to the Terms</h4>
<p>
Expand Down

0 comments on commit 4f3424b

Please sign in to comment.