Skip to content

Commit

Permalink
refactor(item-card): remove capacity and only show full capacity chip
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiaMontazeri committed Nov 30, 2023
1 parent afe2046 commit 5745ccc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/components/item-card/item-card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const Cost = ({ cost }) => (
</Stack>
);

const CapacityChip = ({ capacity, isFull, remainingCapacity }) => (
const FullCapacityChip = () => (
<Chip
color={isFull ? 'error' : 'success'}
color="error"
size="small"
label={isFull ? 'Capacity Full' : `Capacity ${remainingCapacity}/${capacity}`}
label="Capacity Full!"
sx={{
mt: 1,
}}
Expand Down Expand Up @@ -71,6 +71,7 @@ const ItemCard = ({
}) => {
const [moreInfoModalVisibility, setMoreInfoModalVisibility] = useState(false);
const hasBought = purchaseState === 2;
const shouldShowFullCapacity = isFull || remainingCapacity === 0;

const handleClickOnMoreInfo = () => {
setMoreInfoModalVisibility(true);
Expand Down Expand Up @@ -154,7 +155,7 @@ const ItemCard = ({
<Presenter presenterName={presenterName} />
{levelComponentMapping[level]}
{!hasBought && <Cost cost={cost} />}
{!hasBought && <CapacityChip isFull={isFull} remainingCapacity={remainingCapacity} capacity={capacity} />}
{!hasBought && shouldShowFullCapacity && <FullCapacityChip />}
</CardContent>
<CardActions
sx={{
Expand Down

0 comments on commit 5745ccc

Please sign in to comment.