From f097d7761da99ed88e90fcfde72a6397fbc55614 Mon Sep 17 00:00:00 2001 From: Ahmed Al-Taiar Date: Thu, 24 Oct 2024 20:06:09 -0400 Subject: [PATCH] [#1] Clearer location --- .env.defaults | 2 ++ .env.example | 2 ++ Dockerfile | 6 ++++++ README.md | 2 ++ api/package.json | 2 +- api/src/server.ts | 4 ++-- docker-compose.yml | 2 ++ redwood.toml | 2 +- web/package.json | 2 +- web/src/entry.client.tsx | 4 ++-- web/src/pages/HomePage/HomePage.tsx | 20 +++++++++++++------- yarn.lock | 12 ++++++------ 12 files changed, 40 insertions(+), 20 deletions(-) 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 = () => (
-
+
+

+ 📍{' '} + {[ + process.env.CITY, + process.env.STATE, + getCountryData(process.env.COUNTRY as TCountryCode).name, + ] + .filter((s) => s && s !== '') + .join(', ')} +

( {getLogoComponent('gitea')}
-
-

- {getUnicodeFlagIcon(process.env.COUNTRY)} -

-
) diff --git a/yarn.lock b/yarn.lock index 303e833..0cc916d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7336,7 +7336,7 @@ __metadata: "@tus/file-store": "npm:^1.4.0" "@tus/server": "npm:^1.7.0" "@types/nodemailer": "npm:^6.4.15" - country-flag-icons: "npm:^1.5.13" + countries-list: "npm:^3.1.1" graphql-scalars: "npm:^1.23.0" nodemailer: "npm:^6.9.14" languageName: unknown @@ -9062,10 +9062,10 @@ __metadata: languageName: node linkType: hard -"country-flag-icons@npm:^1.5.13": - version: 1.5.13 - resolution: "country-flag-icons@npm:1.5.13" - checksum: 10c0/beee2fe225469507d6c8df90376e031f08a5f103f65cd68e1db0679e82d4ffb2fbb27a3bb19defd112745b5c19d1972df615df21813c8c2074062dd5eb08eabb +"countries-list@npm:^3.1.1": + version: 3.1.1 + resolution: "countries-list@npm:3.1.1" + checksum: 10c0/26734d5927ee9dafa30e4da214b6ab7ecf7cdd93516e5bb077d6fdb1f9f37b4fd8698987b0062c1f3b0c95d18fe947f941ef0ab8c3cc486ef33f1c3dca2678b7 languageName: node linkType: hard @@ -19242,7 +19242,7 @@ __metadata: "@uppy/tus": "npm:^4.0.0" "@uppy/webcam": "npm:^4.0.1" autoprefixer: "npm:^10.4.20" - country-flag-icons: "npm:^1.5.13" + countries-list: "npm:^3.1.1" daisyui: "npm:^4.12.10" date-fns: "npm:^4.1.0" humanize-string: "npm:2.1.0"