aboutsummaryrefslogtreecommitdiffstats
path: root/apps/Notes/components/List.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
commit569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a (patch)
tree8d1cb94a56d60b9d726222277b7516fc59895613 /apps/Notes/components/List.js
parent275bd1d0a9aea90696c145cf992d522a0d6b0aa8 (diff)
downloadmy_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.gz
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.bz2
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.zip
added stadard linter
Diffstat (limited to 'apps/Notes/components/List.js')
-rw-r--r--apps/Notes/components/List.js96
1 files changed, 50 insertions, 46 deletions
diff --git a/apps/Notes/components/List.js b/apps/Notes/components/List.js
index 238e305..05d0711 100644
--- a/apps/Notes/components/List.js
+++ b/apps/Notes/components/List.js
@@ -1,24 +1,24 @@
import styles from '../styles/Notes.module.scss'
-import React, {useState, useEffect} from 'react'
+import React, { useState, useEffect } from 'react'
import useUser from 'hooks/useUser'
import useSettings from 'hooks/useSettings'
import useNotes from '../hooks/useNotes'
import useSort from '../hooks/useSort'
import ListItem from './ListItem'
import Actions from './Actions'
-import {Splash} from 'components'
+import { Splash } from 'components'
const List = () => {
const [fetchedNote, setFetchedNote] = useState()
const [action, setAction] = useState('')
const [loading, setLoading] = useState(false)
const [showSort, setShowSort] = useState(false)
- const {notes, error} = useNotes()
+ const { notes, error } = useNotes()
const [sortedBy, sortBy, sortFn] = useSort(3)
- const {t} = useSettings()
- const {user} = useUser({
+ const { t } = useSettings()
+ const { user } = useUser({
redirectToLogin: true,
- redirectToVerify: true,
+ redirectToVerify: true
})
useEffect(() => {
@@ -32,33 +32,34 @@ const List = () => {
}
return (
- action === '' ? (
- <>
- <div className='window__submenu'>
- <div>
- <div onClick={() => setAction('addNote')}>{t('notes_new')}</div>
- <div className='mobile-only' onClick={() => {setShowSort(s => !s)}}>{t('sort')}</div>
- <div onClick={() => setAction('importNotes')}>{t('import')}</div>
- <div onClick={() => setAction('exportNotes')}>{t('export')}</div>
+ action === ''
+ ? (
+ <>
+ <div className='window__submenu'>
+ <div>
+ <div onClick={() => setAction('addNote')}>{t('notes_new')}</div>
+ <div className='mobile-only' onClick={() => { setShowSort(s => !s) }}>{t('sort')}</div>
+ <div onClick={() => setAction('importNotes')}>{t('import')}</div>
+ <div onClick={() => setAction('exportNotes')}>{t('export')}</div>
+ </div>
</div>
- </div>
- <div className='window__scroll'>
- <table className={styles.notesList}>
- <thead className={showSort ? styles.mobileSort : 'desktop-only'}>
- <tr className="mobile-only">
- <th>{t('sort_by')}</th>
- </tr>
- <tr>
- <th onClick={() => sortBy(1)}>{t('title')} {sortedBy(1)}</th>
- <th onClick={() => sortBy(2)}>{t('created')} {sortedBy(2)}</th>
- <th onClick={() => sortBy(3)}>{t('modified')} {sortedBy(3)}</th>
- </tr>
- <tr className='mobile-only'>
- <td className='window__button' onClick={() => setShowSort(false)}>{t('close')}</td>
- </tr>
- </thead>
- <tbody>
- {
+ <div className='window__scroll'>
+ <table className={styles.notesList}>
+ <thead className={showSort ? styles.mobileSort : 'desktop-only'}>
+ <tr className='mobile-only'>
+ <th>{t('sort_by')}</th>
+ </tr>
+ <tr>
+ <th onClick={() => sortBy(1)}>{t('title')} {sortedBy(1)}</th>
+ <th onClick={() => sortBy(2)}>{t('created')} {sortedBy(2)}</th>
+ <th onClick={() => sortBy(3)}>{t('modified')} {sortedBy(3)}</th>
+ </tr>
+ <tr className='mobile-only'>
+ <td className='window__button' onClick={() => setShowSort(false)}>{t('close')}</td>
+ </tr>
+ </thead>
+ <tbody>
+ {
notes.length > 0
? (notes.sort(sortFn).map(note => (
<ListItem
@@ -68,23 +69,26 @@ const List = () => {
setFetchedNote={setFetchedNote}
setLoading={setLoading}
/>
- ))) : (
+ )))
+ : (
<tr>
<td>{t('notes_list_empty')}</td>
</tr>
- )}
- </tbody>
- </table>
- </div>
- </>
- ) : (
- <Actions
- action={action}
- setAction={setAction}
- fetchedNote={fetchedNote}
- setFetchedNote={setFetchedNote}
- />
- )
+ )
+}
+ </tbody>
+ </table>
+ </div>
+ </>
+ )
+ : (
+ <Actions
+ action={action}
+ setAction={setAction}
+ fetchedNote={fetchedNote}
+ setFetchedNote={setFetchedNote}
+ />
+ )
)
}