{"size": 978, "ext": "js", "max_stars_repo_path": "src/components/SubscribeCard.js", "max_stars_repo_name": "me-X-us/home-leisure", "max_stars_repo_stars_event_min_datetime": "2021-01-16T04:19:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-16T04:19:05.000Z", "max_issues_repo_path": "src/components/SubscribeCard.js", "max_issues_repo_name": "me-X-us/home-leisure", "max_issues_repo_issues_event_min_datetime": "2020-11-12T00:51:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T10:40:48.000Z", "max_forks_repo_path": "src/components/SubscribeCard.js", "max_forks_repo_name": "me-X-us/home-leisure", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 19, "max_forks_count": null, "avg_line_length": 32.6, "max_line_length": 101, "alphanum_fraction": 0.618609407}
import React, { useEffect, useState } from 'react';
import { API_BASE_URL } from '../utils/authHttpWrapper';
import '../css/SubscribeCard.css';
import { Link } from 'react-router-dom';

const SubscribeCard = (props) => {

    const imgDefault = process.env.PUBLIC_URL + '/Gray.png'
    const [subscribeImage, setSubscribeImage] = useState('');

    useEffect(() => {
        setSubscribeImage(API_BASE_URL + '/profile/' + props.subscribe.trainerId + '/image')
        // eslint-disable-next-line
    }, [])

    const onImageError = () => {
        setSubscribeImage(imgDefault);
    }

    return (
        <Link className='Page' to={"/page/" + props.subscribe.trainerName}>
            <div className='Subscribe'>
                <img className='SubscribeImg' src={subscribeImage} onError={onImageError} alt={''} />
                <text className='SubscribeName'>{props.subscribe.trainerName}</text>
            </div>
        </Link>
    );
};

export default SubscribeCard;