import image cloudinary
This commit is contained in:
@@ -19,6 +19,7 @@ const GestionPageAccueil = () => {
|
|||||||
const [heroTitle, setHeroTitle] = useState("");
|
const [heroTitle, setHeroTitle] = useState("");
|
||||||
const [heroText, setHeroText] = useState("");
|
const [heroText, setHeroText] = useState("");
|
||||||
const [heroImage, setHeroImage] = useState(null);
|
const [heroImage, setHeroImage] = useState(null);
|
||||||
|
const [heroImageCloudinaryUrl, setHeroImageCloudinaryUrl] = useState("");
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [successMessage, setSuccessMessage] = useState("");
|
const [successMessage, setSuccessMessage] = useState("");
|
||||||
@@ -69,11 +70,15 @@ const GestionPageAccueil = () => {
|
|||||||
|
|
||||||
// ✅ Image Hero
|
// ✅ Image Hero
|
||||||
if (data.acf?.img_hero) {
|
if (data.acf?.img_hero) {
|
||||||
const mediaResponse = await fetch(
|
if (data.acf?.img_hero_url) {
|
||||||
`https://preprod.octopusdesign.fr/api-octopus/server/wp-json/wp/v2/media/${data.acf.img_hero}`
|
setHeroImage(data.acf.img_hero_url);
|
||||||
);
|
} else {
|
||||||
const mediaData = await mediaResponse.json();
|
const mediaResponse = await fetch(
|
||||||
setHeroImage(mediaData.source_url);
|
`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
|
// ✅ GDC Construct
|
||||||
@@ -110,6 +115,7 @@ const GestionPageAccueil = () => {
|
|||||||
const newData = {
|
const newData = {
|
||||||
hero_title: heroTitle,
|
hero_title: heroTitle,
|
||||||
hero_text: heroText,
|
hero_text: heroText,
|
||||||
|
img_hero_url: heroImageCloudinaryUrl || undefined,
|
||||||
mission: missions,
|
mission: missions,
|
||||||
gdc_construct: {
|
gdc_construct: {
|
||||||
construct_title: constructTitle,
|
construct_title: constructTitle,
|
||||||
@@ -246,6 +252,33 @@ const GestionPageAccueil = () => {
|
|||||||
<input type="file" hidden onChange={handleImageUpload} />
|
<input type="file" hidden onChange={handleImageUpload} />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
label="Ou URL Cloudinary"
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
value={heroImageCloudinaryUrl}
|
||||||
|
onChange={(e) => setHeroImageCloudinaryUrl(e.target.value)}
|
||||||
|
sx={{ mb: 2, backgroundColor: "#fff", borderRadius: "5px" }}
|
||||||
|
placeholder="https://res.cloudinary.com/..."
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
color="primary"
|
||||||
|
fullWidth
|
||||||
|
sx={{ mb: 2 }}
|
||||||
|
onClick={async () => {
|
||||||
|
if (heroImageCloudinaryUrl.trim()) {
|
||||||
|
setHeroImage(heroImageCloudinaryUrl.trim());
|
||||||
|
await updateHomePageACF(13, {
|
||||||
|
img_hero_url: heroImageCloudinaryUrl.trim(),
|
||||||
|
});
|
||||||
|
setSuccessMessage("✅ Image Cloudinary appliquée !");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
🌐 Utiliser l'image Cloudinary
|
||||||
|
</Button>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Titre Héros"
|
label="Titre Héros"
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -367,9 +400,7 @@ const GestionPageAccueil = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Typography sx={{ mb: 1, fontWeight: "bold" }}>
|
<Typography sx={{ mb: 1, fontWeight: "bold" }}>Notes</Typography>
|
||||||
Notes
|
|
||||||
</Typography>
|
|
||||||
<ReactQuill
|
<ReactQuill
|
||||||
theme="snow"
|
theme="snow"
|
||||||
value={constructNote}
|
value={constructNote}
|
||||||
@@ -397,7 +428,7 @@ const GestionPageAccueil = () => {
|
|||||||
onChange={(e) => setexpertiseTitle(e.target.value)}
|
onChange={(e) => setexpertiseTitle(e.target.value)}
|
||||||
sx={{ mb: 2 }}
|
sx={{ mb: 2 }}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
<Paper elevation={3} sx={{ marginTop: "30px", padding: "20px" }}>
|
<Paper elevation={3} sx={{ marginTop: "30px", padding: "20px" }}>
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
@@ -5,10 +5,17 @@ import api from "../../api";
|
|||||||
import ModernSpinner from "../SpinnerModerne";
|
import ModernSpinner from "../SpinnerModerne";
|
||||||
import Expertises from "../Expertises";
|
import Expertises from "../Expertises";
|
||||||
import ConstructSection from "../ConstructSection";
|
import ConstructSection from "../ConstructSection";
|
||||||
import { Box, Grid, Typography, Button, Card, CardContent } from "@mui/material";
|
import {
|
||||||
|
Box,
|
||||||
|
Grid,
|
||||||
|
Typography,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
} from "@mui/material";
|
||||||
import Logo from "../../assets/centre-formation-logo.avif";
|
import Logo from "../../assets/centre-formation-logo.avif";
|
||||||
import Testi from "../Testi";
|
import Testi from "../Testi";
|
||||||
import '../../assets/style.css';
|
import "../../assets/style.css";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const [pageData, setPageData] = useState(null);
|
const [pageData, setPageData] = useState(null);
|
||||||
@@ -23,14 +30,22 @@ const Home = () => {
|
|||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
// 🔥 Ajout d'un timestamp pour éviter la mise en cache
|
// 🔥 Ajout d'un timestamp pour éviter la mise en cache
|
||||||
const response = await api.get(`wp/v2/pages/13?_fields=acf,rank_math_title,rank_math_description&_=${new Date().getTime()}`);
|
const response = await api.get(
|
||||||
|
`wp/v2/pages/13?_fields=acf,rank_math_title,rank_math_description&_=${new Date().getTime()}`
|
||||||
|
);
|
||||||
const pageContent = response.data;
|
const pageContent = response.data;
|
||||||
setPageData(pageContent);
|
setPageData(pageContent);
|
||||||
|
|
||||||
// Récupération de l'image Hero
|
// Récupération de l'image Hero (Cloudinary ou WordPress)
|
||||||
const heroImageId = pageContent.acf?.img_hero;
|
if (
|
||||||
if (heroImageId) {
|
pageContent.acf?.img_hero_url &&
|
||||||
const mediaResponse = await api.get(`wp/v2/media/${heroImageId}?_=${new Date().getTime()}`);
|
pageContent.acf.img_hero_url.startsWith("http")
|
||||||
|
) {
|
||||||
|
setHeroImage(pageContent.acf.img_hero_url);
|
||||||
|
} else if (pageContent.acf?.img_hero) {
|
||||||
|
const mediaResponse = await api.get(
|
||||||
|
`wp/v2/media/${pageContent.acf.img_hero}?_=${new Date().getTime()}`
|
||||||
|
);
|
||||||
setHeroImage(mediaResponse.data.source_url);
|
setHeroImage(mediaResponse.data.source_url);
|
||||||
} else {
|
} else {
|
||||||
setHeroImage(null);
|
setHeroImage(null);
|
||||||
@@ -44,7 +59,7 @@ const Home = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchPageData();
|
fetchPageData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -64,8 +79,6 @@ const Home = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const { acf, rank_math_title, rank_math_description } = pageData || {};
|
const { acf, rank_math_title, rank_math_description } = pageData || {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -74,9 +87,15 @@ const Home = () => {
|
|||||||
<SEO
|
<SEO
|
||||||
postId={13} // ID WordPress valide
|
postId={13} // ID WordPress valide
|
||||||
defaultTitle={rank_math_title || "centre de formation "}
|
defaultTitle={rank_math_title || "centre de formation "}
|
||||||
defaultDescription={rank_math_description || "formation et reconversion professionnelle dans les métiers du numérique"}
|
defaultDescription={
|
||||||
|
rank_math_description ||
|
||||||
|
"formation et reconversion professionnelle dans les métiers du numérique"
|
||||||
|
}
|
||||||
defaultCanonicalUrl={acf?.canonical_url || window.location.href}
|
defaultCanonicalUrl={acf?.canonical_url || window.location.href}
|
||||||
defaultOgImage={heroImage || "https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/01/Construction-logements-au-Mans-01.avif"}
|
defaultOgImage={
|
||||||
|
heroImage ||
|
||||||
|
"https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/01/Construction-logements-au-Mans-01.avif"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Section Héros */}
|
{/* Section Héros */}
|
||||||
@@ -91,7 +110,9 @@ const Home = () => {
|
|||||||
|
|
||||||
{/* Section Construisons */}
|
{/* Section Construisons */}
|
||||||
<ConstructSection
|
<ConstructSection
|
||||||
constructTitle={acf?.gdc_construct?.construct_title || "Construisons vos projets"}
|
constructTitle={
|
||||||
|
acf?.gdc_construct?.construct_title || "Construisons vos projets"
|
||||||
|
}
|
||||||
constructSubtitle={acf?.gdc_construct?.construct_subtitle || "ensemble"}
|
constructSubtitle={acf?.gdc_construct?.construct_subtitle || "ensemble"}
|
||||||
constructText={acf?.gdc_construct?.construct_text || "Texte par défaut"}
|
constructText={acf?.gdc_construct?.construct_text || "Texte par défaut"}
|
||||||
constructSector={acf?.gdc_construct?.construct_sector || "Secteurs"}
|
constructSector={acf?.gdc_construct?.construct_sector || "Secteurs"}
|
||||||
@@ -102,7 +123,9 @@ const Home = () => {
|
|||||||
|
|
||||||
{/* Section Expertises */}
|
{/* Section Expertises */}
|
||||||
<Expertises
|
<Expertises
|
||||||
expertiseTitle={acf?.titre_expertise.titre_expertise || "Pourquoi Nous Choisir ?"}
|
expertiseTitle={
|
||||||
|
acf?.titre_expertise.titre_expertise || "Pourquoi Nous Choisir ?"
|
||||||
|
}
|
||||||
expertise1Title={acf?.gdc_expert?.titre_expertise_1 || "Expertise 1"}
|
expertise1Title={acf?.gdc_expert?.titre_expertise_1 || "Expertise 1"}
|
||||||
expertise1Text={acf?.gdc_expert?.text_expertise_1 || "Text Expertise 1"}
|
expertise1Text={acf?.gdc_expert?.text_expertise_1 || "Text Expertise 1"}
|
||||||
expertise2Title={acf?.gdc_expert?.titre_expertise_2 || "Expertise 2"}
|
expertise2Title={acf?.gdc_expert?.titre_expertise_2 || "Expertise 2"}
|
||||||
@@ -111,16 +134,27 @@ const Home = () => {
|
|||||||
expertise3Text={acf?.gdc_expert?.text_expertise_3 || "Text Expertise 3"}
|
expertise3Text={acf?.gdc_expert?.text_expertise_3 || "Text Expertise 3"}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* Section Témoignages */}
|
{/* Section Témoignages */}
|
||||||
<Typography variant="h2" sx={{ fontWeight: "bold", mb: 2, textAlign: "center", fontSize: { xs: "2rem", md: "2rem", lg: "3rem" } }}>
|
<Typography
|
||||||
Ce que disent nos clients
|
variant="h2"
|
||||||
</Typography>
|
sx={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
mb: 2,
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: { xs: "2rem", md: "2rem", lg: "3rem" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Ce que disent nos clients
|
||||||
|
</Typography>
|
||||||
<Testi />
|
<Testi />
|
||||||
{/* Section Action */}
|
{/* Section Action */}
|
||||||
<Box sx={{ py: 6, px: 4, backgroundColor: "#0e467f", color: "#fff" }}>
|
<Box sx={{ py: 6, px: 4, backgroundColor: "#0e467f", color: "#fff" }}>
|
||||||
<Typography variant="h2" align="center" gutterBottom sx={{ fontWeight: "bold", mb: 4 }}>
|
<Typography
|
||||||
|
variant="h2"
|
||||||
|
align="center"
|
||||||
|
gutterBottom
|
||||||
|
sx={{ fontWeight: "bold", mb: 4 }}
|
||||||
|
>
|
||||||
Prêt à Commencer ?
|
Prêt à Commencer ?
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box textAlign="center">
|
<Box textAlign="center">
|
||||||
@@ -143,7 +177,15 @@ const Home = () => {
|
|||||||
|
|
||||||
{/* Section Témoignages */}
|
{/* Section Témoignages */}
|
||||||
<Box sx={{ py: 6, px: 4 }}>
|
<Box sx={{ py: 6, px: 4 }}>
|
||||||
<Typography variant="h2" sx={{ fontWeight: "bold", mb: 2, textAlign: "center", fontSize: { xs: "2rem", md: "2rem", lg: "3rem" } }}>
|
<Typography
|
||||||
|
variant="h2"
|
||||||
|
sx={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
mb: 2,
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: { xs: "2rem", md: "2rem", lg: "3rem" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
Nos partenaires
|
Nos partenaires
|
||||||
</Typography>
|
</Typography>
|
||||||
<Grid container spacing={4}>
|
<Grid container spacing={4}>
|
||||||
@@ -153,7 +195,10 @@ const Home = () => {
|
|||||||
<Typography variant="body1" sx={{ fontStyle: "italic" }}>
|
<Typography variant="body1" sx={{ fontStyle: "italic" }}>
|
||||||
Un service exceptionnel, une équipe formidable
|
Un service exceptionnel, une équipe formidable
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" sx={{ mt: 2, textAlign: "right", fontWeight: "bold" }}>
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ mt: 2, textAlign: "right", fontWeight: "bold" }}
|
||||||
|
>
|
||||||
- zertides
|
- zertides
|
||||||
</Typography>
|
</Typography>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -165,7 +210,10 @@ const Home = () => {
|
|||||||
<Typography variant="body1" sx={{ fontStyle: "italic" }}>
|
<Typography variant="body1" sx={{ fontStyle: "italic" }}>
|
||||||
Des résultats impressionnants pour notre projet.
|
Des résultats impressionnants pour notre projet.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" sx={{ mt: 2, textAlign: "right", fontWeight: "bold" }}>
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ mt: 2, textAlign: "right", fontWeight: "bold" }}
|
||||||
|
>
|
||||||
- Client 2
|
- Client 2
|
||||||
</Typography>
|
</Typography>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -177,4 +225,4 @@ const Home = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Home;
|
export default Home;
|
||||||
|
|||||||
Reference in New Issue
Block a user