57 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-12-29 19:39:30 +00:00
import style from './ActorTile.module.css';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faUser} from '@fortawesome/free-solid-svg-icons';
import React from 'react';
import {Link} from 'react-router-dom';
import {ActorType} from '../../types/VideoTypes';
2020-12-29 19:39:30 +00:00
interface Props {
2020-12-29 19:39:30 +00:00
actor: ActorType;
onClick?: (actor: ActorType) => void;
2020-12-29 19:39:30 +00:00
}
class ActorTile extends React.Component<Props> {
constructor(props: Props) {
2020-12-29 19:39:30 +00:00
super(props);
this.state = {};
}
render(): JSX.Element {
if (this.props.onClick) {
return this.renderActorTile(this.props.onClick);
} else {
return <Link to={{pathname: '/actors/' + this.props.actor.ActorId}}>{this.renderActorTile(() => {})}</Link>;
2020-12-29 19:39:30 +00:00
}
}
/**
* render the Actor Tile with its pic
* @param customclickhandler a custom click handler to be called onclick instead of Link
*/
private renderActorTile(customclickhandler: (actor: ActorType) => void): JSX.Element {
2020-12-29 19:39:30 +00:00
return (
<div className={style.actortile} onClick={(): void => customclickhandler(this.props.actor)}>
<div className={style.actortile_thumbnail}>
{
this.props.actor.Thumbnail === '' ? (
<FontAwesomeIcon
style={{
lineHeight: '130px'
}}
icon={faUser}
size='5x'
/>
) : (
'dfdf'
) /* todo render picture provided here! */
}
2020-12-29 19:39:30 +00:00
</div>
<div className={style.actortile_name}>{this.props.actor.Name}</div>
2020-12-29 19:39:30 +00:00
</div>
);
}
}
export default ActorTile;