import React, { FC } from 'react'
import { Link } from 'react-router-dom'
import { useTheme } from '../hooks'
import { App } from '../types'

interface Props {
    app: App
}

const AppListItem: FC<Props> = ({ app }) => {
    const theme = useTheme()

    return (
        <div className="app-list-item" style={{ backgroundColor: theme.backgroundPrimary, borderColor: theme.backgroundSecondary }}>
            {app.imageUrl &&
                <div className="image">
                    <img src={app.imageUrl} />
                </div>
            }
            <div>
                <Link to={`/a/${app.id}`} style={{ color: theme.primary }}>{app.name}</Link>
                {app.about && <p style={{ color: theme.text }}>{app.about}</p>}
            </div>
        </div>
    )
}

export default AppListItem
