Skip to content
Open
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
16 changes: 16 additions & 0 deletions frontend/src/components/Chip.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add docstring

export default function Chip(props) {
const { label } = props;
Comment on lines +4 to +5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export default function Chip(props) {
const { label } = props;
export default function Chip({ label }) {


return (
<span className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">
{label}
</span>
);
}

Chip.propTypes = {
label: PropTypes.string.isRequired,
};
37 changes: 15 additions & 22 deletions frontend/src/components/Package.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import Chip from './Chip';

export default function Package(props) {
const { data, showRequest } = props;
Expand Down Expand Up @@ -29,30 +30,22 @@ export default function Package(props) {
</span>
</div>
</div>
{showRequest ? (
{
<div className="flex items-center px-6 py-4 justify-end">
<span className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">
{data.quantityAvailable ?? '0'}
{' available'}
</span>
<Link to={`request/${data._id}`}>
<button
type="button"
className="bg-primary hover:bg-accent-blue text-black font-bold py-2 px-4 rounded"
>
{/* TODO: Disable button if quantityAvailable < 1 */}
Request
</button>
</Link>
</div>
) : (
<div className="flex items-center px-6 py-4 justify-end">
<span className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">
{data.requests ? data.requests.length : '0'}
{' requested'}
</span>
<Chip label={`${data.quantityAvailable ?? '0'} available`} />
{showRequest && (
<Link to={`request/${data._id}`}>
<button
type="button"
className="bg-primary hover:bg-accent-blue text-black font-bold py-2 px-4 rounded"
>
{/* TODO: Disable button if quantityAvailable < 1 */}
Request
</button>
</Link>
)}
</div>
)}
}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/PackageGenerator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function PackageGenerator(props) {
...item,
key: index,
}));
dataWithKey.filter((item) => item.fulfilled === 0);
setRequestData(dataWithKey);
});
}, []);
Expand Down