This commit is contained in:
ferdzo
2024-04-11 23:04:43 +02:00
parent fbb5265dd0
commit 9556ebef38
6 changed files with 16043 additions and 2376 deletions

View File

@@ -0,0 +1,4 @@
# {{capitalizeAll title}}
{{formatDate date "llll"}}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@ import './App.css';
import NavigationBar from './components/NavigationBar'; import NavigationBar from './components/NavigationBar';
import Table from './components/Table'; import Table from './components/Table';
import MyButton from './components/Btn'; import MyButton from './components/Btn';
import Search from './components/Search';
import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap.css';
@@ -10,6 +11,7 @@ function App() {
return ( return (
<div className="App"> <div className="App">
<NavigationBar/> <NavigationBar/>
<Table/> <Table/>
<MyButton/> <MyButton/>
</div> </div>

View File

@@ -1,9 +1,30 @@
import React from "react"; import React, { useState } from "react";
function Search( props ) {
const [value, setValue] = useState("");
const onChange = (event) => {
setValue(event.target.value);
};
const handleSubmit = (event) => {
event.preventDefault();
props.handleValue(value);
}
function Search(data) {
return ( return (
<div> <div>
<input type="text" placeholder="Search..." /> <form onSubmit={handleSubmit}>
<input
onChange={onChange}
value={value}
type="text"
placeholder="Search..."
/>
<button type="submit">Search</button>
</form>
</div> </div>
); );
} }
export default Search;

View File

@@ -1,21 +1,45 @@
import Row from "./Row"; import Row from "./Row";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import axios from 'axios'; import axios from "axios";
import Search from "./Search";
export default function Table() { export default function Table() {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [filteredData, setFilteredData] = useState([]);
const [searchValue, setSearchValue] = useState("");
useEffect(() => { useEffect(() => {
axios.get('http://localhost:8000/api/').then( axios.get("http://localhost:8000/api/").then((response) => {
(response) => {
setData(response.data); setData(response.data);
}); });
}, []); }, []);
console.log(data);
const Done = data && data.inserts && data.inserts.filter((item) => item.done === true); useEffect(() => {
const NotDone = data && data.inserts && data.inserts.filter((item) => item.done === false); if (searchValue){
debugger;
for (const item in data) {
if (item.name.toLowerCase().includes(searchValue.toLowerCase())){
setFilteredData((prev) => {
return [...prev, item];
});
}
}
}
}, [searchValue, data]);
const Done = data?.inserts?.filter((item) => item.done === true);
const NotDone = data?.inserts?.filter((item) => item.done === false);
var isDone = true; var isDone = true;
const handleValue = (value) => {
setSearchValue(value);
};
return ( return (
<div>
<Search data={data} handleValue={handleValue} />
<table className="table"></table>
<table className="table"> <table className="table">
<thead> <thead>
<tr> <tr>
@@ -28,15 +52,14 @@ export default function Table() {
<th scope="col">Plateno</th> <th scope="col">Plateno</th>
<th scope="col">Note</th> <th scope="col">Note</th>
<th scope="col">Done</th> <th scope="col">Done</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{ isDone {filteredData.map((item) => {
? NotDone && NotDone.map((item) => <Row key={item.id} item={item} />) return <Row key={item.id} item={item} />;
: Done && Done.map((item) => <Row key={item.id} item={item} />) })}
}
</tbody> </tbody>
</table> </table>
</div>
); );
} }