mirror of
https://github.com/DerTyp7/notes-react.git
synced 2025-10-29 12:32:11 +01:00
added delete
This commit is contained in:
Binary file not shown.
@@ -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}){
|
||||
<div className={`idea ${parseInt(params.ideaId) === ideaId ? "current" : ""}`}>
|
||||
<p className="title">{t}</p>
|
||||
<p className="description">{d}</p>
|
||||
<p className="timestamp">{timestamp}</p>
|
||||
<div className="right">
|
||||
<p className="delete" onClick={deleteIdea}>Delete</p>
|
||||
<p className="timestamp">{timestamp}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
|
||||
@@ -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() => {
|
||||
|
||||
@@ -101,13 +101,35 @@
|
||||
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{
|
||||
|
||||
Reference in New Issue
Block a user