👌 IMPROVE: Gestion erreur images fonctions
This commit is contained in:
@ -6,7 +6,7 @@ import { faStar as farStar } from '@fortawesome/free-regular-svg-icons';
|
||||
import date from 'date-and-time';
|
||||
import { UserContext } from '../../contexts/UserContext';
|
||||
import api from '../../utils/api';
|
||||
import { API_URL } from '../../utils/config';
|
||||
import { API_URL } from '../../utils/config/config';
|
||||
import '../FunctionCard/FunctionCard.css';
|
||||
|
||||
const FunctionComponentTop = (props) => {
|
||||
@ -40,6 +40,10 @@ const FunctionComponentTop = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleError = (event) => {
|
||||
event.target.src = API_URL + "/images/functions/default.png";
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container-fluid">
|
||||
<div className="row justify-content-center text-center">
|
||||
@ -49,7 +53,7 @@ const FunctionComponentTop = (props) => {
|
||||
<FontAwesomeIcon onClick={toggleFavorite} { ...(isFavorite) ? { icon: faStar } : { icon: farStar } } title={(isFavorite) ? "Retirer la fonction des favoris" : "Ajouter la fonction aux favoris"} className="FunctionComponent__star-favorite" />
|
||||
}
|
||||
|
||||
<img className="FunctionComponent__image" src={API_URL + props.image} alt={props.title} />
|
||||
<img onError={handleError} className="FunctionComponent__image" src={API_URL + props.image} alt={props.title} />
|
||||
<h1 className="FunctionComponent__title title-important">{props.title}</h1>
|
||||
<p className="FunctionComponent__description">{props.description}</p>
|
||||
<div className="FunctionCard__info">
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Fragment, useState } from 'react';
|
||||
import { API_URL } from '../../utils/config';
|
||||
import { API_URL } from '../../utils/config/config';
|
||||
import HeadTag from '../HeadTag';
|
||||
import FunctionTabsTop from './FunctionTabsTop';
|
||||
import FunctionComponentTop from './FunctionComponentTop';
|
||||
|
Reference in New Issue
Block a user