<commit_before>import React from "react";
import Head from "next/head";
import Shop from "../../layouts/Shop";
import { sizesInInches, sizesInCm } from "../../lib/sizes";
import SizeChart from "../../components/shop/SizeChart";

export async function getStaticProps() {
  return { props: { post: { color: "purple" } } };
}

class Sizes extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      isInches: false
    };
  }

  componentDidMount() {
    document.documentElement.style.setProperty("--cart-visibility", "block");
    this.fetchPPP();
  }

  componentWillUnmount() {
    document.documentElement.style.setProperty("--cart-visibility", "none");
  }

  async fetchPPP() {
    const pppReq = await fetch("https://ppp.dracula.workers.dev");
    const ppp = await pppReq.json();

    let country = ppp.country;

    if (country === "CA" || country === "GB" || country === "US") {
      this.setState({ isInches: true });
    }
  }

  onClickUnit(index) {<commit_msg>Detect country on the server side instead of client side<commit_after>import React from "react";
import Head from "next/head";
import Shop from "../../layouts/Shop";
import { sizesInInches, sizesInCm } from "../../lib/sizes";
import SizeChart from "../../components/shop/SizeChart";

export async function getServerSideProps({ req }) {
  const country = req.headers['x-vercel-ip-country'];

  let isInches = false;

  if (country === "CA" || country === "GB" || country === "US") {
    isInches = true;
  }

  return {
    props: { post: { color: "purple", isInches } }
  }
}

class Sizes extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      isInches: props.isInches
    };
  }

  componentDidMount() {
    document.documentElement.style.setProperty("--cart-visibility", "block");
  }

  componentWillUnmount() {
    document.documentElement.style.setProperty("--cart-visibility", "none");
  }

  onClickUnit(index) {
{'fraction_non_alphanumeric': 0.1660723382577687, 'fraction_numerical': 0.0, 'mean_word_length': 3.374164810690423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3470919', 'n_tokens_mistral': 623, 'n_tokens_neox': 612, 'n_words': 142}