adapte page Evenement pour qu'il récupère la description de l'artiste : import {useEffect, useState, useRef} from 'react'
import { Link, useLocation } from 'react-router-dom'
import BoutonReseau from '../../components/Artiste/BoutonReseau'
import { motion } from 'framer-motion'
export default function PageEvenement() {
const location = useLocation();
const oldX = location.state?.oldX;
const oldY = location.state?.oldY;
const oldGroupes = location.state?.oldGroupes;
const[nomArtiste, setNomArtiste] = useState(location.state?.nomArtiste)
const[date, setDate] = useState(location.state?.date)
const[heure, setHeure] = useState(location.state?.heure)
const[description, setDescription] = useState("Tame Impala est un projet musical australien originaire de Perth, créé en 2007 et dirigé par le musicien multi-instrumentiste Kevin Parker. Parker écrit, joue, produit et enregistre la musique seul en studio d'enregistrement. En tournée, il est accompagné de différents musiciens. Tame Impala est né du précédent groupe de Kevin Parker, Dee Dee Dums, qui mêlait des influences blues, jazz et rock psychédélique. Ce groupe était formé de Parker à la guitare et de Luke Epstein à la batterie. Ils remportent la deuxième place au AmpFest de 20051, et terminent troisième la même année au cours de la finale nationale de The Next Big Thing2. En octobre 2006, les Dee Dee Dums remportent la finale nationale de la National Campus Band Competition3.")
const titleRef = useRef<HTMLHeadingElement>(null);
const params = new URLSearchParams(window.location.search)
const idArtiste = params.get('id')
const[windowWidth, setWindowWidth] = useState(window.innerWidth)
const[infosGridPosition, setInfosGridPosition] = useState<"top" | "bottom">("top")
useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth)
}
window.addEventListener('resize', handleResize)
return () => {
window.removeEventListener('resize', handleResize)
}
}, [])
useEffect(() => {
if(titleRef.current){
// regarde si la width du titre est plus grande que 25% de la width de la fenetre - 2*3rem
if(titleRef.current.offsetWidth > windowWidth/4 - 2*3*16){
setInfosGridPosition("top")
}
else{
setInfosGridPosition("bottom")
}
}
}, [titleRef, windowWidth])
const infosVariants = {
initial:{
opacity:0,
transition:{
duration:0.1,
ease: "easeInOut"
}
},
visible:{
opacity:1,
transition:{
delay: 0.8,
duration:0.6,
ease: "easeInOut"
}
}
}
const overlayVariants = {
initial:{
background:"linear-gradient(to top, rgba(0, 0, 0, 0.7) 20%, rgba(0, 0, 0, 0) 60%)",
transition:{
duration:0.1,
ease: "easeInOut"
}
},
extended:{
background:"linear-gradient(to top, rgba(0, 0, 0, 0.7) 40%, rgba(0, 0, 0, 0) 100%)",
transition:{
delay: 0.6,
duration:0.6,
ease: "easeInOut"
}
}
}
return (
<div id='PageArtiste'>
<motion.div className="overlay"
variants={overlayVariants}
initial="initial"
animate={infosGridPosition === "top" ? "extended" : "initial"}
/>
<img src={"http://localhost:8080/getImageArtiste/"+idArtiste} alt="image de fond" />
<div className="content"
style={{
columnGap: infosGridPosition === "top" ? "0" : "5rem",
rowGap: windowWidth > 991 ? "0" : "5rem",
}}
>
<h3 ref={titleRef}>
{
nomArtiste.toUpperCase().split(" ").map((mot : string, index:number) => {
return(
<span key={index}>{mot}<br/></span>
)
})
}
</h3>
<motion.div className="infos"
variants={infosVariants}
initial="initial"
animate="visible"
exit="initial"
style={{gridArea : infosGridPosition}}
>
<p className='description'>
Tame Impala est un projet musical australien originaire de Perth, créé en 2007 et dirigé par le musicien multi-instrumentiste Kevin Parker. Parker écrit, joue, produit et enregistre la musique seul en studio d'enregistrement. En tournée, il est accompagné de différents musiciens.
Tame Impala est né du précédent groupe de Kevin Parker, Dee Dee Dums, qui mêlait des influences blues, jazz et rock psychédélique. Ce groupe était formé de Parker à la guitare et de Luke Epstein à la batterie. Ils remportent la deuxième place au AmpFest de 20051, et terminent troisième la même année au cours de la finale nationale de The Next Big Thing2. En octobre 2006, les Dee Dee Dums remportent la finale nationale de la National Campus Band Competition3.
<Link to="/programmation"
state={{
comesFromPageArtist:idArtiste,
oldX: oldX,
oldY: oldY,
oldGroupes: oldGroupes
}}
className='btn-retour'>
</motion.div>
<div className="date-heure">
<h4>{date}</h4>
<h4>{heure}</h4>
</div>
</div>
</div>
)
}
import { motion } from 'framer-motion'
import {useState,useRef, useEffect} from 'react'
import { Link } from 'react-router-dom'
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)}
>
<Link className="carte-artiste"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
to={{
pathname:"/artiste",
search:?id=${props.id},
}}
state={{
nomArtiste: props.nomArtiste,
date: props.date,
heure: props.heure,
oldX: refCarte.current?.offsetLeft,
oldY: refCarte.current?.offsetTop,
oldGroupes: props.oldGroupes
}}
onClick={() => {props.setIsNavTransparent(true); setIsSwitching(true)}}
>
<motion.img
src={"http://localhost:8080/getImageArtiste/" + props.id}
alt="image de l'artiste"
variants={imageVariants}
initial="default"
animate={isHovered ? "hover" : "default"}
exit="default"
/>
<motion.div className="texts"
variants={textVariants}
initial={props.comesFromPageArtist ? "exit" : "default"}
animate="default"
exit={isSwitching ? "exit" : "default"}
>
<motion.h3
variants={titleVariants}
initial={props.comesFromPageArtist ? "exit" : "default"}
animate={isHovered ? "hover" : "default"}
exit={isSwitching ? "exit" : "default"}
>{
nomArtiste.map((mot, index) => {
return(
{mot}
)
})
}</motion.h3>
<motion.div className="date-heure"
variants={dateHeureVariants}
initial={props.comesFromPageArtist ? "exit" : "default"}
animate={isHovered ? "hover" : "default"}
exit={isSwitching ? "exit" : "default"}
>
<h4
>{props.date}</h4>
<motion.h4
variants={heureVariants}
initial="default"
animate={isHovered ? "hover" : "default"}
exit={isSwitching ? "exit" : "default"}
>{props.heure}</motion.h4>
</motion.div>
</motion.div>
</Link>
</motion.div>
)
}
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';
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;
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[][];
const listeGroupes: Groupe[] = [];
const listeArtistes: Artiste[] = [];
console.log(groupedData);
groupedData.forEach((groupArray) => {
let groupeObj: Partial<Groupe> = {};
let artisteObj: Partial<Artiste> = {};
groupArray.forEach((item) => {
if ('nomG' in item) {
groupeObj = { ...groupeObj, ...item }; // Copier les infos du groupe
} else if ('nomDeSceneMG' in item) {
artisteObj = { ...artisteObj, ...item }; // Copier les infos de l'artiste
} else if ('dateDebutE' in item) {
// S'assurer que l'évènement correspond au groupe ou à l'artiste actuellement traité
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;
}
}
});
if (groupeObj.idG != null) {
listeGroupes.push(groupeObj as Groupe);
}
if (artisteObj.nomDeSceneMG != null) {
listeArtistes.push(artisteObj as Artiste);
}
});
setLesGroupes(listeGroupes);
console.log("listeGroupes : ")
console.log(listeGroupes)
listeGroupes.forEach((groupe) => {
groupePassageMap.current.set(groupe.idG, {
datePassage: groupe.datePassage,
heurePassage: groupe.heurePassage,
});
});
setLesArtistes(listeArtistes);
console.log("listeArtistes : ")
console.log(listeArtistes)
});
}, []);
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}
>
PROGRAMMATION
<Combo title="DATE" choices={["Tout", "21 Juillet", "22 Juillet", "23 Juillet"]} currentChoice={filtreDate} setCurrentChoice={setFiltreDate} />
<Combo title="AFFICHAGE" choices={["Grille", "Horaires"]} currentChoice={filtreAffichage} setCurrentChoice={setFiltreAffichage} />
<Combo title="GENRE" choices={["Tout", "Rap", "Rock", "Pop"]} currentChoice={filtreGenre} setCurrentChoice={setFiltreGenre} />
{
lesGroupes.map((groupe) => (
))
}
{
lesArtistes.map((artiste) => {
const groupeInfo = groupePassageMap.current.get(artiste.idG);
return (
<CarteProgrammation
key={artiste.idMG}
id={artiste.idMG}
nomArtiste={artiste.nomDeSceneMG}
description={artiste.descriptionA}
// date inconnue si l'artiste n'a pas de groupe associé
date={groupeInfo?.datePassage ?? "Date inconnue"}
heure={groupeInfo?.heurePassage ?? "Heure inconnue"}
setIsNavTransparent={props.setIsNavTransparent}
/>
)
})
}
</motion.div>
</>
)
}