import styles from '../Notes.module.scss' import React from 'react' import {getNote, exportNote, removeNote} from '../helpers/noteActions.js' import useSettings from 'hooks/useSettings' import usePopup from 'hooks/usePopup' import useNotes from '../hooks/useNotes' import {faEdit, faDownload, faTrash } from '@fortawesome/free-solid-svg-icons' import {FontAwesomeIcon} from '@fortawesome/react-fontawesome' const datestring = date => { const d = new Date(date); return ("0" + d.getDate()).slice(-2) + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + d.getFullYear() + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) }; const ListItem = ({note, setAction, setFetchedNote, setLoading}) => { const {t} = useSettings() const {setPopup} = usePopup() const {mutateNotes} = useNotes() const handleNoteAction = async (a, note, e) => { if (e) e.stopPropagation() setLoading(true) await getNote(note, setFetchedNote, t, setPopup, () => setAction(a)) } return ( handleNoteAction('showNote', note)} > {`${note.title}`} handleNoteAction('editNote', note, e)}> {e.stopPropagation(); exportNote(note)}}> removeNote(e, note._id, mutateNotes, t, setPopup, setAction)}> {datestring(note.created_at)} {datestring(note.updated_at)} ) } export default ListItem