Commit 389f2ee3 authored by zarina's avatar zarina 🌊

#6, добавлена возможность удаления цитат

parent 0674d7b8
......@@ -9,7 +9,7 @@ const Quote = props => {
<CardBody>
<CardTitle className='text-uppercase font-weight-bold'>{props.author}</CardTitle>
<CardText>{props.text}</CardText>
<Button className='mr-3' color='danger'>Delete</Button>
<Button onClick={props.delete} className='mr-3' color='danger'>Delete</Button>
<Button color='info'>Edit</Button>
</CardBody>
<CardFooter className='text-muted'>{props.category}</CardFooter>
......
......@@ -22,16 +22,31 @@ const Quotes = props => {
, [props.match.params.category]);
const deleteQuote = (id) => {
axios.delete(`/quotes/${id}.json`)
.then(() => {
let allQuotes = {...quotes};
delete allQuotes[id];
setQuotes(allQuotes)
})
}
const printQuotes = () => {
return Object.keys(quotes).map(quote => {
return <Quote author={quotes[quote].author}
text={quotes[quote].text}
category={quotes[quote].category}
key={quote}
delete={() => deleteQuote(quote)}
/>
})
};
return (
<div className='Quotes'>
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment