apps/web: fix pass USE_DEV_COLORS to client

This commit is contained in:
vchikalkin 2023-12-23 15:28:46 +03:00
parent ae7faa2cbf
commit 780794c53f
6 changed files with 20 additions and 11 deletions

View File

@ -1,9 +1,9 @@
import { getEnv } from '@/config/env';
import { getClientEnv } from '@/config/env';
import Image from 'next/image';
import logo from 'public/assets/images/logo-primary.svg';
import logoDev from 'public/assets/images/logo-primary-dev.svg';
const env = getEnv();
const env = getClientEnv();
export function Logo() {
return (

View File

@ -1,5 +1,6 @@
const envSchema = require('./schema/env.js');
const { clientEnvSchema, serverEnvSchema } = require('./schema/env');
const getEnv = () => envSchema.parse(process.env);
const getClientEnv = () => clientEnvSchema.parse(process.env);
const getServerEnv = () => serverEnvSchema.parse(process.env);
module.exports = { getEnv };
module.exports = { getClientEnv, getServerEnv };

View File

@ -5,4 +5,12 @@ const envSchema = z.object({
NEXT_PUBLIC_USE_DEV_COLORS: z.string().optional(),
});
module.exports = envSchema;
const serverEnvSchema = envSchema.pick({
URL_IUS_DIRECT: true,
});
const clientEnvSchema = envSchema.pick({
NEXT_PUBLIC_USE_DEV_COLORS: true,
});
module.exports = { envSchema, serverEnvSchema, clientEnvSchema };

View File

@ -1,10 +1,10 @@
import { getEnv } from './env';
import { getServerEnv } from './env';
import proxyUrls from '@/constants/urls';
import { isServer } from '@/utils/common';
export function getUrls() {
if (isServer()) {
const env = getEnv();
const env = getServerEnv();
const { URL_IUS_DIRECT } = env;
return {

View File

@ -1,4 +1,4 @@
import { getEnv } from '../config/env';
import { getClientEnv } from '../config/env';
export const COLORS_PROD = {
COLOR_DANGER: '#B20004',
@ -12,5 +12,5 @@ export const COLORS_DEV = {
COLOR_SECONDARY: '#c54a84',
COLOR_TERTIARTY: '#FF9112',
};
const env = getEnv();
const env = getClientEnv();
export const COLORS = env.NEXT_PUBLIC_USE_DEV_COLORS ? COLORS_DEV : COLORS_PROD;

View File

@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const envSchema = require('./config/schema/env');
const { envSchema } = require('./config/schema/env');
const urls = require('./constants/urls');
const env = envSchema.parse(process.env);