diff --git a/web/app/components/base/date-and-time-picker/utils/dayjs.ts b/web/app/components/base/date-and-time-picker/utils/dayjs.ts index b37808209c..23307895a7 100644 --- a/web/app/components/base/date-and-time-picker/utils/dayjs.ts +++ b/web/app/components/base/date-and-time-picker/utils/dayjs.ts @@ -3,6 +3,7 @@ import type { Day } from '../types' import dayjs from 'dayjs' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' +import { IS_PROD } from '@/config' import tz from '@/utils/timezone.json' dayjs.extend(utc) @@ -131,7 +132,7 @@ export type ToDayjsOptions = { } const warnParseFailure = (value: string) => { - if (process.env.NODE_ENV !== 'production') + if (!IS_PROD) console.warn('[TimePicker] Failed to parse time value', value) } diff --git a/web/app/components/base/error-boundary/index.tsx b/web/app/components/base/error-boundary/index.tsx index b041bba4d6..9cb4b70cf5 100644 --- a/web/app/components/base/error-boundary/index.tsx +++ b/web/app/components/base/error-boundary/index.tsx @@ -4,6 +4,7 @@ import { RiAlertLine, RiBugLine } from '@remixicon/react' import * as React from 'react' import { useCallback, useEffect, useRef, useState } from 'react' import Button from '@/app/components/base/button' +import { IS_DEV } from '@/config' import { cn } from '@/utils/classnames' type ErrorBoundaryState = { @@ -54,7 +55,7 @@ class ErrorBoundaryInner extends React.Component< } componentDidCatch(error: Error, errorInfo: ErrorInfo) { - if (process.env.NODE_ENV === 'development') { + if (IS_DEV) { console.error('ErrorBoundary caught an error:', error) console.error('Error Info:', errorInfo) } @@ -262,13 +263,13 @@ export function withErrorBoundary

( // Simple error fallback component export const ErrorFallback: React.FC<{ error: Error - resetErrorBoundary: () => void -}> = ({ error, resetErrorBoundary }) => { + resetErrorBoundaryAction: () => void +}> = ({ error, resetErrorBoundaryAction }) => { return (

Oops! Something went wrong

{error.message}

-
diff --git a/web/app/components/base/ga/index.tsx b/web/app/components/base/ga/index.tsx index eb991092e0..03475b3bb4 100644 --- a/web/app/components/base/ga/index.tsx +++ b/web/app/components/base/ga/index.tsx @@ -3,7 +3,7 @@ import type { FC } from 'react' import { headers } from 'next/headers' import Script from 'next/script' import * as React from 'react' -import { IS_CE_EDITION } from '@/config' +import { IS_CE_EDITION, IS_PROD } from '@/config' export enum GaType { admin = 'admin', @@ -32,7 +32,7 @@ const GA: FC = ({ if (IS_CE_EDITION) return null - const cspHeader = process.env.NODE_ENV === 'production' + const cspHeader = IS_PROD ? (headers() as unknown as UnsafeUnwrappedHeaders).get('content-security-policy') : null const nonce = extractNonceFromCSP(cspHeader) diff --git a/web/app/components/base/zendesk/index.tsx b/web/app/components/base/zendesk/index.tsx index dc6ce1e655..e12a128a02 100644 --- a/web/app/components/base/zendesk/index.tsx +++ b/web/app/components/base/zendesk/index.tsx @@ -1,13 +1,13 @@ import { headers } from 'next/headers' import Script from 'next/script' import { memo } from 'react' -import { IS_CE_EDITION, ZENDESK_WIDGET_KEY } from '@/config' +import { IS_CE_EDITION, IS_PROD, ZENDESK_WIDGET_KEY } from '@/config' const Zendesk = async () => { if (IS_CE_EDITION || !ZENDESK_WIDGET_KEY) return null - const nonce = process.env.NODE_ENV === 'production' ? (await headers()).get('x-nonce') ?? '' : '' + const nonce = IS_PROD ? (await headers()).get('x-nonce') ?? '' : '' return ( <> diff --git a/web/app/components/header/github-star/index.tsx b/web/app/components/header/github-star/index.tsx index 01f30fba31..e91bdcca2c 100644 --- a/web/app/components/header/github-star/index.tsx +++ b/web/app/components/header/github-star/index.tsx @@ -3,6 +3,7 @@ import type { FC } from 'react' import type { GithubRepo } from '@/models/common' import { RiLoader2Line } from '@remixicon/react' import { useQuery } from '@tanstack/react-query' +import { IS_DEV } from '@/config' const defaultData = { stargazers_count: 110918, @@ -21,7 +22,7 @@ const GithubStar: FC<{ className: string }> = (props) => { const { isFetching, isError, data } = useQuery({ queryKey: ['github-star'], queryFn: getStar, - enabled: process.env.NODE_ENV !== 'development', + enabled: !IS_DEV, retry: false, placeholderData: defaultData, }) diff --git a/web/service/use-common.ts b/web/service/use-common.ts index 77bb2a11fa..a1edb041c0 100644 --- a/web/service/use-common.ts +++ b/web/service/use-common.ts @@ -23,6 +23,7 @@ import type { } from '@/models/common' import type { RETRIEVE_METHOD } from '@/types/app' import { useMutation, useQuery } from '@tanstack/react-query' +import { IS_DEV } from '@/config' import { get, post } from './base' import { useInvalid } from './use-base' @@ -85,7 +86,7 @@ export const useUserProfile = () => { profile, meta: { currentVersion: response.headers.get('x-version'), - currentEnv: process.env.NODE_ENV === 'development' + currentEnv: IS_DEV ? 'DEVELOPMENT' : response.headers.get('x-env'), },