Skip to content

Commit

Permalink
feat: icon displays properly when the product is mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Apr 8, 2021
1 parent fe11950 commit daa56cd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/containers/Admin/NaicsCodeProduct/AllowableProductsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Alert, Button, Table} from 'react-bootstrap';
import {createFragmentContainer, graphql} from 'react-relay';
import {AllowableProductsTable_query} from '__generated__/AllowableProductsTable_query.graphql';
import {faCheck} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';

interface Props {
query: AllowableProductsTable_query;
Expand All @@ -11,7 +12,7 @@ interface Props {
export const AllowableProductsTableComponent: React.FunctionComponent<Props> = (
props
) => {
if (props.query.productNaicsCodesByNaicsCodeId.edges.length === 0) {
if (!props.query?.productNaicsCodesByNaicsCodeId.edges.length) {
return (
<Alert variant="secondary" id="no-search-results">
No allowed products have been set for this NAICS code.
Expand All @@ -25,7 +26,9 @@ export const AllowableProductsTableComponent: React.FunctionComponent<Props> = (
<thead>
<tr>
<th scope="col">Product Name</th>
<th scope="col">Mandatory</th>
<th scope="col" className="centered">
Mandatory
</th>
<th scope="col" />
</tr>
</thead>
Expand All @@ -34,7 +37,14 @@ export const AllowableProductsTableComponent: React.FunctionComponent<Props> = (
<tr>
<td>{e.node.productByProductId.productName}</td>
<td className="centered">
{e.node.isMandatory ? <b>{faCheck} Yes</b> : 'No'}
{e.node.isMandatory ? (
<>
<FontAwesomeIcon icon={faCheck} />
<b> Yes</b>
</>
) : (
'No'
)}
</td>
<td className="centered">
<Button variant="outline-danger" size="sm">
Expand All @@ -50,7 +60,8 @@ export const AllowableProductsTableComponent: React.FunctionComponent<Props> = (
color: white;
background: #003366;
}
.table td.centered {
.table td.centered,
.table th.centered {
text-align: center;
}
`}</style>
Expand Down

0 comments on commit daa56cd

Please sign in to comment.