import * as React from "react";
import { Image } from "@fluentui/react";

export interface IJitzImageProps {
  email?: string;
  siteUrl: string;
  width?: number;
  height?: number;
  className?: string;
}

export interface IJitzImageState {}

export class JitzImage1 extends React.Component<
  IJitzImageProps,
  IJitzImageState
> {
  constructor(props: IJitzImageProps, state: IJitzImageState) {
    super(props);
    this.state = {};
  }

  public render(): React.ReactElement<IJitzImageProps> {
    return (
      <Image
        src={`${encodeURIComponent(this.props.email || "")}`}
        alt={""}
        onError={(e: any) => {
          e.target.onerror = null;
          e.target.src = `${this.props.siteUrl}/_layouts/15/userphoto.aspx?size=L&accountname=${this.props.email}`;
        }}
        width={this.props.width}
        height={this.props.height}
        className={this.props.className}
      />
    );
  }
}
