diff --git a/.github/workflows/testing-client.yml b/.github/workflows/testing-client.yml index 7835cbff7..908494476 100644 --- a/.github/workflows/testing-client.yml +++ b/.github/workflows/testing-client.yml @@ -16,6 +16,7 @@ jobs: name: Running client tests runs-on: ubuntu-22.04 timeout-minutes: 30 + if: ${{ github.ref_name != 'test' }} strategy: fail-fast: false defaults: diff --git a/client/next.config.js b/client/next.config.js index b81579bc7..5bd3cb256 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -15,30 +15,46 @@ const nextConfig = { reactStrictMode: false, redirects() { return [ - { - source: '/', - destination: '/analysis/map', - permanent: false, - }, - { - source: '/analysis', - destination: '/analysis/map', - permanent: false, - }, { source: '/auth/signup', destination: '/auth/signin', permanent: false, }, - ...(!env.NEXT_PUBLIC_ENABLE_EUDR + ...(env.NEXT_PUBLIC_ENABLE_EUDR ? [ + { + source: '/', + destination: '/eudr', + permanent: false, + }, + { + source: '/analysis', + destination: '/eudr', + permanent: false, + }, + { + source: '/analysis/map', + destination: '/eudr', + permanent: false, + }, + ] + : [ + { + source: '/', + destination: '/analysis/map', + permanent: false, + }, + { + source: '/analysis', + destination: '/analysis/map', + permanent: false, + }, { source: '/eudr', destination: '/analysis/map', permanent: false, }, - ] - : []), + ]), ]; }, }; diff --git a/client/src/env.mjs b/client/src/env.mjs index ed18b700c..faa340cb7 100644 --- a/client/src/env.mjs +++ b/client/src/env.mjs @@ -1,6 +1,8 @@ import { createEnv } from '@t3-oss/env-nextjs'; import { z } from 'zod'; +const castToBoolean = z.preprocess((/** @type {string} */ val) => val === 'true', z.boolean()); + export const env = createEnv({ shared: { NODE_ENV: z.enum(['development', 'production', 'test']), @@ -28,7 +30,7 @@ export const env = createEnv({ // ? URL (including protocol) of the API NEXT_PUBLIC_API_URL: z.string().url(), // ? enables access to EUDR page - NEXT_PUBLIC_ENABLE_EUDR: z.coerce.boolean().optional().default(false), + NEXT_PUBLIC_ENABLE_EUDR: castToBoolean.default(false), NEXT_PUBLIC_PLANET_API_KEY: z.string().default('PLAK6679039df83f414faf798ba4ad4530db'), NEXT_PUBLIC_CARTO_FOREST_ACCESS_TOKEN: z .string() diff --git a/client/src/layouts/application/component.tsx b/client/src/layouts/application/component.tsx index 4006afa70..348ad3d9e 100644 --- a/client/src/layouts/application/component.tsx +++ b/client/src/layouts/application/component.tsx @@ -25,12 +25,13 @@ const ApplicationLayout: React.FC = ({ children }) => { default: CollectionIconOutline, active: CollectionIconSolid, }, + disabled: env.NEXT_PUBLIC_ENABLE_EUDR, }, { name: 'Analysis', href: '/analysis', icon: { default: ChartBarIconOutline, active: ChartBarIconSolid }, - disabled: !!(!lastTask || lastTask?.status === 'processing'), + disabled: !!(!lastTask || lastTask?.status === 'processing') || env.NEXT_PUBLIC_ENABLE_EUDR, }, ...(env.NEXT_PUBLIC_ENABLE_EUDR ? [ @@ -44,13 +45,6 @@ const ApplicationLayout: React.FC = ({ children }) => { : []), ]; - // navigationItems.push({ - // name: 'EUDR', - // href: '/eudr', - // icon: { default: ReportSVG, active: ReportSVG }, - // disabled: !!(!lastTask || lastTask?.status === 'processing'), - // }); - return (