import Styles from "@/constants/Styles";
import { useState } from "react";
import { Image } from "react-native";

type Props = {
   src: string,
   size?: 'sm' | 'xs' | 'lg'
   border?: boolean
}

export default function ImageUser({ src, size }: Props) {
   const [error, setError] = useState(false)
   return (
      <Image
         source={error ? require('../assets/images/user.jpg') : { uri: src }}
         style={[size == 'xs' ? Styles.userProfileExtraSmall : size == 'lg' ? Styles.userProfileBig : Styles.userProfileSmall, Styles.borderAll]}
         onError={() =>
            setError(true)
         }
      />
   )
}