From 48082e2ed9a2af82333ca485d05c653db2701333 Mon Sep 17 00:00:00 2001 From: "j.mei7" Date: Sun, 3 Apr 2022 20:23:26 +0200 Subject: [PATCH] added delete --- express_backend/database.db | Bin 212992 -> 212992 bytes react_frontend/src/Idea.js | 15 +++++++++++- react_frontend/src/IdeaList.js | 4 ---- react_frontend/src/css/IdeaList.scss | 34 ++++++++++++++++++++++----- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/express_backend/database.db b/express_backend/database.db index 96ae0500bcd69689502a197dba8411b466d8c64b..a01aa4bc85e541abfee0ae8cb5e1913fc9e72cbf 100644 GIT binary patch delta 231 zcmZo@;B9E&ogmE^I#I@%F?3_X5`Jc8{^ZT<0(yLtW#lCBVHW;c2C2!6@?vZthOFx3 zi*mw@MsOX;^0JI_lN;rw8HFYX$cazhB5%VeJo%%%FwlYzo7okn@<%Z+Ft7;4iL%C4kFpuKqM{$TB-sD} delta 282 zcmXxaJqp4w7{+m5lQd1+d?DIG)wsAS2yPAq=_Q;5FH#+xmEh*+1*BfYqqsQhi)Q)p z=izA@*);N0LVX^tp}uc#npm}LxtS@N8`|-cai8WogbE=;WFgWJNeJ`{>#IyK=_yI5v#8)pIr2Y5ddpZV^FP8rBEr+EJM>2 gO%hZHG>%cu(I`S0Ln%cGY2R~Uz#gh&1;?uU0gcuqtpET3 diff --git a/react_frontend/src/Idea.js b/react_frontend/src/Idea.js index e89f262..ba27755 100644 --- a/react_frontend/src/Idea.js +++ b/react_frontend/src/Idea.js @@ -7,6 +7,15 @@ function Idea({ideaId, title, description, timestamp}){ let [t, setT] = useState(title); let [d, setD] = useState(description); + + const deleteIdea = async () => { + let data = await fetch('http://localhost:5000/idea/delete/' + ideaId); + const result = await data.json(); + console.log(result) + if(result.title === "Success"){ + window.location.reload(); + } + } const fetchIdea = async () => { const data = await fetch( 'http://localhost:5000/idea/get/' + params.ideaId @@ -35,7 +44,11 @@ function Idea({ideaId, title, description, timestamp}){

{t}

{d}

-

{timestamp}

+
+

Delete

+

{timestamp}

+
+
) diff --git a/react_frontend/src/IdeaList.js b/react_frontend/src/IdeaList.js index 6b19433..ce6bf62 100644 --- a/react_frontend/src/IdeaList.js +++ b/react_frontend/src/IdeaList.js @@ -1,12 +1,8 @@ import React, {useState, useEffect} from 'react'; import Idea from './Idea'; import './css/IdeaList.scss'; -import { useParams} from 'react-router-dom' function IdeaList() { - - let params = useParams() - let selectedIdeaId = params.ideaId; let [ideas, setIdeas] = useState([]); const createIdea = async() => { diff --git a/react_frontend/src/css/IdeaList.scss b/react_frontend/src/css/IdeaList.scss index 3f3d0a1..fc83fa9 100644 --- a/react_frontend/src/css/IdeaList.scss +++ b/react_frontend/src/css/IdeaList.scss @@ -100,14 +100,36 @@ white-space: nowrap; overflow: hidden; } - - .timestamp{ + + .right{ float: right; - width: 60px; - margin-top: 10px; - font-size: 0.7em; - color: rgba(195, 195, 195, 0.572); + + .timestamp{ + + width: 60px; + + font-size: 0.7em; + color: rgba(195, 195, 195, 0.572); + } + + .delete{ + font-size: 11pt; + color: rgb(177, 0, 0); + margin-top: -20px; + padding-bottom: 20px; + text-align: right; + padding-right: 5px; + text-transform: uppercase; + transition: 50ms; + transition-timing-function: linear; + + &:hover{ + text-decoration: underline; + color: rgb(255, 45, 45); + } + } } + } .current{