generated from Code-the-Dream-School/react-node-practicum-front-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Code-the-Dream-School/farkhondeh-dev1
Farkhondeh dev1
- Loading branch information
Showing
13 changed files
with
289 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import styles from './AlarmButton.module.css'; | ||
|
||
export default function AlarmButton({ message, imagepath, filterTitle, filterData, targetPage }) { | ||
const Navigate = useNavigate(); | ||
|
||
function loadingPage() { | ||
console.log(filterData); | ||
Navigate(`/${targetPage}`, { state: { filterTitle, filterData } }); | ||
} | ||
|
||
return ( | ||
<div className={styles.alarmitem}> | ||
<img | ||
src={imagepath} | ||
alt={filterTitle} | ||
className={styles.alarmicon} | ||
onClick={loadingPage} | ||
/> | ||
<span className={styles.alarmtext} onClick={loadingPage}> | ||
{message} | ||
</span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
.alarmcontainer { | ||
margin-left: 30%; | ||
margin-right: 30%; | ||
display: flex; | ||
justify-content: space-around; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 40%; | ||
padding: 20px; | ||
background-color: #f8f9fa; | ||
} | ||
/* Individual alert item */ | ||
.alarmitem { | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
width: 100%; | ||
background-color: #ffffff; | ||
border: 1px solid #ccc; | ||
border-radius: 10px; | ||
padding: 15px; | ||
margin-bottom: 10px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
/* Styling the icons */ | ||
.alarmicon { | ||
width: 40px; | ||
height: 40px; | ||
margin-right: 15px; /* Space between the icon and the text */ | ||
} | ||
|
||
/* Styling the text */ | ||
.alerttext { | ||
font-size: 1rem; | ||
font-weight: 500; | ||
color: #333; | ||
cursor: grab; | ||
} | ||
|
||
/* Button hover effects */ | ||
.alertitem:hover { | ||
background-color: #e9ecef; | ||
cursor: grab; | ||
} | ||
|
||
/* Responsive design */ | ||
@media (max-width: 768px) { | ||
.alert-icon { | ||
width: 30px; /* Smaller icon size for mobile */ | ||
height: 30px; | ||
} | ||
|
||
.alert-text { | ||
font-size: 0.9rem; /* Adjust font size for smaller screens */ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import Alarmbutton from './AlarmButton.jsx'; | ||
import { useEffect, useState } from 'react'; | ||
import { drugData } from '../../data.js'; | ||
import styles from './AlarmButton.module.css'; | ||
|
||
export default function Alarms() { | ||
//const [rowData, setRowdata] = useState([]); | ||
|
||
const [lowStockData, setLowStockData] = useState([]); | ||
const [noStockData, setnoStockData] = useState([]); | ||
const [expiringsoonData, setExpiringData] = useState([]); | ||
|
||
useEffect(() => { | ||
const drugsData = drugData.filter((drug) => drug.class); | ||
const lowStockFilter = drugsData.filter((drug) => { | ||
return parseInt(drug.quantity) !== 0 && drug.quantity <= drug.threshold; | ||
}); | ||
|
||
setLowStockData(lowStockFilter); // Data drugs matching LowStuck | ||
|
||
const noStockFilter = drugsData.filter((drug) => parseInt(drug.quantity) === 0); | ||
setnoStockData(noStockFilter); // Data drugs matching no Stock | ||
|
||
const expirationDateData = drugsData.filter((drug) => { | ||
const expirationDate = new Date(drug.expiration); | ||
const today = new Date(); | ||
|
||
return expirationDate - today < 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds | ||
}); | ||
|
||
setExpiringData(expirationDateData); //Data for Date checking | ||
}, []); // Dependencies | ||
|
||
return ( | ||
<> | ||
<h3></h3> | ||
<div className={styles.alarmcontainer}> | ||
<Alarmbutton | ||
message={`Low Stock on ${lowStockData.length} products`} | ||
imagepath="../images/low-stock.png" | ||
filterTitle="LowStock" | ||
filterData={lowStockData} | ||
targetPage="Medication" | ||
/> | ||
<Alarmbutton | ||
message={`No Stock on ${noStockData.length} products`} | ||
imagepath="../images/out-of-stock.png" | ||
filterTitle="No Stock" | ||
filterData={noStockData} | ||
targetPage="Medication" | ||
/> | ||
<Alarmbutton | ||
message={`Expiration soon on ${expiringsoonData.length} products`} | ||
imagepath="../images/expire-soon.png" | ||
filterTitle="Expire" | ||
filterData={expiringsoonData} | ||
targetPage="Medication" | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//import React, { useState, useEffect } from 'react'; | ||
//import { drugData } from './data.jsx'; // Update path accordingly | ||
|
||
export default function FilterSearch() { | ||
// const [data, setData] = useState([]); | ||
// // const [loading, setLoading] = useState(true); | ||
// // const [error, setError] = useState(null); | ||
|
||
// const fetchData = async () => { | ||
// try { | ||
// const response = await fetch('http://localhost:8000/api/v1/inventory'); | ||
// if (!response.ok) { | ||
// throw new Error('Network response was not ok'); | ||
// } | ||
// const result = await response.json(); | ||
// setData(result); | ||
// } catch (error) { | ||
// setError(error.message); | ||
// } finally { | ||
// setLoading(false); | ||
// } | ||
// } | ||
|
||
const HandelSearch = () => { | ||
//if() | ||
//data.filter() | ||
}; | ||
const HandelCancel = () => {}; | ||
|
||
// const [filteredDrugs, setFilteredDrugs] = useState([]); | ||
// useEffect(() => { | ||
// // Filter the data for a specific class | ||
// let DrugData = drugData.filter((drug) => drug.class === 'DrugData'); | ||
// if (filter) Drugdata= drugData.filter((drug)=> d) | ||
// setFilteredDrugs(DrugData); // Set filtered data in the state | ||
// }, []); | ||
return ( | ||
<> | ||
<div> | ||
<label htmlFor="drugname">Drug Name: </label> | ||
<input name="drugname" /> | ||
</div> | ||
<div> | ||
<label htmlFor="batchCode">BatchCode: </label> | ||
<input name="batchCode" /> | ||
</div> | ||
<div> | ||
<label htmlFor="ExpirationdateFrom">Expirationdate From: </label> | ||
<input name="ExpirationdateFrom" /> | ||
<label htmlFor="Expirationdateto">Expirationdate To: </label> | ||
<input name="Expirationdateto" /> | ||
</div> | ||
<div> | ||
<label htmlFor="type">Type of Drug:</label> | ||
<input name="type" /> | ||
</div> | ||
<div> | ||
<button onClick={HandelSearch}>Search</button> | ||
<button onClick={HandelCancel}>Cancel</button> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import FilterSearch from './FilterSearch'; | ||
|
||
export default function Medication() { | ||
const location = useLocation(); | ||
const { filterTitle, filterData } = location.state || {}; // Safeguard for missing state | ||
|
||
console.log(location); | ||
console.log('Filter Title:', filterTitle); | ||
console.log('Filter Data:', filterData); | ||
|
||
if (!filterData) { | ||
return <p>No data available</p>; | ||
} | ||
|
||
const [searchsection, setsearchsection] = useState(false); | ||
const toggleSearch = () => { | ||
setsearchsection((prevState) => !prevState); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<button onClick={toggleSearch}>Filter and search</button> | ||
{searchsection && ( | ||
<div> | ||
<FilterSearch /> | ||
</div> | ||
)} | ||
</div> | ||
<h1>{filterTitle}</h1> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Generic</th> | ||
<th>Class</th> | ||
<th>Quantity</th> | ||
<th>Threshold</th> | ||
<th>Expiration</th> | ||
<th>Batch</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{filterData.map((drug) => ( | ||
<tr key={drug.id}> | ||
<td>{drug.name}</td> | ||
<td>{drug.generic}</td> | ||
<td>{drug.class}</td> | ||
<td>{drug.quantity}</td> | ||
<td>{drug.threshold}</td> | ||
<td>{drug.expiration}</td> | ||
<td>{drug.batch}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.