aboutsummaryrefslogtreecommitdiffstats
path: root/pages/index.js
blob: 9df0acf93c586b0a18c4c58b5f8a73a1d99e58d7 (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
61
62
63
64
65
66
67
import React, { useState ,useRef } from 'react'
import useUser from 'lib/useUser'
import {Layout, App} from 'components'
import {open} from 'helpers/windowActions'
import {Notes} from 'apps'

const appList = {
  Notes,
};

const Home = () => {
  const [apps, setApps] = useState([])
  const {mutateUser} = useUser({
    redirectToLogin: true,
    redirectToVerify: true,
    redirectToApps: true,
  })

  return (
    <Layout apps={apps} setApps={setApps}>
      <>
        {
          Object.keys(appList).map(appName => (
            <div key={`${appName}_icon`} onClick={() => open(appName, apps, setApps)}>
              <img src={`./${appName.toLowerCase()}.svg`} alt={`${appName} Icon`} />
              <p>{appName}</p>
            </div>
          ))
        }
        { apps && apps.map(app => {
           const AppName = appList[app.name]

           return (
             <App
               key={`${app.name}_app`}
               app={app}
               apps={apps}
               setApps={setApps}
             >
               <AppName />
             </App>
           );
        })}
        <style jsx>{`
          div {
            text-decoration: none;
            display: inline-block;
            width: 4em;
            cursor: pointer;
          }

          img {
            width: 4em;
          }

          p {
            padding-top: .5em;
            text-align: center;
            color: #333;
          }
        `}</style>
      </>
    </Layout>
  )
}

export default Home