I want to add a hidden notes funcionality in which when i click the hide note button the note should be removed from that place and get added to hidden notes, and when i click on hidden notes i should see them, and even get the option to unhide it, Please help,
Here is the webpage i currently have done(The button for hidden notes is in the all Notes dropdown):
(https://i.stack.imgur.com/Pm3Dx.png)
(https://i.stack.imgur.com/rr5OL.png)
(https://i.stack.imgur.com/TEY07.png)
(https://i.stack.imgur.com/wzKN8.png)
Here is the code for the notes app done till now – (drive File), (without node_modules as it is very heavy):
this is app.js:
import './App.css';
import {
BrowserRouter as Router,
Routes,
Route,
Link
} from "react-router-dom";
import Navbar from './components/Navbar';
import Home from './components/Home';
import AddNote from "./components/AddNote"
import About from './components/About';
import NoteState from './context/notes/NoteState';
import Alert from './components/Alert';
import Footer from './components/Footer';
import DropDown from './components/DropDown';
function App() {
return (
<>
<NoteState>
<Router>
<Navbar />
<DropDown></DropDown>
<div className="container">
<Routes>
<Route exact path="/" element={<Home />} />
<Route exact path="/about" element={<About />} />
<Route exact path="/addnote" element={<AddNote/>} />
</Routes>
</div>
<Alert message="This is amazing React course" />
<Footer></Footer>
</Router>
</NoteState>
</>
);
}
export default App;
Please Help
2
Answers
It depends how you want to save the data, I would normally write the logic like this:
There are more ways to do this too
Create a table named "notes"
1.1. The table should have a field named "isVisible". The data type of this field will be boolean and by default the value is set to true.
Create an API to change the visibility of the note, the method should be "PATCH".
Create an API to fetch the list of all the notes. In request parameters you have to add one parameter i.e.,isVisible and based on the value of the parameter the API will return the data.
For example if you want to show all the hidden notes then your backend URL will look like http://localhost:3000/api/notes?isVisible=false