diff --git a/.env.defaults b/.env.defaults index c1639a6..3bc93fc 100644 --- a/.env.defaults +++ b/.env.defaults @@ -21,6 +21,8 @@ LAST_NAME=lastname DEFAULT_THEME=light COUNTRY=US +STATE=New York +CITY=Manhattan SMTP_HOST=smtp.example.com SMTP_PORT=465 diff --git a/.env.example b/.env.example index 3c6d04a..fb677e8 100644 --- a/.env.example +++ b/.env.example @@ -9,6 +9,8 @@ LAST_NAME=lastname DEFAULT_THEME=light COUNTRY=US +STATE=New York +CITY=Manhattan SMTP_HOST=smtp.example.com SMTP_PORT=465 diff --git a/Dockerfile b/Dockerfile index 89b0bfc..e7879a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,9 @@ FROM api_build as web_build_with_prerender ARG FIRST_NAME ARG LAST_NAME +ARG COUNTRY +ARG STATE +ARG CITY ARG DEFAULT_THEME ARG API_ADDRESS_PROD ARG API_ADDRESS_DEV @@ -75,6 +78,9 @@ FROM base as web_build ARG FIRST_NAME ARG LAST_NAME +ARG COUNTRY +ARG STATE +ARG CITY ARG DEFAULT_THEME ARG API_ADDRESS_PROD ARG API_ADDRESS_DEV diff --git a/README.md b/README.md index 26db47b..3eb8579 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ services: - FIRST_NAME=first name # Your first name - LAST_NAME=lastname # Your last name - COUNTRY=US # ISO-3166-1 alpha-2 country code, https://en.wikipedia.org/wiki/ISO_3166-1#Codes + - STATE=New York # Optional, state or province + - CITY=Manhattan # Optional - DEFAULT_THEME=light # 'light' or 'dark' - SMTP_HOST=smtp.example.com - SMTP_PORT=465 diff --git a/api/package.json b/api/package.json index 70ff74b..02c0e84 100644 --- a/api/package.json +++ b/api/package.json @@ -11,7 +11,7 @@ "@redwoodjs/graphql-server": "8.4.0", "@tus/file-store": "^1.4.0", "@tus/server": "^1.7.0", - "country-flag-icons": "^1.5.13", + "countries-list": "^3.1.1", "graphql-scalars": "^1.23.0", "nodemailer": "^6.9.14" }, diff --git a/api/src/server.ts b/api/src/server.ts index 28d26be..e32f66a 100644 --- a/api/src/server.ts +++ b/api/src/server.ts @@ -16,9 +16,9 @@ enum Theme { } ;(async () => { - const { hasFlag } = await import('country-flag-icons') + const { countries } = await import('countries-list') - if (!hasFlag(process.env.COUNTRY)) + if (!Object.keys(countries).includes(process.env.COUNTRY)) throw new Error( 'Invalid COUNTRY environment variable, please select a valid ISO-3166-1 alpha-2 country code\n See https://en.wikipedia.org/wiki/ISO_3166-1#Codes' ) diff --git a/docker-compose.yml b/docker-compose.yml index 78e6f60..4fd6000 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,8 @@ services: - FIRST_NAME=first name # Your first name - LAST_NAME=lastname # Your last name - COUNTRY=US # ISO-3166-1 alpha-2 country code, https://en.wikipedia.org/wiki/ISO_3166-1#Codes + - STATE=New York # Optional, state or province + - CITY=Manhattan # Optional - DEFAULT_THEME=light # 'light' or 'dark' - SMTP_HOST=smtp.example.com - SMTP_PORT=465 diff --git a/redwood.toml b/redwood.toml index 71797b3..d20a76d 100644 --- a/redwood.toml +++ b/redwood.toml @@ -9,7 +9,7 @@ title = "${FIRST_NAME} ${LAST_NAME}" port = 8910 apiUrl = "/api" - includeEnvironmentVariables = ["FIRST_NAME", "LAST_NAME", "COUNTRY", "DEFAULT_THEME", "API_ADDRESS_PROD", "API_ADDRESS_DEV"] + includeEnvironmentVariables = ["FIRST_NAME", "LAST_NAME", "COUNTRY", "STATE", "CITY", "DEFAULT_THEME", "API_ADDRESS_PROD", "API_ADDRESS_DEV"] [generate] tests = false stories = false diff --git a/web/package.json b/web/package.json index eba721e..f2b11e0 100644 --- a/web/package.json +++ b/web/package.json @@ -35,7 +35,7 @@ "@uppy/react": "^4.0.1", "@uppy/tus": "^4.0.0", "@uppy/webcam": "^4.0.1", - "country-flag-icons": "^1.5.13", + "countries-list": "^3.1.1", "date-fns": "^4.1.0", "humanize-string": "2.1.0", "react": "18.3.1", diff --git a/web/src/entry.client.tsx b/web/src/entry.client.tsx index 05fc8d2..af48e72 100644 --- a/web/src/entry.client.tsx +++ b/web/src/entry.client.tsx @@ -1,4 +1,4 @@ -import { hasFlag } from 'country-flag-icons' +import { countries } from 'countries-list' import { hydrateRoot, createRoot } from 'react-dom/client' import App from 'src/App' @@ -21,7 +21,7 @@ if (!redwoodAppElement) "exists in your 'web/src/index.html' file." ) -if (!hasFlag(process.env.COUNTRY)) +if (!Object.keys(countries).includes(process.env.COUNTRY)) throw new Error( 'Invalid COUNTRY environment variable, please select a valid ISO-3166-1 alpha-2 country code\n See https://en.wikipedia.org/wiki/ISO_3166-1#Codes' ) diff --git a/web/src/pages/HomePage/HomePage.tsx b/web/src/pages/HomePage/HomePage.tsx index 55aee25..5a80b0b 100644 --- a/web/src/pages/HomePage/HomePage.tsx +++ b/web/src/pages/HomePage/HomePage.tsx @@ -1,6 +1,7 @@ import { mdiCompass, mdiContacts } from '@mdi/js' import Icon from '@mdi/react' -import getUnicodeFlagIcon from 'country-flag-icons/unicode' +import type { TCountryCode } from 'countries-list' +import { getCountryData } from 'countries-list' import { Link, routes } from '@redwoodjs/router' import { Metadata } from '@redwoodjs/web' @@ -22,8 +23,18 @@ const HomePage = () => (
- {getUnicodeFlagIcon(process.env.COUNTRY)} -
-