diff --git a/package.json b/package.json index 7ad0538..86dfb1a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "cra-template": "1.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-scripts": "5.0.1" + "react-scripts": "5.0.1", + "uuidv4": "^6.2.13", + "web-vitals": "^2.1.4" }, "scripts": { "start": "react-scripts start", diff --git a/src/App.css b/src/App.css index 74b5e05..5b2b874 100644 --- a/src/App.css +++ b/src/App.css @@ -2,37 +2,34 @@ text-align: center; } -.App-logo { - height: 40vmin; - pointer-events: none; +table { + border: 2px solid rgb(34, 124, 177); + width: 800px; + height: 200px; + position: relative; + left: 20px; + top: 100px; } - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } + +th { + border-bottom: 1px solid black; } - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; + +td { + text-align: center; } - -.App-link { - color: #61dafb; +form{ + position: relative; + top: 82px; + left: -137px; } +.search{ + position: relative; + top: 87px; + left: -216px; + width: 465px; -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } } +input{ + margin:5px ; +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index 4d333f8..ebfb065 100644 --- a/src/App.js +++ b/src/App.js @@ -1,14 +1,104 @@ +import logo from './logo.svg'; import './App.css'; +import { useState } from 'react'; +import PatientForm from './components/PatientForm'; +import PatientDet from './components/PatientDet'; + + + +function App() { + const [patients, setPatients] = useState([ + { + id:1, + full_name:"Ali Ahmed", + birth_date:"10/10/1999", + gender:"m", + phone:"+96477889654" + }, + { + id:2, + full_name:"Ameer Saad", + birth_date:"10/10/2000", + gender:"m", + phone:"+96477809654" + }, + { + id:3, + full_name:"Muna Ali", + birth_date:"10/10/1998", + gender:"f", + phone:"+964777809654" + } + ]) + +const [filteredList, setFilteredList] = useState(patients); + +const addPatient=(patient)=>{ + setPatients([...patients, patient]) + setFilteredList([...patients, patient]) + console.log(patients) +} + +const onDelete =(id)=>{ + const delP = patients.filter(p=> p.id !== id) + const delF = filteredList.filter(p=> p.id !== id) + setFilteredList(delF) + setPatients(delP) +} + + + + const filterBySearch = (event) => { + + const pcopy = patients + console.log(pcopy) + const query = event.target.value; + + var updatedList = [...patients]; + updatedList = updatedList.filter((item) => { + return item.full_name.toLowerCase().indexOf(query.toLowerCase()) !== -1; + }); + + if(query){ + setPatients(updatedList); + } + else{ + setPatients(filteredList) + } + + }; -const App = ()=>{ - // State here return (
| Full Name | +Birth-Date | +Gender | +Phone | ++ |
|---|