Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enums properly defined and nothing broke #16

Merged
merged 5 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions client-app/src/Components/DonatedItemsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link, useNavigate } from 'react-router-dom';
import { FaSearch, FaPlus } from 'react-icons/fa';
import Barcode from 'react-barcode';
import Modal from 'react-modal';
import ItemStatus from '../constants/Enums.js';
import '../css/AdminHeader.css';
import '../css/DonatedItemsList.css';
import html2canvas from 'html2canvas';
Expand All @@ -25,7 +26,7 @@ function DonatedItemsList() {
item.donor.toLowerCase().includes(searchInput.toLowerCase()) ||
item.date.includes(searchInput) ||
item.program.toLowerCase().includes(searchInput.toLowerCase()) ||
item.status.toLowerCase().includes(searchInput.toLowerCase())
Object.values(ItemStatus).includes(item.status) && item.status.toLowerCase().includes(searchInput.toLowerCase())
);
setFilteredItems(filtered);
};
Expand Down Expand Up @@ -95,11 +96,11 @@ function DonatedItemsList() {

// Sample data for demonstration
const [donatedItems, setDonatedItems] = useState([
{ id: 811253, name: 'Bicycle', donor: 'Mary', date: '2024-02-25', program: 'Not Assigned', status: 'Donated' },
{ id: 811249, name: 'Computer', donor: 'James', date: '2024-02-06', program: 'Not Assigned', status: 'In Storage Facility' },
{ id: 811247, name: 'Computer', donor: 'Vivian', date: '2024-01-26', program: 'Not Assigned', status: 'Refurbished' },
{ id: 811246, name: 'Bicycle', donor: 'Elizabeth', date: '2024-01-21', program: 'Not Assigned', status: 'Item Sold' },
{ id: 811240, name: 'Bicycle', donor: 'Peter', date: '2024-01-13', program: 'Not Assigned', status: 'Received' }
{ id: 811253, name: 'Bicycle', donor: 'Mary', date: '2024-02-25', program: 'Not Assigned', status: ItemStatus.DONATED },
truffer11 marked this conversation as resolved.
Show resolved Hide resolved
{ id: 811249, name: 'Computer', donor: 'James', date: '2024-02-06', program: 'Not Assigned', status: ItemStatus.IN_STORAGE },
{ id: 811247, name: 'Computer', donor: 'Vivian', date: '2024-01-26', program: 'Not Assigned', status: ItemStatus.REFURBISHED },
{ id: 811246, name: 'Bicycle', donor: 'Elizabeth', date: '2024-01-21', program: 'Not Assigned', status: ItemStatus.SOLD },
{ id: 811240, name: 'Bicycle', donor: 'Peter', date: '2024-01-13', program: 'Not Assigned', status: ItemStatus.RECEIVED }
// Add more items here...
]);
const downloadBarcode = (id) => {
Expand Down Expand Up @@ -173,11 +174,11 @@ function DonatedItemsList() {
<option value="" disabled selected>
Filter by Status
</option>
<option value="Donated">Donated</option>
<option value="In Storage Facility">In Storage Facility</option>
<option value="Refurbished">Refurbished</option>
<option value="Received">Received</option>
<option value="Item Sold">Item Sold</option>
<option value={ItemStatus.DONATED}>Donated</option>
truffer11 marked this conversation as resolved.
Show resolved Hide resolved
<option value={ItemStatus.IN_STORAGE}>In Storage Facility</option>
<option value={ItemStatus.REFURBISHED}>Refurbished</option>
<option value={ItemStatus.RECEIVED}>Received</option>
<option value={ItemStatus.SOLD}>Item Sold</option>
</select>
</div>
</div>
Expand Down
11 changes: 6 additions & 5 deletions client-app/src/Components/StatusDisplayPage.js
truffer11 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import ItemStatus from '../constants/Enums';
import '../css/StatusDisplayPage.css';

const StatusDisplayPage = () => {
Expand Down Expand Up @@ -103,7 +104,7 @@ const StatusDisplayPage = () => {
checked={donorInfo.status.donated}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@truffer11 You can replace with enums in this file also.

onChange={handleCheckboxChange}
/>
Donated
{ItemStatus.DONATED}
</label>
<br />
<label>
Expand All @@ -113,7 +114,7 @@ const StatusDisplayPage = () => {
checked={donorInfo.status.inStorageFacility}
onChange={handleCheckboxChange}
/>
In Storage Facility
{ItemStatus.IN_STORAGE}
</label>
<br />
<label>
Expand All @@ -123,7 +124,7 @@ const StatusDisplayPage = () => {
checked={donorInfo.status.refurbished}
onChange={handleCheckboxChange}
/>
Refurbished
{ItemStatus.REFURBISHED}
</label>
<br />
<label>
Expand All @@ -133,7 +134,7 @@ const StatusDisplayPage = () => {
checked={donorInfo.status.received}
onChange={handleCheckboxChange}
/>
Received
{ItemStatus.RECEIVED}
</label>
<br />
<label>
Expand All @@ -143,7 +144,7 @@ const StatusDisplayPage = () => {
checked={donorInfo.status.sold}
onChange={handleCheckboxChange}
/>
Sold
{ItemStatus.SOLD}
</label>
<br></br>
<label>
Expand Down
9 changes: 9 additions & 0 deletions client-app/src/constants/Enums.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const ItemStatus = Object.freeze ({
DONATED: 'Donated',
IN_STORAGE: 'In Storage Facility',
REFURBISHED: 'Refurbished',
SOLD: 'Item Sold',
RECEIVED: 'Received'
});

export default ItemStatus;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@truffer11 Can you please rename the file toEnums.ts. .ts is a typescript extension. Typescript has enum datatype (which is not there in javascript) which is very useful in our case.

truffer11 marked this conversation as resolved.
Show resolved Hide resolved
Loading