Conditionally show icon
This commit is contained in:
parent
7692ec0a0b
commit
18901c954b
1 changed files with 10 additions and 6 deletions
|
|
@ -1,13 +1,12 @@
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useTranslation } from 'next-i18next'
|
|
||||||
|
|
||||||
import { ACCESSORY_JOB_IDS } from '~utils/jobsWithAccessories'
|
|
||||||
|
|
||||||
import Button from '~components/Button'
|
import Button from '~components/Button'
|
||||||
import JobAccessoryPopover from '~components/JobAccessoryPopover'
|
import JobAccessoryPopover from '~components/JobAccessoryPopover'
|
||||||
|
|
||||||
import ShieldIcon from '~public/icons/Shield.svg'
|
import ShieldIcon from '~public/icons/Shield.svg'
|
||||||
|
import ManaturaIcon from '~public/icons/Manatura.svg'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -51,7 +50,7 @@ const JobImage = ({
|
||||||
return source
|
return source
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasAccessory = job && ACCESSORY_JOB_IDS.includes(job.id)
|
const hasAccessory = job && job.accessory
|
||||||
const image = <img alt={job?.name[locale]} src={imageUrl()} />
|
const image = <img alt={job?.name[locale]} src={imageUrl()} />
|
||||||
|
|
||||||
function handleAccessoryButtonClicked() {
|
function handleAccessoryButtonClicked() {
|
||||||
|
|
@ -64,9 +63,14 @@ const JobImage = ({
|
||||||
|
|
||||||
// Elements
|
// Elements
|
||||||
const accessoryButton = () => {
|
const accessoryButton = () => {
|
||||||
|
let icon
|
||||||
|
|
||||||
|
if (job && job.accessory_type === 1) icon = <ShieldIcon />
|
||||||
|
else if (job && job.accessory_type === 2) icon = <ManaturaIcon />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
accessoryIcon={<ShieldIcon />}
|
accessoryIcon={icon}
|
||||||
className="JobAccessory"
|
className="JobAccessory"
|
||||||
onClick={handleAccessoryButtonClicked}
|
onClick={handleAccessoryButtonClicked}
|
||||||
ref={buttonRef}
|
ref={buttonRef}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue