import styles from '../styles/Notes.module.scss' 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' const List = () => { const [fetchedNote, setFetchedNote] = useState() const [action, setAction] = useState('') const [loading, setLoading] = useState(false) const {notes, error} = useNotes() const [sortedBy, sortBy, sortFn] = useSort(3) const {t} = useSettings() const {user} = useUser({ redirectToLogin: true, redirectToVerify: true, }) useEffect(() => { setLoading(false) }, [fetchedNote]) if (error) return if (loading) return if (!user || !user.isLoggedIn || !user.isVerified || !notes || !sortFn) { return } return ( action === '' ? ( <>
setAction('addNote')}>{t('notes_new')}
setAction('importNotes')}>{t('import')}
setAction('exportNotes')}>{t('export')}
{ notes.length > 0 ? (notes.sort(sortFn).map(note => ( ))) : ( )}
sortBy(1)}>{t('title')} {sortedBy(1)} sortBy(2)}>{t('created')} {sortedBy(2)} sortBy(3)}>{t('modified')} {sortedBy(3)}
{t('notes_list_empty')}
) : ( ) ) } export default List