import styles from '../Notes.module.scss' import React, {useState, useEffect, useRef} from 'react' import useUser from 'lib/useUser' import useNotes from '../hooks/useNotes' import useSort from '../hooks/useSort' import {Layout} from 'components' import ListItem from './ListItem' import Actions from './Actions' import Splash from './Splash' const List = () => { const [fetchedNote, setFetchedNote] = useState() const [action, setAction] = useState('') const {notes, error} = useNotes() const [sortedBy, sortBy, sortFn] = useSort(2) const {user, mutateUser} = useUser({ redirectToLogin: true, redirectToVerify: true, }) if (error) return if (!user || !user.isLoggedIn || !user.isVerified || !notes || !sortFn) { return } return ( <> { action === '' ? ( <>
setAction('addNote')}>New note
setAction('importNote')}>Import
{}}>Export
{ notes.length > 0 ? (notes.sort(sortFn).map(note => ( ))) : ( )}
sortBy(1)}>Title {sortedBy(1)} sortBy(2)}>Created {sortedBy(2)} sortBy(3)}>Modified {sortedBy(3)}
Your notes list is empty.
) : ( ) } ) } export default List