aintenant, comment mettre en place le filtre par date, qui affiche la date de l’evenement (donc qui correspond a datePassage du groupe et donc des artistes de ce groupe) ? import { useEffect, useState, useRef, useLayoutEffect } from “react”;
import SearchBar from “…/…/components/form/SearchBar”;
import Combo from “…/…/components/form/Combo”;
import CarteArtiste from “…/…/components/Artiste/CarteProgrammation”;
import { motion } from “framer-motion”;
import { useLocation } from “react-router-dom”;
import axios from “axios”;
import Footer from “…/…/components/footer”;
import CarteProgrammation from “…/…/components/Artiste/CarteProgrammation”;
import { AnimatePresence } from “framer-motion”;
type Props = {
isNavInFocus: boolean;
setIsNavTransparent: (isNavTransparent: boolean) => void;
};
type Groupe = {
idG: number;
nomG: string;
descriptionG: string;
datePassage: string;
heurePassage: string;
};
type Artiste = {
descriptionA?: string;
idMG?: number;
idG: number;
nomDeSceneMG: string;
nomMG: string;
prenomMG?: string;
datePassage?: string;
heurePassage?: string;
};
type Evenement = {
dateDebutE: string;
dateFinE: string;
heureDebutE: string;
heureFinE: string;
idE: number;
idG: number;
idL: number | null;
nomE: string;
};
type Programme = Groupe | Evenement | Artiste;
export default function Programmation(props: Props) {
const location = useLocation();
const idArtistComingFrom = location.state?.comesFromPageArtist;
const oldX = location.state?.oldX;
const oldY = location.state?.oldY;
const oldGroupes = location.state?.oldGroupes;
const [searchTerm, setSearchTerm] = useState(“”);
window.history.replaceState({}, document.title);
const [lesGroupes, setLesGroupes] = useState<Groupe[]>(
location.state ? oldGroupes : []
);
const [lesArtistes, setLesArtistes] = useState<Artiste[]>([]);
const groupePassageMap = useRef<
Map<number, { datePassage: string; heurePassage: string }>
(new Map());
useEffect(() => {
axios.get(“http://localhost:8080/getGroupesWithEvenements”).then((res) => {
const groupedData = res.data as Programme[][];
console.log(groupedData);
const listeGroupes: Groupe[] = [];
const groupSet = new Set();
const listeArtistes: Artiste[] = [];
groupedData.forEach((groupArray) => {
let groupeObj: Partial = {};
let artisteObj: Partial = {};
groupArray.forEach((item) => {
if (“nomG” in item) {
groupeObj = { …groupeObj, …item };
} else if (“nomDeSceneMG” in item) {
artisteObj = { …artisteObj, …item };
} else if (“dateDebutE” in item) {
const datePassage = item.dateDebutE;
const heurePassage = item.heureDebutE;
if (groupeObj.idG === item.idG) {
groupeObj.datePassage = datePassage;
groupeObj.heurePassage = heurePassage;
}
if (artisteObj.idG === item.idG) {
artisteObj.datePassage = datePassage;
artisteObj.heurePassage = heurePassage;
}
}
});
// si l’id n’a pas encore était ajoutée à la liste on ajoute le groupe
if (groupeObj.idG !== undefined && !groupSet.has(groupeObj.idG)) {
listeGroupes.push(groupeObj as Groupe);
groupSet.add(groupeObj.idG);
}
if (artisteObj.nomDeSceneMG !== undefined) {
listeArtistes.push(artisteObj as Artiste);
}
});
setLesGroupes(listeGroupes);
groupePassageMap.current.clear();
listeGroupes.forEach((groupe) => {
groupePassageMap.current.set(groupe.idG, {
datePassage: groupe.datePassage,
heurePassage: groupe.heurePassage,
});
});
setLesArtistes(listeArtistes);
});
}, []);
let filteredGroupes = lesGroupes;
if (searchTerm) {
filteredGroupes = lesGroupes.filter((groupe) =>
groupe.nomG.toLowerCase().includes(searchTerm.toLowerCase())
);
}
let filteredArtistes = lesArtistes;
if (searchTerm) {
filteredArtistes = lesArtistes.filter((artiste) =>
artiste.nomDeSceneMG.toLowerCase().includes(searchTerm.toLowerCase())
)
}
const [filtreDate, setFiltreDate] = useState(“Tout”);
const [filtreAffichage, setFiltreAffichage] = useState(“Grille”);
const [filtreGenre, setFiltreGenre] = useState(“Tout”);
const pageRef = useRef(null);
const contentVariants = {
visible: {
filter: “blur(0px)”,
scale: 1,
zIndex: 1,
transition: {
duration: 0.5,
ease: [1, 0, 0, 1],
},
},
hidden: {
filter: “blur(10px)”,
scale: 0.8,
zIndex: -1,
transition: {
duration: 0.5,
ease: [1, 0, 0, 1],
},
},
};
useEffect(() => {
window.scrollTo(0, 0);
props.setIsNavTransparent(false);
}, []);
return (
<>
<motion.div
id=“Programmation”
className=“page-defaut”
variants={contentVariants}
animate={props.isNavInFocus ? “hidden” : “visible”}
ref={pageRef}
type Props = {
id:number|undefined,
date: string,
heure: string,
nomArtiste: string,
setIsNavTransparent: (isNavTransparent : boolean) => void;
comesFromPageArtist?: boolean;
oldX?: number;
oldY?: number;
oldGroupes?: Groupe[];
description?: string;
}
type Groupe = {
idG: number;
nomG: string;
descriptionG: string;
datePassage: string;
heurePassage: string;
}
export default function CarteProgrammation(props: Props) {
const nomArtiste = props.nomArtiste.toUpperCase().split(" “)
const[isHovered, setIsHovered] = useState(false)
const[isSwitching, setIsSwitching] = useState(false)
const[delay, setDelay] = useState(props.comesFromPageArtist? 0.2 : 0)
const refCarte = useRef(null);
const[zIndexCard, setZIndexCard] = useState(props.comesFromPageArtist ? 99 : 1)
useEffect(() => {
setTimeout(() => {
console.log(props.date)
console.log(props.heure)
setZIndexCard(1)
setDelay(0)
}, 600);
}, [])
const titleVariants = {
hover:{
fontSize: “2.3rem”,
color:”#FFD600",
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
},
default:{
fontSize: “2.3rem”,
color:“#FFFBEE”,
transition:{
delay:delay,
duration:0.4,
ease: [1, 0, 0,1]
}
},
exit:{
fontSize: “7.625rem”,
color:“#FFD600”,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
}
}
// fais le variant pour l’image de l’artiste (scale 1.2 sur hover)
const imageVariants = {
hover:{
scale:1.3,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
},
default:{
scale:1,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
}
}
// fais le variant pour le texte de dateHeure (x 2rem sur hover)
const dateHeureVariants = {
hover:{
y:“0rem”,
fontSize: “1.875rem”,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
},
default:{
y:(window.innerWidth <= 576 ? 3.1 : 2.9).toString() + “rem”,
fontSize: “1.875rem”,
transition:{
delay:delay,
duration:0.4,
ease: [1, 0, 0,1]
}
},
exit:{
y:“0rem”,
fontSize: “4.6875rem”,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
}
}
// default font-size: 1.875rem;
// exit font-size: 4.6875rem;
const heureVariants = {
hover:{
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
},
default:{
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
},
}
const carteVariants = {
default:{
zIndex:zIndexCard,
width: “24rem”,
height: “15.5rem”,
y:0,
x:0,
transition:{
delay:0.2,
duration:0.4,
ease: [1, 0, 0,1]
}
},
exit:{
x: refCarte.current? -refCarte.current.offsetLeft : props.oldX? -props.oldX : 0,
y: refCarte.current? -refCarte.current.offsetTop : props.oldY? -props.oldY : 0,
height: “100vh”,
width: “100vw”,
zIndex:99,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
}
}
const textVariants = {
default:{
padding: “0.5rem 1rem”,
transition:{
delay:delay*2,
duration:0.4,
ease: [1, 0, 0,1]
}
},
exit:{
padding: “3rem”,
transition:{
duration:0.4,
ease: [1, 0, 0,1]
}
}
}
return (
<motion.div
className=“outer-carte-artiste”
ref={refCarte}
variants={carteVariants}
initial={props.comesFromPageArtist ? “exit” : “default”}
animate=“default”
exit={isSwitching ? “exit” : “default”}
onClick={() => window.scrollTo(0,0)}
<motion.div className=“date-heure”
variants={dateHeureVariants}
initial={props.comesFromPageArtist ? “exit” : “default”}
animate={isHovered ? “hover” : “default”}
exit={isSwitching ? “exit” : “default”}
<motion.h4
variants={heureVariants}
initial=“default”
animate={isHovered ? “hover” : “default”}
exit={isSwitching ? “exit” : “default”}
{props.heure}</motion.h4>
</motion.div>
</motion.div>
export default function PageEvenement() {
)
}