aboutsummaryrefslogtreecommitdiffstats
path: root/pages/Notes.js
blob: 5ed91cfe9b856e96ee9485631ea42031666dbba1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import styles from 'styles/Main.module.scss'
import React, { useMemo, Suspense, useEffect } from 'react'
import Head from 'next/head'
import useApps from 'hooks/useApps'
import useSettings from 'hooks/useSettings'
import useUser from 'hooks/useUser'
import { Splash, Popup } from 'components'

const NotesApp = () => {
  const { user } = useUser({
    redirectToLogin: true,
    redirectToVerify: true
  })
  const app = { name: 'Notes', min: false, max: true, height: '48em', width: '64em', pos: [], buttons: [], props: {} }
  const { apps, setApps } = useApps([app])
  const { settings } = useSettings()

  useEffect(() => setApps([app]), [])

  if (!user || !apps || apps.length < 1 || !settings || !settings.theme || !settings.language) return null

  return (
    <>
      <Head>
        <title>My Notes</title>
        <link rel='apple-touch-icon' sizes='180x180' href='/notes/apple-touch-icon.png' />
        <link rel='icon' type='image/png' sizes='32x32' href='/notes/favicon-32x32.png' />
        <link rel='icon' type='image/png' sizes='16x16' href='/notes/favicon-16x16.png' />
        <link rel='manifest' href='/notes/site.webmanifest' />
        <link rel='mask-icon' href='/notes/safari-pinned-tab.svg' color='#ffc40d' />
        <link rel='shortcut icon' href='/notes/favicon.ico' />
        <meta name='msapplication-TileColor' content='#ffc40d' />
        <meta name='msapplication-config' content='/notes/browserconfig.xml' />
        <meta name='theme-color' content='#ffffff' />
      </Head>
      <section className={styles.layout + ' ' + settings.theme}>
        <main className='window__content noHeader'>
          <NotesContainer />
        </main>
        <Popup />
      </section>
    </>
  )
}

const NotesContainer = () => {
  const Notes = React.lazy(() => import('apps/Notes'))

  const Component = useMemo(() => (
    <Suspense fallback={<Splash fixed />}>
      <Notes logout />
    </Suspense>
  ), [])

  return Notes
    ? Component
    : null
}

export default NotesApp