From 0ca0629a14515891193a2e9c11d6e71f5e859896 Mon Sep 17 00:00:00 2001 From: Tapas Adhikary Date: Sat, 5 Dec 2020 09:32:02 +0530 Subject: [PATCH] Not allowing to delete shopnote and items from the demo branch --- README.md | 2 +- src/components/item.js | 18 ++++++++++++++++-- src/components/note.js | 21 +++++++++++++++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9d558fc..7eda529 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ You should have the application launched @ http://localhost:8888 [![Netlify Status](https://api.netlify.com/api/v1/badges/9cdee8a1-a2de-4571-8733-760258100fae/deploy-status)](https://app.netlify.com/sites/shopnote/deploys) # Step-by-step approach -A Step by Step guide to build `shopnote` kind of application is coming soon. Please stay tuned. +[A Step by Step guide](https://css-tricks.com/how-to-create-a-client-serverless-jamstack-app-using-netlify-gatsby-and-fauna/) to build `shopnote` like application. # Important Links - [Netlify Functions](https://www.netlify.com/products/functions/) diff --git a/src/components/item.js b/src/components/item.js index 206fe6f..455a37a 100644 --- a/src/components/item.js +++ b/src/components/item.js @@ -1,8 +1,9 @@ import React, { useState } from 'react'; import { PlusCircle, XCircle, Save, Trash2 } from 'react-feather'; +import Alert from 'react-bootstrap/Alert'; const Item = props => { - + const [show, setShow] = useState(false); const [item, setItem] = useState(props.data); const [name, setName] = useState(item.name); @@ -11,6 +12,19 @@ const Item = props => { setItem(changed); } + if (show) { + return ( + setShow(false)} dismissible> + I get that! You are trying to delete an Item. +

+ This is running from the demo branch where the delete capability is not + available. You can checkout the master branch and run the app locally + by following the instractions. You get to do All there! +

+
+ ); + } + return ( <> { @@ -63,7 +77,7 @@ const Item = props => { - props.deleteItem(item['_id'])}> + setShow(true)}> diff --git a/src/components/note.js b/src/components/note.js index 232b0a2..99e943a 100644 --- a/src/components/note.js +++ b/src/components/note.js @@ -5,9 +5,12 @@ import { generate } from 'shortid'; import { ShoppingBag, X } from 'react-feather'; import Item from './item'; +import Alert from 'react-bootstrap/Alert'; + import moment from 'moment'; const Note = props => { + const [show, setShow] = useState(false); const shopnote = props.data; const sortedByChecked = shopnote.items.data.sort((a,b) => a.checked - b.checked); const [items, setItems] = useState(sortedByChecked); @@ -138,7 +141,18 @@ const Note = props => { return remainingItems; } - + if (show) { + return ( + setShow(false)} dismissible> + I get that! You are trying to delete a Note +

+ This is running from the demo branch where the delete capability is not + available. You can checkout the master branch and run the app locally + by following the instractions. You get to do all there! +

+
+ ); + } return ( @@ -147,10 +161,9 @@ const Note = props => { { shopnote.name } - {/* - props.deleteNote(shopnote["_id"])}/> + + setShow(true)}/> - */} { shopnote.description }