From 4fa5e8ae182c27a61d426a3afd03ab6a63d9247c Mon Sep 17 00:00:00 2001 From: Matthew Warman Date: Tue, 22 Oct 2024 08:39:53 -0400 Subject: [PATCH] pr fixes --- src/common/components/Error/ErrorPage.scss | 5 --- src/common/providers/ConfigProvider.tsx | 38 ++++++++++--------- .../utils/i18n/resources/en/common.json | 1 + .../utils/i18n/resources/es/common.json | 1 + .../utils/i18n/resources/fr/common.json | 1 + 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/common/components/Error/ErrorPage.scss b/src/common/components/Error/ErrorPage.scss index 615a52f..d6b7d33 100644 --- a/src/common/components/Error/ErrorPage.scss +++ b/src/common/components/Error/ErrorPage.scss @@ -9,11 +9,6 @@ align-items: center; } - &__icon { - margin-top: 4rem; - margin-bottom: 4rem; - } - &__title { margin-bottom: 2rem; } diff --git a/src/common/providers/ConfigProvider.tsx b/src/common/providers/ConfigProvider.tsx index 7276de4..b52912d 100644 --- a/src/common/providers/ConfigProvider.tsx +++ b/src/common/providers/ConfigProvider.tsx @@ -19,24 +19,6 @@ export interface Config { VITE_TOAST_AUTO_DISMISS_MILLIS: number; } -/** - * The configuration validation schema. - * @see {@link https://github.com/jquense/yup | Yup} - */ -const configSchema: ObjectSchema = object({ - VITE_BASE_URL_API: string().url().required('${path} is required.'), - VITE_BUILD_DATE: string().default('1970-01-01'), - VITE_BUILD_TIME: string().default('00:00:00'), - VITE_BUILD_TS: string().default('1970-01-01T00:00:00+0000'), - VITE_BUILD_COMMIT_SHA: string().default('local'), - VITE_BUILD_ENV_CODE: string().default('local'), - VITE_BUILD_WORKFLOW_RUNNER: string().default('local'), - VITE_BUILD_WORKFLOW_NAME: string().default('local'), - VITE_BUILD_WORKFLOW_RUN_NUMBER: number().default(1), - VITE_BUILD_WORKFLOW_RUN_ATTEMPT: number().default(-1), - VITE_TOAST_AUTO_DISMISS_MILLIS: number().default(5000), -}); - /** * The `ConfigContext` instance. */ @@ -56,6 +38,26 @@ const ConfigContextProvider = ({ children }: PropsWithChildren): JSX.Element => const [isReady, setIsReady] = useState(false); const [config, setConfig] = useState(); + /** + * The configuration validation schema. + * @see {@link https://github.com/jquense/yup | Yup} + */ + const configSchema: ObjectSchema = object({ + VITE_BASE_URL_API: string() + .url() + .required(({ path }) => t('validation.required-path', { path })), + VITE_BUILD_DATE: string().default('1970-01-01'), + VITE_BUILD_TIME: string().default('00:00:00'), + VITE_BUILD_TS: string().default('1970-01-01T00:00:00+0000'), + VITE_BUILD_COMMIT_SHA: string().default('local'), + VITE_BUILD_ENV_CODE: string().default('local'), + VITE_BUILD_WORKFLOW_RUNNER: string().default('local'), + VITE_BUILD_WORKFLOW_NAME: string().default('local'), + VITE_BUILD_WORKFLOW_RUN_NUMBER: number().default(1), + VITE_BUILD_WORKFLOW_RUN_ATTEMPT: number().default(-1), + VITE_TOAST_AUTO_DISMISS_MILLIS: number().default(5000), + }); + useEffect(() => { try { const validatedConfig = configSchema.validateSync(import.meta.env, { diff --git a/src/common/utils/i18n/resources/en/common.json b/src/common/utils/i18n/resources/en/common.json index 86ea17a..ea4612f 100644 --- a/src/common/utils/i18n/resources/en/common.json +++ b/src/common/utils/i18n/resources/en/common.json @@ -30,6 +30,7 @@ "min": "Must be at least {{min}} characters. ", "oneOf": "Must be one of: {{values}} ", "required": "Required. ", + "required-path": "{{path}} is required. ", "url": "Must be a URL. " }, "no": "no", diff --git a/src/common/utils/i18n/resources/es/common.json b/src/common/utils/i18n/resources/es/common.json index ef92083..25c8e91 100644 --- a/src/common/utils/i18n/resources/es/common.json +++ b/src/common/utils/i18n/resources/es/common.json @@ -30,6 +30,7 @@ "min": "Debe tener al menos {{min}} caracteres. ", "oneOf": "Debe ser uno de: {{values}} ", "required": "Requerido. ", + "required-path": "{{path}} es obligatorio. ", "url": "Debe ser una URL. " }, "no": "no", diff --git a/src/common/utils/i18n/resources/fr/common.json b/src/common/utils/i18n/resources/fr/common.json index 62bc820..321e583 100644 --- a/src/common/utils/i18n/resources/fr/common.json +++ b/src/common/utils/i18n/resources/fr/common.json @@ -30,6 +30,7 @@ "min": "Doit contenir au moins {{min}} caractères. ", "oneOf": "Doit être l'un des: {{values}} ", "required": "Requis. ", + "required-path": "{{path}} est obligatoire. ", "url": "Doit être une URL. " }, "no": "non",