import { FC, HTMLProps, useMemo } from 'react'
import { Entity } from '../../../src/types'
import styles from './EntityIcon.module.css'
import cx from 'classnames'
import { useFactories } from '../../contexts/FactoryProvider'
interface Props extends Omit, 'value'> {
value: Entity | string
amount?: number
}
export const EntityIcon: FC = ({ className, value, amount, ...rest }) => {
const { findFactory } = useFactories()
const entity = useMemo(() => {
return typeof value === 'object'
? value
: value === '/Time'
? {
href: '/Time',
name: 'Time',
image: '/images/Time.png',
recipe: undefined
}
: findFactory(value) ?? {
href: value,
name: value,
image: value,
recipe: undefined
}
}, [findFactory, value])
return (
{/* eslint-disable-next-line @next/next/no-img-element */}
{amount !== undefined && {amount}}
)
}