diff --git a/frontend/src/components/navigation/RegionSelect.tsx b/frontend/src/components/navigation/RegionSelect.tsx new file mode 100644 index 000000000..54b393d1b --- /dev/null +++ b/frontend/src/components/navigation/RegionSelect.tsx @@ -0,0 +1,141 @@ +import { useRouter } from "next/router"; +import { faCheck } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +import { Modal, ModalContent, ModalTrigger, Select, SelectItem } from "@app/components/v2"; + +enum Region { + US = "us", + EU = "eu" +} + +const regions = [ + { + value: Region.US, + label: "United States", + location: "Virginia, USA", + flag: ( + + + + + + + + + + ) + }, + { + value: Region.EU, + label: "Europe", + location: "Frankfurt, Germany", + flag: ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) + } +]; + +export const RegionSelect = () => { + const router = useRouter(); + + const handleRegionSelect = (value: Region) => { + router.push(`https://${value}.infisical.com/${router.pathname}`); + }; + + const [subdomain, domain] = window.location.host.split("."); + + // only display region select for local dev and cloud + if (!(subdomain.match(/localhost:8080/) || domain.match(/infisical/))) return null; + + // default to US if not eu + const currentRegion = subdomain === Region.EU ? regions[1] : regions[0]; + + return ( +
+ + + + + + + {regions.map(({ value, label, location, flag }) => ( +
+

+ {flag} + {value.toUpperCase()} Region +

+
    +
  • + Fastest + option if you are based in {value === Region.US ? "the" : ""} {label} +
  • +
  • + Data + storage compliance for this region +
  • +
  • + Hosted + in {location} +
  • +
+
+ ))} +
+
+
+ ); +};