import React from 'react';
import Styled from 'styled-components';

export const Avatar = ({ image, name, initials }) => {
  return (
    <AvatarWrapper>
      {image?.length < 1 ? <span>{initials}</span> : ''}
      {image && image.length > 0 ? <img src={image} alt={name} /> : ''}
    </AvatarWrapper>
  );
};

export const AvatarForProfile = ({ image, name, initials }) => {
  return (
    <AvatarWrapperTwo>
      {image?.length < 1 ? <span>{initials}</span> : ''}
      {image && image.length > 0 ? <img src={image} alt={name} /> : ''}
    </AvatarWrapperTwo>
  );
};

export const FormUserAvatar = ({ image, name, initials }) => {
  return (
    <AvatarWrapper>
      <span>{initials}</span>
      {image && image.length > 0 ? <img src={image} alt={name} /> : ''}
    </AvatarWrapper>
  );
};
export const Avatar40 = ({ image, name, initials }) => {
  return (
    <AvatarWrapper className="avatar-40">
      <span>{initials}</span>
      {image ? <img src={image} alt={name} /> : ''}
    </AvatarWrapper>
  );
};

export const Avatar30 = ({ image, name, initials }) => {
  return (
    <AvatarWrapper className="avatar-30">
      <span>{initials}</span>
      {image ? <img src={image} alt={name} /> : ''}
    </AvatarWrapper>
  );
};

export const AvatarWithText = ({ image, name, email, initials }) => {
  return (
    <WrapAvatarWithText>
      <Avatar40 image={image} alt={name} initials={initials} />
      <div className="name-info">
        <h4>{name}</h4>
        <p>{email}</p>
      </div>
    </WrapAvatarWithText>
  );
};

const WrapAvatarWithText = Styled.div`
  position: relative;
  display: flex;
  .name-info {
    margin-left: 1rem;
    h4 {
      font-family: var(--ff-medium);
      font-weight: 500;
      color: #0a1045;
      font-size: 1.6rem;
      text-transform: capitalize;
    }
    p {
      font-family: var(--ff-body);
      font-weight: 400;
      font-size: 1.4rem;
    }
  }
`;

const AvatarWrapper = Styled.div`
  position: relative;
  border-radius: 50%;
  background: var(--co-grey);
  min-width: 35px;
  max-height: 35px;
  width: 35px;
  height: 35px;
  &.avatar-40 {
    min-width: 40px;
    max-height: 40px;
    width: 40px;
    height: 40px;
  }

  span {
    position: absolute;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    text-transform: uppercase;
  }
  img {
    position: relative;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    border: 1px solid #E8EDFF;
    z-index: 1;
  }
`;
const AvatarWrapperTwo = Styled.div`
  position: relative;
  border-radius: 50%;
  background: var(--co-grey);
  min-width: 35px;
  max-height: 35px;
  width: 35px;
  height: 35px;
  &.avatar-40 {
    min-width: 40px;
    max-height: 40px;
    width: 40px;
    height: 40px;
  }

  span {
    position: absolute;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    text-transform: uppercase;
  }
  img {
    position: relative;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    border: 1px solid #E8EDFF;
    z-index: 1;
  }
`;
