Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed some hydration errors

Blue Mouseffa91c9a1b0d
diff --git a/app/App.tsx b/app/App.tsx
index 9e8e46e63..1e9c3d213 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -18,17 +18,12 @@ import Loader from 'ui/Loader'
import ScrollToTop from 'hoc/ScrollToTop'
import Selfhosted from 'hoc/Selfhosted'
-import {
- isSelfhosted, PADDLE_JS_URL, PADDLE_VENDOR_ID,
-} from 'redux/constants'
import { getAccessToken } from 'utils/accessToken'
-import { loadScript } from 'utils/generic'
import { authActions } from 'redux/reducers/auth'
import sagaActions from 'redux/sagas/actions'
import { errorsActions } from 'redux/reducers/errors'
import { alertsActions } from 'redux/reducers/alerts'
import { StateType, useAppDispatch } from 'redux/store'
-import UIActions from 'redux/reducers/ui'
import routesPath from 'routesPath'
import { getPageMeta } from 'utils/server'
@@ -71,13 +66,14 @@ const Fallback = ({ isMinimalFooter }: FallbackProps): JSX.Element => {
interface IApp {
ssrTheme: 'dark' | 'light'
+ ssrAuthenticated: boolean
}
const TITLE_BLACKLIST = [
'/projects/', '/captchas/',
]
-const App: React.FC<IApp> = ({ ssrTheme }) => {
+const App: React.FC<IApp> = ({ ssrTheme, ssrAuthenticated }) => {
const dispatch = useAppDispatch()
const { pathname } = useLocation()
const { t } = useTranslation('common')
@@ -85,39 +81,11 @@ const App: React.FC<IApp> = ({ ssrTheme }) => {
const {
loading, authenticated,
} = useSelector((state: StateType) => state.auth)
- const paddleLoaded = useSelector((state: StateType) => state.ui.misc.paddleLoaded)
const { error } = useSelector((state: StateType) => state.errors)
const { message, type } = useSelector((state: StateType) => state.alerts)
const accessToken = getAccessToken()
const refreshToken = getRefreshToken()
- // Paddle (payment processor) set-up
- useEffect(() => {
- if (paddleLoaded || !authenticated) {
- return
- }
-
- loadScript(PADDLE_JS_URL)
-
- const eventCallback = (data: any) => {
- dispatch(UIActions.setPaddleLastEvent(data))
- }
- // eslint-disable-next-line no-use-before-define
- const interval = setInterval(paddleSetup, 200)
-
- function paddleSetup() {
- if (isSelfhosted) {
- clearInterval(interval)
- } else if ((window as any)?.Paddle) {
- (window as any).Paddle.Setup({
- vendor: PADDLE_VENDOR_ID,
- eventCallback,
- })
- clearInterval(interval)
- }
- }
- }, [paddleLoaded, authenticated]) // eslint-disable-line
-
useEffect(() => {
(async () => {
if ((accessToken && refreshToken) && !authenticated) {
@@ -170,7 +138,7 @@ const App: React.FC<IApp> = ({ ssrTheme }) => {
// eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
{pathname !== routesPath.main && (
- <Header ssrTheme={ssrTheme} />
+ <Header ssrTheme={ssrTheme} ssrAuthenticated={ssrAuthenticated} />
)}
{/* @ts-ignore */}
<ScrollToTop>
diff --git a/app/components/Header/index.tsx b/app/components/Header/index.tsx
index 68898f4a5..746f21084 100644
--- a/app/components/Header/index.tsx
+++ b/app/components/Header/index.tsx
@@ -573,9 +573,10 @@ const NotAuthedHeader = ({
interface IHeader {
ssrTheme: 'dark' | 'light'
+ ssrAuthenticated: boolean
}
-const Header: React.FC<IHeader> = ({ ssrTheme }): JSX.Element => {
+const Header: React.FC<IHeader> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
const { t, i18n: { language } }: {
t: (key: string, options?: {
[key: string]: string | number | null
@@ -584,12 +585,13 @@ const Header: React.FC<IHeader> = ({ ssrTheme }): JSX.Element => {
} = useTranslation('common')
const dispatch = useAppDispatch()
const _dispatch = useDispatch()
- const { authenticated, user } = useSelector((state: StateType) => state.auth)
+ const { authenticated: reduxAuthenticated, user } = useSelector((state: StateType) => state.auth)
const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)
const { pathname } = useLocation()
// @ts-ignore
const buttonRef: MutableRefObject<HTMLButtonElement> = useRef<HTMLButtonElement>()
const theme = isBrowser ? reduxTheme : ssrTheme
+ const authenticated = isBrowser ? reduxAuthenticated : ssrAuthenticated
const [rawStatus, status] = useMemo(() => {
const { trialEndDate } = (user || {})
diff --git a/app/entry.client.tsx b/app/entry.client.tsx
index 59c355509..2e75f2d92 100644
--- a/app/entry.client.tsx
+++ b/app/entry.client.tsx
@@ -1,6 +1,8 @@
import { RemixBrowser } from '@remix-run/react'
import { startTransition, StrictMode } from 'react'
import { hydrateRoot } from 'react-dom/client'
+import _forEach from 'lodash/forEach'
+import _includes from 'lodash/includes'
import i18next from 'i18next'
import { I18nextProvider, initReactI18next } from 'react-i18next'
@@ -9,6 +11,23 @@ import HTTPBackend from 'i18next-http-backend'
import { getInitialNamespaces } from 'remix-i18next'
import i18n from './i18n'
+const clearBrowserExtensionInjectionsBeforeHydration = () => {
+ _forEach(
+ document
+ .querySelectorAll(
+ [
+ 'html > *:not(body, head)',
+ 'script[src*="extension://"]',
+ 'link[href*="extension://"]',
+ 'body > link[rel="modulepreload"]',
+ ].join(', '),
+ ),
+ (s) => {
+ s.parentNode?.removeChild(s)
+ },
+ )
+}
+
async function hydrate() {
await i18next
.use(initReactI18next)
@@ -24,6 +43,8 @@ async function hydrate() {
},
})
+ clearBrowserExtensionInjectionsBeforeHydration()
+
startTransition(() => {
hydrateRoot(
document,
diff --git a/app/pages/Billing/index.tsx b/app/pages/Billing/index.tsx
index d09fbebb2..8e54027af 100644
--- a/app/pages/Billing/index.tsx
+++ b/app/pages/Billing/index.tsx
@@ -11,13 +11,17 @@ import duration from 'dayjs/plugin/duration'
import { ExclamationTriangleIcon, InformationCircleIcon } from '@heroicons/react/24/outline'
import _round from 'lodash/round'
-import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'
+import {
+ isSelfhosted, PADDLE_JS_URL, PADDLE_VENDOR_ID, CONTACT_EMAIL, paddleLanguageMapping,
+} from 'redux/constants'
+import { loadScript } from 'utils/generic'
+import { useAppDispatch, StateType } from 'redux/store'
import routes from 'routesPath'
import sagaActions from 'redux/sagas/actions'
import { withAuthentication, auth } from 'hoc/protected'
import Modal from 'ui/Modal'
import { IUser } from 'redux/models/IUser'
-import { StateType } from 'redux/store/index'
+import UIActions from 'redux/reducers/ui'
import Pricing from '../MainPage/Pricing'
dayjs.extend(utc)
@@ -30,7 +34,9 @@ const Billing = (): JSX.Element => {
user: IUser
} = useSelector((state: StateType) => state.auth)
const { theme } = useSelector((state: StateType) => state.ui.theme)
+ const paddleLoaded = useSelector((state: StateType) => state.ui.misc.paddleLoaded)
const dispatch = useDispatch()
+ const _dispatch = useAppDispatch()
const { t, i18n: { language } }: {
t: (key: string, optinions?: {
[key: string]: string | number,
@@ -47,6 +53,33 @@ const Billing = (): JSX.Element => {
const isNoSub: boolean = planCode === 'none'
const totalUsage = _round((usageinfo.total / maxEventsCount) * 100, 2)
+ // Paddle (payment processor) set-up
+ useEffect(() => {
+ if (paddleLoaded) {
+ return
+ }
+
+ loadScript(PADDLE_JS_URL)
+
+ const eventCallback = (data: any) => {
+ _dispatch(UIActions.setPaddleLastEvent(data))
+ }
+ // eslint-disable-next-line no-use-before-define
+ const interval = setInterval(paddleSetup, 200)
+
+ function paddleSetup() {
+ if (isSelfhosted) {
+ clearInterval(interval)
+ } else if ((window as any)?.Paddle) {
+ (window as any).Paddle.Setup({
+ vendor: PADDLE_VENDOR_ID,
+ eventCallback,
+ })
+ clearInterval(interval)
+ }
+ }
+ }, [paddleLoaded]) // eslint-disable-line
+
useEffect(() => {
dispatch(sagaActions.loadUsageinfo())
}, [dispatch])
@@ -148,14 +181,14 @@ const Billing = (): JSX.Element => {
</h1>
<div>
{subUpdateURL && (
- <span onClick={onUpdatePaymentDetails} className='inline-flex select-none cursor-pointer mr-2 items-center border border-transparent leading-4 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 px-4 py-2 text-sm'>
- {t('billing.update')}
- </span>
+ <span onClick={onUpdatePaymentDetails} className='inline-flex select-none cursor-pointer mr-2 items-center border border-transparent leading-4 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 px-4 py-2 text-sm'>
+ {t('billing.update')}
+ </span>
)}
{subCancelURL && (
- <span onClick={() => setIsCancelSubModalOpened(true)} className='inline-flex select-none cursor-pointer items-center border border-transparent leading-4 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 shadow-sm text-white bg-red-500 dark:bg-red-600 hover:bg-red-600 dark:hover:bg-red-700 px-4 py-2 text-sm'>
- {t('billing.cancelSub')}
- </span>
+ <span onClick={() => setIsCancelSubModalOpened(true)} className='inline-flex select-none cursor-pointer items-center border border-transparent leading-4 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 shadow-sm text-white bg-red-500 dark:bg-red-600 hover:bg-red-600 dark:hover:bg-red-700 px-4 py-2 text-sm'>
+ {t('billing.cancelSub')}
+ </span>
)}
</div>
</div>
@@ -168,53 +201,53 @@ const Billing = (): JSX.Element => {
</p>
<hr className='mt-3 mb-2 border-gray-200 dark:border-gray-600' />
{cancellationEffectiveDate && (
- <div className='flex items-center text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- <InformationCircleIcon className='h-10 w-10 mr-2 text-blue-600' aria-hidden='true' />
- <span className='font-bold max-w-prose'>
- {t('billing.cancelledSubMessage', {
- date: language === 'en'
- ? dayjs(cancellationEffectiveDate).locale(language).format('MMMM D, YYYY')
- : dayjs(cancellationEffectiveDate).locale(language).format('D MMMM, YYYY'),
- })}
- </span>
- </div>
+ <div className='flex items-center text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ <InformationCircleIcon className='h-10 w-10 mr-2 text-blue-600' aria-hidden='true' />
+ <span className='font-bold max-w-prose'>
+ {t('billing.cancelledSubMessage', {
+ date: language === 'en'
+ ? dayjs(cancellationEffectiveDate).locale(language).format('MMMM D, YYYY')
+ : dayjs(cancellationEffectiveDate).locale(language).format('D MMMM, YYYY'),
+ })}
+ </span>
+ </div>
)}
{nextBillDate && (
- <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- <span className='font-bold'>
- {t('billing.nextBillDate')}
- </span>
- &nbsp;
- <span>
- {language === 'en'
- ? dayjs(nextBillDate).locale(language).format('MMMM D, YYYY')
- : dayjs(nextBillDate).locale(language).format('D MMMM, YYYY')}
- </span>
- </div>
+ <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ <span className='font-bold'>
+ {t('billing.nextBillDate')}
+ </span>
+ &nbsp;
+ <span>
+ {language === 'en'
+ ? dayjs(nextBillDate).locale(language).format('MMMM D, YYYY')
+ : dayjs(nextBillDate).locale(language).format('D MMMM, YYYY')}
+ </span>
+ </div>
)}
{isTrial && trialMessage && (
- <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- <span className='font-bold'>
- {trialMessage}
- </span>
- </div>
+ <div className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ <span className='font-bold'>
+ {trialMessage}
+ </span>
+ </div>
)}
{isNoSub && (
- <div className='flex items-center text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- <ExclamationTriangleIcon className='h-10 w-10 mr-2 text-red-600' aria-hidden='true' />
- <span className='font-bold max-w-prose'>
- {t('billing.noSubWarning')}
- </span>
- </div>
+ <div className='flex items-center text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
+ <ExclamationTriangleIcon className='h-10 w-10 mr-2 text-red-600' aria-hidden='true' />
+ <span className='font-bold max-w-prose'>
+ {t('billing.noSubWarning')}
+ </span>
+ </div>
)}
<Pricing t={t} language={language} />
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight mt-10'>
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='billing.contact'
values={{ email: CONTACT_EMAIL }}
- // @ts-ignore
+ // @ts-ignore
components={{
mail: <a title={`Email us at ${CONTACT_EMAIL}`} href={`mailto:${CONTACT_EMAIL}`} className='font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400' />,
amount: 5,
@@ -270,14 +303,14 @@ const Billing = (): JSX.Element => {
type='error'
message={(
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='pricing.cancelDesc'
values={{
email: CONTACT_EMAIL,
}}
/>
- )}
+ )}
isOpened={isCancelSubModalOpened}
/>
</div>
diff --git a/app/pages/Dashboard/Dashboard.tsx b/app/pages/Dashboard/Dashboard.tsx
index 9db180202..a69633666 100644
--- a/app/pages/Dashboard/Dashboard.tsx
+++ b/app/pages/Dashboard/Dashboard.tsx
@@ -3,6 +3,7 @@ import React, {
memo, useState, useEffect, useMemo,
} from 'react'
import { Link, useNavigate } from '@remix-run/react'
+import { ClientOnly } from 'remix-utils'
import cx from 'clsx'
import PropTypes from 'prop-types'
import _isEmpty from 'lodash/isEmpty'
@@ -496,139 +497,149 @@ const Dashboard = ({
<Loader />
</div>
) : (
- <>
- {tabProjects === tabForOwnedProject && (
- <div>
- {_isEmpty(_filter(projects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
- ) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
- {_map(_filter(projects, ({ uiHidden }) => !uiHidden), ({
- name, id, active, overall, public: isPublic, isTransferring,
- }) => (
- <ProjectCard
- key={id}
- id={id}
- type='analytics'
- t={t}
- name={name}
- active={active}
- isPublic={isPublic}
- overall={overall}
- live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
- setUserShareData={() => { }}
- deleteProjectFailed={() => { }}
- userSharedUpdate={() => { }}
- sharedProjects={[]}
- setProjectsShareData={() => { }}
- sharedProjectError={() => { }}
- isTransferring={isTransferring}
- confirmed
- />
- ))}
- <AddProject t={t} onClick={onNewProject} />
- </ul>
- )}
+ <ClientOnly
+ fallback={(
+ <div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
+ <Loader />
</div>
)}
-
- {tabProjects === tabForCaptchaProject && (
- <div>
- {_isEmpty(_filter(captchaProjects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
- ) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
- {_map(_filter(captchaProjects, ({ uiHidden }) => !uiHidden), ({
- name, id, active, overall, public: isPublic,
- }) => (
- <ProjectCard
- t={t}
- key={id}
- id={id}
- type='captcha'
- name={name}
- captcha
- active={active}
- isPublic={isPublic}
- overall={overall}
- live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
- deleteProjectFailed={() => { }}
- sharedProjects={[]}
- setProjectsShareData={() => { }}
- setUserShareData={() => { }}
- userSharedUpdate={() => { }}
- sharedProjectError={() => { }}
- confirmed
- />
- ))}
- <AddProject t={t} onClick={onNewProject} />
- </ul>
+ >
+ {() => (
+ <>
+ {tabProjects === tabForOwnedProject && (
+ <div>
+ {_isEmpty(_filter(projects, ({ uiHidden }) => !uiHidden)) ? (
+ <NoProjects t={t} onClick={onNewProject} />
+ ) : (
+ <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
+ {_map(_filter(projects, ({ uiHidden }) => !uiHidden), ({
+ name, id, active, overall, public: isPublic, isTransferring,
+ }) => (
+ <ProjectCard
+ key={id}
+ id={id}
+ type='analytics'
+ t={t}
+ name={name}
+ active={active}
+ isPublic={isPublic}
+ overall={overall}
+ live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
+ setUserShareData={() => { }}
+ deleteProjectFailed={() => { }}
+ userSharedUpdate={() => { }}
+ sharedProjects={[]}
+ setProjectsShareData={() => { }}
+ sharedProjectError={() => { }}
+ isTransferring={isTransferring}
+ confirmed
+ />
+ ))}
+ <AddProject t={t} onClick={onNewProject} />
+ </ul>
+ )}
+ </div>
)}
- </div>
- )}
- {tabProjects === tabForSharedProject && (
- <div>
- {_isEmpty(_filter(sharedProjects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
- ) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
- {_map(_filter(sharedProjects, ({ uiHidden }) => !uiHidden), ({
- project, confirmed,
- }) => {
- if (_isUndefined(confirmed) || confirmed) {
- return (
+ {tabProjects === tabForCaptchaProject && (
+ <div>
+ {_isEmpty(_filter(captchaProjects, ({ uiHidden }) => !uiHidden)) ? (
+ <NoProjects t={t} onClick={onNewProject} />
+ ) : (
+ <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
+ {_map(_filter(captchaProjects, ({ uiHidden }) => !uiHidden), ({
+ name, id, active, overall, public: isPublic,
+ }) => (
<ProjectCard
t={t}
- key={confirmed ? `${project?.id}-confirmed` : project?.id}
- type='analytics'
- id={project?.id}
- name={project?.name}
- shared
- getRole={getRole}
- active={project?.active}
- isPublic={project?.public}
- confirmed={confirmed}
- overall={project?.overall}
- live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
- setUserShareData={() => { }}
+ key={id}
+ id={id}
+ type='captcha'
+ name={name}
+ captcha
+ active={active}
+ isPublic={isPublic}
+ overall={overall}
+ live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
deleteProjectFailed={() => { }}
sharedProjects={[]}
setProjectsShareData={() => { }}
+ setUserShareData={() => { }}
userSharedUpdate={() => { }}
sharedProjectError={() => { }}
+ confirmed
/>
- )
- }
-
- return (
- <ProjectCard
- t={t}
- key={confirmed ? `${project?.id}-confirmed` : project?.id}
- id={project?.id}
- type='analytics'
- name={project?.name}
- shared
- getRole={getRole}
- active={project?.active}
- isPublic={project?.public}
- overall={project?.overall}
- confirmed={confirmed}
- sharedProjects={user.sharedProjects}
- setProjectsShareData={setProjectsShareData}
- setUserShareData={setUserShareData}
- live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
- userSharedUpdate={userSharedUpdate}
- sharedProjectError={sharedProjectError}
- deleteProjectFailed={deleteProjectFailed}
- />
- )
- })}
- </ul>
+ ))}
+ <AddProject t={t} onClick={onNewProject} />
+ </ul>
+ )}
+ </div>
)}
- </div>
+
+ {tabProjects === tabForSharedProject && (
+ <div>
+ {_isEmpty(_filter(sharedProjects, ({ uiHidden }) => !uiHidden)) ? (
+ <NoProjects t={t} onClick={onNewProject} />
+ ) : (
+ <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:gap-y-6 lg:grid-cols-3'>
+ {_map(_filter(sharedProjects, ({ uiHidden }) => !uiHidden), ({
+ project, confirmed,
+ }) => {
+ if (_isUndefined(confirmed) || confirmed) {
+ return (
+ <ProjectCard
+ t={t}
+ key={confirmed ? `${project?.id}-confirmed` : project?.id}
+ type='analytics'
+ id={project?.id}
+ name={project?.name}
+ shared
+ getRole={getRole}
+ active={project?.active}
+ isPublic={project?.public}
+ confirmed={confirmed}
+ overall={project?.overall}
+ live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
+ setUserShareData={() => { }}
+ deleteProjectFailed={() => { }}
+ sharedProjects={[]}
+ setProjectsShareData={() => { }}
+ userSharedUpdate={() => { }}
+ sharedProjectError={() => { }}
+ />
+ )
+ }
+
+ return (
+ <ProjectCard
+ t={t}
+ key={confirmed ? `${project?.id}-confirmed` : project?.id}
+ id={project?.id}
+ type='analytics'
+ name={project?.name}
+ shared
+ getRole={getRole}
+ active={project?.active}
+ isPublic={project?.public}
+ overall={project?.overall}
+ confirmed={confirmed}
+ sharedProjects={user.sharedProjects}
+ setProjectsShareData={setProjectsShareData}
+ setUserShareData={setUserShareData}
+ live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
+ userSharedUpdate={userSharedUpdate}
+ sharedProjectError={sharedProjectError}
+ deleteProjectFailed={deleteProjectFailed}
+ />
+ )
+ })}
+ </ul>
+ )}
+ </div>
+ )}
+ </>
)}
- </>
+ </ClientOnly>
)}
{(tabProjects === tabForOwnedProject && pageAmount > 1) && (
<Pagination className='mt-2' page={dashboardPaginationPage} pageAmount={pageAmount} setPage={setDashboardPaginationPage} total={total} />
diff --git a/app/pages/MainPage/Pricing.tsx b/app/pages/MainPage/Pricing.tsx
index 8ad276b85..d36276f01 100644
--- a/app/pages/MainPage/Pricing.tsx
+++ b/app/pages/MainPage/Pricing.tsx
@@ -1,6 +1,7 @@
/* eslint-disable no-confusing-arrow */
import React, { memo, useState, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
+import { ClientOnly } from 'remix-utils'
import { Link } from '@remix-run/react'
import { CheckIcon } from '@heroicons/react/24/solid'
import _map from 'lodash/map'
@@ -23,6 +24,7 @@ import { authMe } from 'api'
import routes from 'routesPath'
import { IUser } from 'redux/models/IUser'
import { AppDispatch, StateType } from 'redux/store'
+import Loader from 'ui/Loader'
type CurrencyCode = 'USD' | 'EUR' | 'GBP'
@@ -207,17 +209,21 @@ const PricingItem = ({
{t('pricing.legacy')}
</p>
)}
- <p className='mt-4 text-center'>
- <span className='text-4xl font-bold text-[#4D4D4D] dark:text-gray-50'>
- {currency.symbol}
- {billingFrequency === BillingFrequency.monthly ? tier.priceMonthly : tier.priceYearly}
- </span>
- &nbsp;
- <span className='text-base font-medium text-gray-500 dark:text-gray-400'>
- /
- {t(billingFrequency === BillingFrequency.monthly ? 'pricing.perMonth' : 'pricing.perYear')}
- </span>
- </p>
+ <ClientOnly fallback={<Loader />}>
+ {() => (
+ <p className='mt-4 text-center'>
+ <span className='text-4xl font-bold text-[#4D4D4D] dark:text-gray-50'>
+ {currency.symbol}
+ {billingFrequency === BillingFrequency.monthly ? tier.priceMonthly : tier.priceYearly}
+ </span>
+ &nbsp;
+ <span className='text-base font-medium text-gray-500 dark:text-gray-400'>
+ /
+ {t(billingFrequency === BillingFrequency.monthly ? 'pricing.perMonth' : 'pricing.perYear')}
+ </span>
+ </p>
+ )}
+ </ClientOnly>
{authenticated ? (
<span
onClick={() => downgrade ? downgradeHandler(tier) : onPlanChange(tier)}
diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsx
index 8a6b156ad..a3232fb35 100644
--- a/app/pages/MainPage/index.tsx
+++ b/app/pages/MainPage/index.tsx
@@ -3,6 +3,7 @@ import React, { memo } from 'react'
import { useTranslation, Trans } from 'react-i18next'
import cx from 'clsx'
import { useSelector } from 'react-redux'
+import { ClientOnly } from 'remix-utils'
import {
ArrowTopRightOnSquareIcon, ArrowSmallRightIcon, CheckCircleIcon, CheckIcon, XMarkIcon, ChevronRightIcon,
} from '@heroicons/react/24/solid'
@@ -139,9 +140,10 @@ const M_FEATURES_ICONS = [
interface IMain {
ssrTheme: 'dark' | 'light'
+ ssrAuthenticated: boolean
}
-const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
+const Main: React.FC<IMain> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {
const { t, i18n: { language } }: {
t: (key: string, options?: {
[key: string]: any
@@ -151,9 +153,10 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
},
} = useTranslation('common')
const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)
- const { authenticated } = useSelector((state: StateType) => state.auth)
+ const reduxAuthenticated = useSelector((state: StateType) => state.auth.authenticated)
const { stats, lastBlogPost } = useSelector((state: StateType) => state.ui.misc)
const theme = isBrowser ? reduxTheme : ssrTheme
+ const authenticated = isBrowser ? reduxAuthenticated : ssrAuthenticated
const events = nFormatterSeparated(Number(stats.events))
const users = nFormatterSeparated(Number(stats.users))
@@ -196,11 +199,11 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
className='aspect-[1108/632] w-[69.25rem] bg-gradient-to-r from-[#80caff] to-[#4f46e5] opacity-20'
style={{
clipPath:
- 'polygon(73.6% 51.7%, 91.7% 11.8%, 100% 46.4%, 97.4% 82.2%, 92.5% 84.9%, 75.7% 64%, 55.3% 47.5%, 46.5% 49.4%, 45% 62.9%, 50.3% 87.2%, 21.3% 64.1%, 0.1% 100%, 5.4% 51.1%, 21.4% 63.9%, 58.9% 0.2%, 73.6% 51.7%)',
+ 'polygon(73.6% 51.7%, 91.7% 11.8%, 100% 46.4%, 97.4% 82.2%, 92.5% 84.9%, 75.7% 64%, 55.3% 47.5%, 46.5% 49.4%, 45% 62.9%, 50.3% 87.2%, 21.3% 64.1%, 0.1% 100%, 5.4% 51.1%, 21.4% 63.9%, 58.9% 0.2%, 73.6% 51.7%)',
}}
/>
</div>
- <Header ssrTheme={ssrTheme} />
+ <Header ssrTheme={ssrTheme} ssrAuthenticated={ssrAuthenticated} />
<div className='flex justify-center items-center py-2 px-2'>
<a
href='https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi'
@@ -219,7 +222,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
<div className='lg:mt-0 text-left relative lg:mr-14 px-4'>
<h1 className='max-w-2xl text-3xl sm:text-5xl md:text-5xl font-extrabold text-slate-900 dark:text-white sm:leading-none lg:text-5xl xl:text-6xl xl:leading-[110%]'>
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='main.slogan'
components={{
@@ -234,17 +237,21 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
{_isEmpty(lastBlogPost) ? (
<div className='h-6 ml-1 bg-slate-300 dark:bg-slate-700 w-80 rounded-md animate-pulse' />
) : (
- <a
- className='inline-flex ml-1 items-center space-x-1 text-sm font-semibold leading-6 text-slate-700 dark:text-slate-300 hover:underline'
- href={`${BLOG_URL}post/${lastBlogPost.url_path}`}
- target='_blank'
- rel='noopener noreferrer'
- >
- <span>
- {lastBlogPost.title}
- </span>
- <ChevronRightIcon className='h-4 w-4 text-slate-500' aria-hidden='true' />
- </a>
+ <ClientOnly fallback={<div className='h-6 ml-1 bg-slate-300 dark:bg-slate-700 w-80 rounded-md animate-pulse' />}>
+ {() => (
+ <a
+ className='inline-flex ml-1 items-center space-x-1 text-sm font-semibold leading-6 text-slate-700 dark:text-slate-300 hover:underline'
+ href={`${BLOG_URL}post/${lastBlogPost.url_path}`}
+ target='_blank'
+ rel='noopener noreferrer'
+ >
+ <span>
+ {lastBlogPost.title}
+ </span>
+ <ChevronRightIcon className='h-4 w-4 text-slate-500' aria-hidden='true' />
+ </a>
+ )}
+ </ClientOnly>
)}
</div>
<p className='text-base text-slate-700 dark:text-slate-300 sm:text-xl lg:text-lg xl:text-lg'>
@@ -364,19 +371,19 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
{t('main.privacy.title')}
</h2>
{_map(t('main.privacy.list', { returnObjects: true }), (item: {
- label: string
- desc: string
- }) => (
- <div key={item.label} className='mb-4 flex items-center'>
- <div className='mr-3'>
- <CheckCircleIcon className='fill-indigo-500 w-[24px] h-[24px]' />
- </div>
- <p>
- <span className='dark:text-white'>{item.label}</span>
- <span className='mr-1 ml-1 dark:text-white'>-</span>
- <span className='text-gray-600 dark:text-gray-400'>{item.desc}</span>
- </p>
+ label: string
+ desc: string
+ }) => (
+ <div key={item.label} className='mb-4 flex items-center'>
+ <div className='mr-3'>
+ <CheckCircleIcon className='fill-indigo-500 w-[24px] h-[24px]' />
</div>
+ <p>
+ <span className='dark:text-white'>{item.label}</span>
+ <span className='mr-1 ml-1 dark:text-white'>-</span>
+ <span className='text-gray-600 dark:text-gray-400'>{item.desc}</span>
+ </p>
+ </div>
))}
{/* mt-7 because mb-4 in upper component + mt-7 = 11. mb-11 is used for spacing the links in other sections. */}
<Link to={routesPath.privacy} className='mt-7 dark:text-indigo-400 text-indigo-700 hover:underline font-bold border-0 flex items-center' aria-label={t('footer.pp')}>
@@ -389,59 +396,59 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
</div>
{/* block singup */}
{!authenticated && (
- <div className='overflow-x-clip'>
- <div className='py-20 max-w-7xl w-full flex justify-center md:justify-between items-center mx-auto px-5 relative isolate'>
- <div
- className='absolute inset-x-0 -top-3 -z-10 transform-gpu overflow-hidden px-36 blur-3xl'
- aria-hidden='true'
- >
+ <div className='overflow-x-clip'>
+ <div className='py-20 max-w-7xl w-full flex justify-center md:justify-between items-center mx-auto px-5 relative isolate'>
<div
- className='mx-auto aspect-[1155/678] w-[72.1875rem] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] opacity-30'
- style={{
- clipPath:
- 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
- }}
- />
- </div>
- <div className='relative z-50 lg:col-span-6 rounded-xl'>
- <div className='bg-white dark:bg-slate-800/20 ring-1 ring-slate-200 dark:ring-slate-800 sm:max-w-md sm:w-full sm:mx-auto sm:rounded-lg sm:overflow-hidden'>
- <div className='px-4 py-8 sm:px-10'>
- <p className='text-lg text-gray-900 dark:text-white text-center md:text-xl font-semibold'>
- {t('main.signup')}
- </p>
- <div className='mt-6'>
- <SignUp ssrTheme={ssrTheme} />
- </div>
- </div>
- <div className='px-4 sm:px-10'>
- <div className='py-6 bg-transparent border-t border-gray-200 dark:border-slate-700'>
- <p className='text-xs leading-5 text-gray-500 dark:text-gray-100'>
- <Trans
- // @ts-ignore
- t={t}
- i18nKey='main.signupTerms'
- components={{
- tos: <Link to={routesPath.terms} className='font-medium text-gray-900 dark:text-gray-300 hover:underline' aria-label={t('footer.tos')} />,
- pp: <Link to={routesPath.privacy} className='font-medium text-gray-900 dark:text-gray-300 hover:underline' aria-label={t('footer.pp')} />,
- }}
- />
+ className='absolute inset-x-0 -top-3 -z-10 transform-gpu overflow-hidden px-36 blur-3xl'
+ aria-hidden='true'
+ >
+ <div
+ className='mx-auto aspect-[1155/678] w-[72.1875rem] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] opacity-30'
+ style={{
+ clipPath:
+ 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
+ }}
+ />
+ </div>
+ <div className='relative z-50 lg:col-span-6 rounded-xl'>
+ <div className='bg-white dark:bg-slate-800/20 ring-1 ring-slate-200 dark:ring-slate-800 sm:max-w-md sm:w-full sm:mx-auto sm:rounded-lg sm:overflow-hidden'>
+ <div className='px-4 py-8 sm:px-10'>
+ <p className='text-lg text-gray-900 dark:text-white text-center md:text-xl font-semibold'>
+ {t('main.signup')}
</p>
+ <div className='mt-6'>
+ <SignUp ssrTheme={ssrTheme} />
+ </div>
+ </div>
+ <div className='px-4 sm:px-10'>
+ <div className='py-6 bg-transparent border-t border-gray-200 dark:border-slate-700'>
+ <p className='text-xs leading-5 text-gray-500 dark:text-gray-100'>
+ <Trans
+ // @ts-ignore
+ t={t}
+ i18nKey='main.signupTerms'
+ components={{
+ tos: <Link to={routesPath.terms} className='font-medium text-gray-900 dark:text-gray-300 hover:underline' aria-label={t('footer.tos')} />,
+ pp: <Link to={routesPath.privacy} className='font-medium text-gray-900 dark:text-gray-300 hover:underline' aria-label={t('footer.pp')} />,
+ }}
+ />
+ </p>
+ </div>
</div>
</div>
</div>
- </div>
- <div className='relative'>
- <picture>
- <source srcSet={theme === 'dark' ? '/assets/section-signup-dark.webp' : '/assets/section-signup-light.webp'} type='image/webp' />
- <img
- src={theme === 'dark' ? '/assets/section-signup-dark.png' : '/assets/section-signup-light.png'}
- className='relative z-50 hidden md:block'
- alt='Swetrix Dashboard overview'
- />
- </picture>
+ <div className='relative'>
+ <picture>
+ <source srcSet={theme === 'dark' ? '/assets/section-signup-dark.webp' : '/assets/section-signup-light.webp'} type='image/webp' />
+ <img
+ src={theme === 'dark' ? '/assets/section-signup-dark.png' : '/assets/section-signup-light.png'}
+ className='relative z-50 hidden md:block'
+ alt='Swetrix Dashboard overview'
+ />
+ </picture>
+ </div>
</div>
</div>
- </div>
)}
{/* end block singup */}
{/* Core features section */}
@@ -455,16 +462,16 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
</div>
<div className='mt-[60px] flex items-center max-w-7xl w-full mx-auto flex-wrap justify-center xl:justify-between'>
{_map(t('main.features', { returnObjects: true }), (item: {
- name: string
- desc: string
- }, index: number) => (
- <div key={item.name} className='w-[416px] h-64 px-7 py-11 text-center'>
- <span className='text-indigo-500 text-3xl font-semibold'>{1 + index}</span>
- <div className='mt-2'>
- <h2 className='text-slate-900 dark:text-white text-xl font-semibold max-w-[300px] mx-auto mb-3 whitespace-pre-line'>{item.name}</h2>
- <p className='text-gray-500 max-w-xs mx-auto dark:text-gray-400'>{item.desc}</p>
- </div>
+ name: string
+ desc: string
+ }, index: number) => (
+ <div key={item.name} className='w-[416px] h-64 px-7 py-11 text-center'>
+ <span className='text-indigo-500 text-3xl font-semibold'>{1 + index}</span>
+ <div className='mt-2'>
+ <h2 className='text-slate-900 dark:text-white text-xl font-semibold max-w-[300px] mx-auto mb-3 whitespace-pre-line'>{item.name}</h2>
+ <p className='text-gray-500 max-w-xs mx-auto dark:text-gray-400'>{item.desc}</p>
</div>
+ </div>
))}
</div>
<BackgroundSvg theme={theme} className='absolute right-0 bottom-0 z-10' type='twolinecircle' />
@@ -524,20 +531,20 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
</h2>
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-y-10 sm:gap-y-24 justify-between justify-items-center text-slate-900 dark:text-white pt-20 pb-36'>
{_map(t('main.mFeatures', { returnObjects: true }), (item: {
- name: string
- desc: string
- }, index: number) => (
- <div key={item.name} className='max-w-[310px] w-full'>
- <div className='flex items-center'>
- <span className='text-slate-900 dark:text-gray-200 text-xl mr-4'>
- {M_FEATURES_ICONS[index]}
- </span>
- <h2 className='font-semibold text-xl'>
- {item.name}
- </h2>
- </div>
- <p className='pl-9 text-slate-700 dark:text-gray-300'>{item.desc}</p>
+ name: string
+ desc: string
+ }, index: number) => (
+ <div key={item.name} className='max-w-[310px] w-full'>
+ <div className='flex items-center'>
+ <span className='text-slate-900 dark:text-gray-200 text-xl mr-4'>
+ {M_FEATURES_ICONS[index]}
+ </span>
+ <h2 className='font-semibold text-xl'>
+ {item.name}
+ </h2>
</div>
+ <p className='pl-9 text-slate-700 dark:text-gray-300'>{item.desc}</p>
+ </div>
))}
</div>
</section>
@@ -557,7 +564,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
className='ml-[max(50%,38rem)] aspect-[1313/771] w-[82.0625rem] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc]'
style={{
clipPath:
- 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
+ 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
}}
/>
</div>
@@ -569,14 +576,14 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
className='ml-[-22rem] aspect-[1313/771] w-[82.0625rem] flex-none origin-top-right rotate-[30deg] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] xl:ml-0 xl:mr-[calc(50%-12rem)]'
style={{
clipPath:
- 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
+ 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
}}
/>
</div>
<section className='relative z-20 px-3'>
<h1 className='mt-20 text-center h-8 mb-5 text-3xl sm:text-5xl text-slate-900 dark:text-white font-extrabold max-w-prose w-full mx-auto'>
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='main.whyUseSwetrix'
components={{
@@ -627,15 +634,15 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
className='w-1/6 px-3 py-4 text-sm text-gray-50 sm:pl-6'
>
{COMPETITOR_FEATURE_TABLE[service][key] && (
- <CheckIcon className='flex-shrink-0 h-5 w-5 text-green-600 dark:text-green-500' aria-label={t('common.yes')} />
+ <CheckIcon className='flex-shrink-0 h-5 w-5 text-green-600 dark:text-green-500' aria-label={t('common.yes')} />
)}
{COMPETITOR_FEATURE_TABLE[service][key] === false && (
- <XMarkIcon className='flex-shrink-0 h-5 w-5 text-red-600 dark:text-red-500' aria-label={t('common.no')} />
+ <XMarkIcon className='flex-shrink-0 h-5 w-5 text-red-600 dark:text-red-500' aria-label={t('common.no')} />
)}
{COMPETITOR_FEATURE_TABLE[service][key] === null && (
- <p className='text-slate-700 dark:text-gray-50 h-5 w-5 text-center'>
- -
- </p>
+ <p className='text-slate-700 dark:text-gray-50 h-5 w-5 text-center'>
+ -
+ </p>
)}
</td>
))}
@@ -666,32 +673,32 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
</h2>
<div className='flex items-center flex-col md:flex-row justify-between mt-16'>
{_map(t('main.lTestimonials', { returnObjects: true }), (item: {
- name: string;
- role: string;
- desc: string;
- }, index: number) => (
- <div
- key={item.name}
- className={cx('max-w-xs w-full dark:bg-slate-900', {
- 'mt-5 md:mt-0': index > 0,
- })}
- style={{
- boxShadow: '-22px -11px 40px rgba(0, 0, 0, 0.02), 3px -5px 16px rgba(0, 0, 0, 0.02), 17px 24px 20px rgba(0, 0, 0, 0.02)',
- borderRadius: '100px 30px 30px 30px',
- }}
- >
- <Quote theme={theme} color={index === 1 ? 'indigo' : 'black'} className='mx-auto relative -top-4' />
- <div className='px-10 mb-10 max-h-80 overflow-auto'>
- <p className='text-gray-500 text-sm mt-8 dark:text-gray-400'>
- {item.name}
- <br />
- {item.role}
- </p>
- <p className='text-slate-900 dark:text-white text-md text mt-2 leading-9 whitespace-pre-line'>
- {item.desc}
- </p>
- </div>
+ name: string;
+ role: string;
+ desc: string;
+ }, index: number) => (
+ <div
+ key={item.name}
+ className={cx('max-w-xs w-full dark:bg-slate-900', {
+ 'mt-5 md:mt-0': index > 0,
+ })}
+ style={{
+ boxShadow: '-22px -11px 40px rgba(0, 0, 0, 0.02), 3px -5px 16px rgba(0, 0, 0, 0.02), 17px 24px 20px rgba(0, 0, 0, 0.02)',
+ borderRadius: '100px 30px 30px 30px',
+ }}
+ >
+ <Quote theme={theme} color={index === 1 ? 'indigo' : 'black'} className='mx-auto relative -top-4' />
+ <div className='px-10 mb-10 max-h-80 overflow-auto'>
+ <p className='text-gray-500 text-sm mt-8 dark:text-gray-400'>
+ {item.name}
+ <br />
+ {item.role}
+ </p>
+ <p className='text-slate-900 dark:text-white text-md text mt-2 leading-9 whitespace-pre-line'>
+ {item.desc}
+ </p>
</div>
+ </div>
))}
</div>
</div>
@@ -706,7 +713,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
className='aspect-[1097/1023] w-[68.5625rem] bg-gradient-to-r from-[#ff4694] to-[#776fff] opacity-25 dark:opacity-10'
style={{
clipPath:
- 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
+ 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',
}}
/>
</div>
@@ -715,7 +722,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
<div className='max-w-[430px] w-full pt-14 pr-3 mb-16 md:mb-0'>
<h2 className='font-bold text-2xl leading-9 sm:text-4xl sm:leading-[48px] md:text-[28px] md:leading-10 lg:text-[33px] lg:leading-[48px] text-white mb-3'>
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='main.os'
components={{
@@ -760,7 +767,7 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
<div className='max-w-lg w-full lg:ml-5'>
<h2 className='text-3xl md:text-4xl text-slate-900 dark:text-white font-extrabold'>
<Trans
- // @ts-ignore
+ // @ts-ignore
t={t}
i18nKey='main.opensourceAdv'
components={{
@@ -772,14 +779,14 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
<hr className='border-slate-300 dark:border-slate-700 border-1 max-w-[346px] my-6' />
<div className='max-w-md w-full lg:mb-0 mb-9'>
{_map(t('main.opensource', { returnObjects: true }), (item: {
- desc: string
- }) => (
- <p key={item.desc} className='text-slate-700 dark:text-gray-300 text-sm leading-6 flex items-center mb-3'>
- <span>
- <CheckCircleIcon className='w-6 h-6 text-indigo-500 mr-4' />
- </span>
- {item.desc}
- </p>
+ desc: string
+ }) => (
+ <p key={item.desc} className='text-slate-700 dark:text-gray-300 text-sm leading-6 flex items-center mb-3'>
+ <span>
+ <CheckCircleIcon className='w-6 h-6 text-indigo-500 mr-4' />
+ </span>
+ {item.desc}
+ </p>
))}
</div>
</div>
@@ -804,45 +811,57 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
</div>
<div className='flex items-center justify-between mt-20 md:mt-32 md:flex-row flex-col'>
<div className='text-center'>
- <p className='text-indigo-700 text-5xl font-extrabold text-center'>
- {users[0]}
- {users[1] && (
- <span className='text-gray-900 dark:text-indigo-200'>
- {users[1]}
- +
- </span>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {users[0]}
+ {users[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {users[1]}
+ +
+ </span>
+ )}
+ </p>
)}
- </p>
+ </ClientOnly>
<p className='text-gray-600 text-lg dark:text-gray-200'>
{t('main.users')}
</p>
</div>
<div className='bg-gray-800 dark:bg-gray-200 w-2 h-2 rounded-full mx-5 mb-14 mt-16 md:mb-0 md:mt-0' />
<div className='text-center'>
- <p className='text-indigo-700 text-5xl font-extrabold text-center'>
- {websites[0]}
- {websites[1] && (
- <span className='text-gray-900 dark:text-indigo-200'>
- {websites[1]}
- +
- </span>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {websites[0]}
+ {websites[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {websites[1]}
+ +
+ </span>
+ )}
+ </p>
)}
- </p>
+ </ClientOnly>
<p className='text-gray-600 text-lg dark:text-gray-200'>
{t('main.websites')}
</p>
</div>
<div className='bg-gray-800 dark:bg-gray-200 w-2 h-2 rounded-full mx-5 mb-14 mt-16 md:mb-0 md:mt-0' />
<div className='text-center'>
- <p className='text-indigo-700 text-5xl font-extrabold text-center'>
- {events[0]}
- {events[1] && (
- <span className='text-gray-900 dark:text-indigo-200'>
- {events[1]}
- +
- </span>
+ <ClientOnly fallback={<p className='text-indigo-700 text-5xl font-extrabold text-center'>0</p>}>
+ {() => (
+ <p className='text-indigo-700 text-5xl font-extrabold text-center'>
+ {events[0]}
+ {events[1] && (
+ <span className='text-gray-900 dark:text-indigo-200'>
+ {events[1]}
+ +
+ </span>
+ )}
+ </p>
)}
- </p>
+ </ClientOnly>
<p className='text-gray-600 text-lg dark:text-gray-200'>
{t('main.pageviews')}
</p>
diff --git a/app/root.tsx b/app/root.tsx
index 1ac3b8693..9926d027b 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -10,8 +10,9 @@ import {
useLoaderData,
ScrollRestoration,
} from '@remix-run/react'
+import { ClientOnly } from 'remix-utils'
import { store } from 'redux/store'
-import { isDevelopment, whitelist, isBrowser } from 'redux/constants'
+import { whitelist, isBrowser } from 'redux/constants'
import { Provider } from 'react-redux'
import clsx from 'clsx'
import _map from 'lodash/map'
@@ -26,7 +27,7 @@ import { useChangeLanguage } from 'remix-i18next'
import { useTranslation } from 'react-i18next'
import AppWrapper from 'App'
import { detectLanguage } from 'i18n'
-import { detectTheme, getPageMeta } from 'utils/server'
+import { detectTheme, getPageMeta, isAuthenticated } from 'utils/server'
import mainCss from 'styles/index.css'
import tailwindCss from 'styles/tailwind.css'
@@ -98,6 +99,7 @@ export async function loader({ request }: LoaderArgs) {
const { url } = request
const locale = detectLanguage(request)
const theme = detectTheme(request)
+ const isAuthed = isAuthenticated(request)
const REMIX_ENV = {
NODE_ENV: process.env.NODE_ENV,
@@ -111,7 +113,7 @@ export async function loader({ request }: LoaderArgs) {
}
return json({
- locale, url, theme, REMIX_ENV,
+ locale, url, theme, REMIX_ENV, isAuthed,
})
}
@@ -121,7 +123,7 @@ export const handle = {
export default function App() {
const {
- locale, url, theme, REMIX_ENV,
+ locale, url, theme, REMIX_ENV, isAuthed,
} = useLoaderData<typeof loader>()
const { i18n, t } = useTranslation('common')
const { title } = getPageMeta(t, url)
@@ -179,12 +181,25 @@ export default function App() {
>
<Provider store={store}>
<AlertProvider template={AlertTemplate} {...options}>
- <AppWrapper ssrTheme={theme} />
- <ScrollRestoration />
- <Scripts />
- {isDevelopment && <LiveReload />}
+ <AppWrapper
+ ssrTheme={theme}
+ ssrAuthenticated={isAuthed}
+ />
</AlertProvider>
</Provider>
+ <ClientOnly>
+ {() => (
+ <ScrollRestoration />
+ )}
+ </ClientOnly>
+ {/* <ScrollRestoration /> */}
+ <Scripts />
+ {/* <ClientOnly>
+ {() => (
+ <Scripts />
+ )}
+ </ClientOnly> */}
+ <LiveReload />
</body>
</html>
)
diff --git a/app/routes/index.tsx b/app/routes/index.tsx
index 326c1dfb4..fb0d80357 100644
--- a/app/routes/index.tsx
+++ b/app/routes/index.tsx
@@ -4,7 +4,7 @@ import { useLoaderData } from '@remix-run/react'
import { json } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
-import { detectTheme } from 'utils/server'
+import { detectTheme, isAuthenticated } from 'utils/server'
export const sitemap: SitemapFunction = () => ({
priority: 1,
@@ -12,14 +12,15 @@ export const sitemap: SitemapFunction = () => ({
export async function loader({ request }: LoaderArgs) {
const theme = detectTheme(request)
+ const isAuth = isAuthenticated(request)
- return json({ theme })
+ return json({ theme, isAuth })
}
export default function Index() {
const {
- theme,
+ theme, isAuth,
} = useLoaderData<typeof loader>()
- return <MainPage ssrTheme={theme} />
+ return <MainPage ssrTheme={theme} ssrAuthenticated={isAuth} />
}
diff --git a/app/utils/server.ts b/app/utils/server.ts
index 000c9abe6..217a8d6bc 100644
--- a/app/utils/server.ts
+++ b/app/utils/server.ts
@@ -20,6 +20,13 @@ export function detectTheme(request: Request): 'dark' | 'light' {
return 'light'
}
+export function isAuthenticated(request: Request): boolean {
+ const cookie = request.headers.get('Cookie')
+ const accessToken = cookie?.match(/(?<=access_token=)[^;]*/)?.[0]
+
+ return !!accessToken
+}
+
interface IPageMeta {
title: string
}