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!

1.4 KB
Raw Blame
import { useEffect } from 'react'
import type { MetaFunction } from 'react-router'
import { redirect } from 'react-router'
import type { SitemapFunction } from 'remix-sitemap'

import { isSelfhosted } from '~/lib/constants'
import { Text } from '~/ui/Text'
import { getTitle } from '~/utils/seo'

export const sitemap: SitemapFunction = () => ({
  exclude: true,
})

export const meta: MetaFunction = () => [
  ...getTitle('Payment'),
  { name: 'robots', content: 'noindex' },
]

export async function loader() {
  if (isSelfhosted) {
    return redirect('/login', 302)
  }

  return null
}

export default function Index() {
  useEffect(() => {
    if (!window.REMIX_ENV?.PADDLE_CLIENT_SIDE_TOKEN) {
      return
    }

    const initializePaddle = () => {
      if (window.Paddle) {
        window.Paddle.Initialize({
          token: window.REMIX_ENV?.PADDLE_CLIENT_SIDE_TOKEN,
        })
        return true
      }
      return false
    }

    const interval = setInterval(() => {
      if (initializePaddle()) {
        clearInterval(interval)
      }
    }, 500)

    return () => clearInterval(interval)
  }, [])

  return (
    <div className='min-h-page bg-gray-50 dark:bg-slate-950'>
      <div className='mx-auto px-4 pt-12 pb-16 sm:px-6 md:w-4/5 lg:px-8'>
        <Text as='h1' size='4xl' weight='bold'>
          Swetrix Payment
        </Text>
      </div>
    </div>
  )
}