2020-02-18 13:10:37 +01:00
|
|
|
import React, {FC} from "react";
|
2019-10-20 16:59:02 +02:00
|
|
|
import { binder } from "@scm-manager/ui-extensions";
|
|
|
|
|
import { Image } from "..";
|
|
|
|
|
import { Person } from "./Avatar";
|
|
|
|
|
import { EXTENSION_POINT } from "./Avatar";
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
person: Person;
|
2020-02-18 13:10:37 +01:00
|
|
|
representation?: "rounded" | "rounded-border";
|
2018-10-18 14:40:35 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-18 13:10:37 +01:00
|
|
|
const AvatarImage:FC<Props> = ({person, representation = "rounded-border"}) => {
|
2018-12-10 08:45:59 +01:00
|
|
|
const avatarFactory = binder.getExtension(EXTENSION_POINT);
|
2018-10-18 14:40:35 +02:00
|
|
|
if (avatarFactory) {
|
2018-12-10 08:45:59 +01:00
|
|
|
const avatar = avatarFactory(person);
|
2018-10-18 14:40:35 +02:00
|
|
|
|
2020-02-18 13:10:37 +01:00
|
|
|
const className = representation === "rounded" ? "is-rounded" : "has-rounded-border";
|
|
|
|
|
|
|
|
|
|
return <Image className={className} src={avatar} alt={person.name} />;
|
2018-10-18 14:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2020-02-18 13:10:37 +01:00
|
|
|
};
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
export default AvatarImage;
|