added delete

This commit is contained in:
j.mei7
2022-04-03 20:23:26 +02:00
parent 7442a26d9f
commit 48082e2ed9
4 changed files with 42 additions and 11 deletions

Binary file not shown.

View File

@@ -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,8 +44,12 @@ function Idea({ideaId, title, description, timestamp}){
<div className={`idea ${parseInt(params.ideaId) === ideaId ? "current" : ""}`}>
<p className="title">{t}</p>
<p className="description">{d}</p>
<div className="right">
<p className="delete" onClick={deleteIdea}>Delete</p>
<p className="timestamp">{timestamp}</p>
</div>
</div>
</Link>
)
}

View File

@@ -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() => {

View File

@@ -101,13 +101,35 @@
overflow: hidden;
}
.timestamp{
.right{
float: right;
.timestamp{
width: 60px;
margin-top: 10px;
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{