-
Notifications
You must be signed in to change notification settings - Fork 3
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 #321 from NIAEFEUP/feature/disabled-offer-indicator
Show indication that an offer is disabled in the "Offers management" page
- Loading branch information
Showing
6 changed files
with
217 additions
and
68 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
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
64 changes: 64 additions & 0 deletions
64
src/components/Company/Offers/Manage/CompanyOffersTitle.js
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,64 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { Chip, makeStyles } from "@material-ui/core"; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
hiddenChip: { | ||
backgroundColor: "#90A4AE", | ||
marginRight: theme.spacing(.5), | ||
}, | ||
blockedChip: { | ||
backgroundColor: "#DC4338", | ||
marginRight: theme.spacing(.5), | ||
}, | ||
archivedChip: { | ||
backgroundColor: "#56A8D6", | ||
marginRight: theme.spacing(.5), | ||
}, | ||
chips: { | ||
position: "absolute", | ||
}, | ||
})); | ||
|
||
const OfferTitle = ({ title, getOfferVisibility, offerId }) => { | ||
const [chips, setChips] = useState([]); | ||
const isHidden = getOfferVisibility(offerId)?.isHidden; | ||
const isBlocked = getOfferVisibility(offerId)?.isDisabled; | ||
const isArchived = getOfferVisibility(offerId)?.isArchived; | ||
|
||
const classes = useStyles(); | ||
|
||
useEffect(() => { | ||
const statusChips = { | ||
hidden: <Chip size="small" label="Hidden" data-testid="HiddenChip" className={classes.hiddenChip} />, | ||
blocked: <Chip size="small" label="Blocked" data-testid="BlockedChip" className={classes.blockedChip} />, | ||
archived: <Chip size="small" label="Archived" data-testid="ArchivedChip" className={classes.archivedChip} />, | ||
}; | ||
|
||
const tempChips = []; | ||
if (isHidden) | ||
tempChips.push(statusChips.hidden); | ||
if (isBlocked) | ||
tempChips.push(statusChips.blocked); | ||
if (isArchived) | ||
tempChips.push(statusChips.archived); | ||
setChips(tempChips); | ||
}, [classes, isArchived, isBlocked, isHidden]); | ||
|
||
return ( | ||
<> | ||
{title} | ||
<div className={classes.chips}> | ||
{chips} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
OfferTitle.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
getOfferVisibility: PropTypes.func.isRequired, | ||
offerId: PropTypes.number.isRequired, | ||
}; | ||
|
||
export default OfferTitle; |
Oops, something went wrong.