securité cours + correction bug accueil
This commit is contained in:
@@ -18,6 +18,8 @@ import {
|
||||
Tab,
|
||||
} from "@mui/material";
|
||||
import axios from "axios";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { getToken } from "../../auth";
|
||||
import '../../assets/styleCours.css';
|
||||
|
||||
const API_URL = "https://www.formations.octopusdesign.fr/webservice/rest/server.php";
|
||||
@@ -37,9 +39,17 @@ const ListeCours = () => {
|
||||
const [assignmentQuery, setAssignmentQuery] = useState("");
|
||||
const [showOnlyMedia, setShowOnlyMedia] = useState(false);
|
||||
const [tabIndex, setTabIndex] = useState(0);
|
||||
const navigate = useNavigate();
|
||||
|
||||
// ✅ Redirection si non connecté
|
||||
useEffect(() => {
|
||||
if (!getToken()) {
|
||||
navigate("/admin/login");
|
||||
}
|
||||
}, [navigate]);
|
||||
|
||||
const itemsPerPage = 5;
|
||||
const pdfRef = useRef();
|
||||
|
||||
const pageHasMedia = (html) => /<img|<video|<audio|pluginfile\.php/.test(html);
|
||||
|
||||
const fetchCours = async () => {
|
||||
|
||||
@@ -67,18 +67,17 @@ const GestionPageAccueil = () => {
|
||||
const data = await response.json();
|
||||
setHeroTitle(data.acf?.hero_title || "");
|
||||
setHeroText(data.acf?.hero_text || "");
|
||||
setMissions(data.acf?.mission || []);
|
||||
|
||||
// ✅ Image Hero
|
||||
if (data.acf?.img_hero) {
|
||||
if (data.acf?.img_hero_url) {
|
||||
setHeroImage(data.acf.img_hero_url);
|
||||
} else {
|
||||
const mediaResponse = await fetch(
|
||||
`https://preprod.octopusdesign.fr/api-octopus/server/wp-json/wp/v2/media/${data.acf.img_hero}`
|
||||
);
|
||||
const mediaData = await mediaResponse.json();
|
||||
setHeroImage(mediaData.source_url);
|
||||
}
|
||||
if (data.acf?.img_hero_url) {
|
||||
setHeroImage(data.acf.img_hero_url);
|
||||
} else if (data.acf?.img_hero) {
|
||||
const mediaResponse = await fetch(
|
||||
`https://preprod.octopusdesign.fr/api-octopus/server/wp-json/wp/v2/media/${data.acf.img_hero}`
|
||||
);
|
||||
const mediaData = await mediaResponse.json();
|
||||
setHeroImage(mediaData.source_url);
|
||||
}
|
||||
|
||||
// ✅ GDC Construct
|
||||
|
||||
Reference in New Issue
Block a user