fix(notes/nui): sending data from NoteList to the modal

This commit is contained in:
chip committed 2020-10-30 00:19:34 +01:00
1 parent 4438ee3302
commit 53ef7d0195
1 file changed
+18 -4
+18 -4
View File
@@ -1,13 +1,27 @@
import { List } from '@material-ui/core';
import React from 'react'
import { NoteItem } from './NoteItem';
import { List, ListItem, ListItemText } from '@material-ui/core';
import React, { useState } from 'react'
import { useNoteModal } from '../hooks/useNoteModal';
import { useNoteDetail } from '../hooks/useNoteDetail';
// add search bar later
const NoteList = ({notes}) => {
const { noteModal, setNoteModal } = useNoteModal();
const { detail, setDetail } = useNoteDetail();
const handleNoteModal = (note) => {
setNoteModal(true)
setDetail(note)
console.log(note.id)
}
return (
<List>
{notes.map((note) => (
<NoteItem key={note.id} {...note} />
<ListItem key={note.id} button divider onClick={() => handleNoteModal(note)}>
<ListItemText><strong>{note.title}</strong></ListItemText>
</ListItem>
))}
</List>
)