This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import './App.css'; | |
import { getAllNotes, deleteNote, editNote } from './api' | |
import { NoteList, NoteForm } from './components' | |
function App() { | |
const [notes, setNotes] = useState([]) | |
useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NoteList from './NoteList' | |
import NoteForm from './NoteForm' | |
export { NoteList, NoteForm } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NoteForm = ({ form, notes, setNotes }) => { | |
const { getFieldDecorator, validateFields, resetFields } = form; | |
function handleSubmit(e) { | |
e.preventDefault(); | |
validateFields((err, values) => { | |
if (!err && values.note) { | |
createNote(values.note).then(res => { | |
const newNotesArray = notes.concat([res]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.App { | |
text-align: center; | |
min-height: 100vh; | |
display: flex; | |
margin: 75px 0 25px; | |
flex-direction: flex-start; | |
align-items: flex-start; | |
justify-content: center; | |
font-size: calc(10px + 2vmin); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Form, Button, Input } from 'antd'; | |
import { createNote } from '../api' | |
const NoteForm = ({ form, notes, setNotes }) => { | |
const { getFieldDecorator, validateFields, resetFields } = form; | |
function handleSubmit(e) { | |
e.preventDefault(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import './App.css'; | |
import { getAllNotes, deleteNote, editNote } from './api' | |
function App() { | |
const [notes, setNotes] = useState([]) | |
useEffect(() => { | |
getAllNotes.then(res => setNotes(res)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import './App.css'; | |
import { getAllNotes, deleteNote, editNote } from './api' | |
function App( ) { | |
const [notes, setNotes] = useState([]) | |
useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getAllNotes from './getAllNotes' | |
import createNote from './createNote' | |
import deleteNote from './deleteNote' | |
import editNote from './editNote'; | |
export { getAllNotes, createNote, deleteNote, editNote } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { client, q } from '../config/db' | |
const createNote = text => client.query( | |
q.Create( | |
q.Collection('notes'), | |
{ | |
data: { | |
text | |
}, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { client, q } from '../config/db' | |
const createNote = text => client.query( | |
q.Create( | |
q.Collection('notes'), | |
{ | |
data: { | |
text | |
}, | |
}, |