From c98ec94d7f9cb89a9364dd9fca5bb0cc5e0bf643 Mon Sep 17 00:00:00 2001 From: Joe Karow <58997957+JoeKarow@users.noreply.github.com> Date: Fri, 3 May 2024 15:16:00 -0400 Subject: [PATCH] feat: RQ devtool in vercel preview (#1257) # Pull Request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? React Query devtool only shows in local dev Issue Number: N/A ## What is the new behavior? Devtool will show in vercel preview env when logged in. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information ## Summary by CodeRabbit - **New Features** - Introduced a conditional React Query Devtool that dynamically loads based on the user's session status and environment. - **Enhancements** - Simplified language formatting settings in the internationalization configuration. - Streamlined dynamic import and conditional usage of development tools in the application framework. - **Refactor** - Replaced complex conditional logic with simpler, more efficient checks in environment configuration utilities. - **Bug Fixes** - Removed unused imports and outdated configurations to enhance performance and maintainability. --- apps/app/next-i18next.config.mjs | 17 +++++++--------- apps/app/src/pages/_app.tsx | 14 +++---------- apps/app/src/utils/RQDevtool.tsx | 23 +++++++++++++++++++++ packages/env/checks.ts | 34 ++++++++++++++++++++++++++++---- 4 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 apps/app/src/utils/RQDevtool.tsx diff --git a/apps/app/next-i18next.config.mjs b/apps/app/next-i18next.config.mjs index 7a511d1498..7ecac1459f 100644 --- a/apps/app/next-i18next.config.mjs +++ b/apps/app/next-i18next.config.mjs @@ -91,11 +91,11 @@ const config = { partialBundledLanguages: true, nonExplicitSupportedLngs: true, cleanCode: true, - // react: { - // useSuspense: false, - // bindI18nStore: 'added loaded', - // bindI18n: 'languageChanged loaded', - // }, + react: { + useSuspense: false, + // bindI18nStore: 'added loaded', + // bindI18n: 'languageChanged loaded', + }, backend: isBrowser ? { @@ -111,11 +111,8 @@ const config = { skipOnVariables: false, alwaysFormat: true, format: (value, format) => { - switch (format) { - case 'lowercase': { - if (typeof value === 'string') return value.toLowerCase() - break - } + if (format === 'lowercase' && typeof value === 'string') { + return value.toLowerCase() } return value }, diff --git a/apps/app/src/pages/_app.tsx b/apps/app/src/pages/_app.tsx index db029c6449..f99d47aa3d 100644 --- a/apps/app/src/pages/_app.tsx +++ b/apps/app/src/pages/_app.tsx @@ -9,14 +9,12 @@ import { type AppProps, type NextWebVitalsMetric } from 'next/app' import dynamic from 'next/dynamic' import Head from 'next/head' import { useRouter } from 'next/router' -// import Script from 'next/script' import { type Session } from 'next-auth' import { appWithTranslation } from 'next-i18next' import { DefaultSeo, type DefaultSeoProps } from 'next-seo' import { GoogleAnalytics } from 'nextjs-google-analytics' import { appEvent } from '@weareinreach/analytics/events' -import { isLocalDev } from '@weareinreach/env/checks' import { PageLoadProgress } from '@weareinreach/ui/components/core/PageLoadProgress' import { Footer } from '@weareinreach/ui/components/sections/Footer' import { Navbar } from '@weareinreach/ui/components/sections/Navbar' @@ -24,18 +22,14 @@ import { useScreenSize } from '@weareinreach/ui/hooks/useScreenSize' import { BodyGrid } from '@weareinreach/ui/layouts/BodyGrid' import { Providers } from '~app/providers' import { api } from '~app/utils/api' +import { ConditionalReactQueryDevtool } from '~app/utils/RQDevtool' import nextI18nConfig from '../../next-i18next.config.mjs' -// import { Donate, DonateModal } from '@weareinreach/ui/components/core/Donate' + const DonateModal = dynamic(() => import('@weareinreach/ui/components/core/Donate').then((mod) => mod.DonateModal) ) -const ReactQueryDevtools = dynamic( - () => import('@tanstack/react-query-devtools').then((mod) => mod.ReactQueryDevtools), - { ssr: false } -) - const defaultSEO = { titleTemplate: '%s | InReach', defaultTitle: 'InReach', @@ -91,9 +85,7 @@ const MyApp = (appProps: AppPropsWithGridSwitch) => { {(isMobile || isTablet) && }