Skip to content

Commit

Permalink
disables analysis routes when EUDR env var is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Apr 17, 2024
1 parent 5da8819 commit b483367
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
42 changes: 29 additions & 13 deletions client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
: []),
]),
];
},
};
Expand Down
4 changes: 3 additions & 1 deletion client/src/env.mjs
Original file line number Diff line number Diff line change
@@ -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']),
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 2 additions & 8 deletions client/src/layouts/application/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ const ApplicationLayout: React.FC<React.PropsWithChildren> = ({ 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
? [
Expand All @@ -44,13 +45,6 @@ const ApplicationLayout: React.FC<React.PropsWithChildren> = ({ children }) => {
: []),
];

// navigationItems.push({
// name: 'EUDR',
// href: '/eudr',
// icon: { default: ReportSVG, active: ReportSVG },
// disabled: !!(!lastTask || lastTask?.status === 'processing'),
// });

return (
<div className="min-w-screen-lg flex h-screen min-h-[700px] overflow-hidden bg-navy-600">
<div className="flex w-28 shrink-0 grow-0 flex-col">
Expand Down

0 comments on commit b483367

Please sign in to comment.