-
-
+
+
\ No newline at end of file
diff --git a/watchgether/js/list.js b/watchgether/js/list.js
index c8bf981..0777454 100644
--- a/watchgether/js/list.js
+++ b/watchgether/js/list.js
@@ -1,7 +1,46 @@
let allMovies = []; // Stockage local de la liste entière
+window.onload = () => {
+ loadList();
+ document.getElementById('sortOrder').addEventListener('change', renderList);
+ document.getElementById('filterType').addEventListener('change', renderList);
+ document.getElementById('filterStatus').addEventListener('change', renderList);
+}
+
+async function apiRequest(action, params = {}) {
+ try {
+ const response = await fetch('../RequestHandler.php', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({ action, params })
+ });
+ return await response.json();
+ } catch (error) {
+ console.error("Erreur API:", error);
+ return { success: false, error: "Erreur de connexion au serveur" };
+ }
+}
+
+async function addMovie(tmdbId, title, posterPath, type) {
+ const result = await apiRequest('addMovie', {
+ tmdb_id: tmdbId,
+ titre: title,
+ affiche_path: posterPath,
+ type: type
+ });
+
+ if (result.success) {
+ alert(`"${title}" a été ajouté à votre liste ! 🍿`);
+ closeModal();
+ } else {
+ alert('Erreur lors de l\'ajout. Vérifie si le film n\'est pas déjà présent.');
+ }
+}
+
async function loadList() {
- const response = await fetch('RequestHandler.php', {
+ const response = await fetch('../RequestHandler.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'getMyList' })
@@ -40,28 +79,74 @@ function renderList() {
filtered.forEach(m => {
const card = document.createElement('div');
- card.className = `relative group bg-slate-800 rounded-xl overflow-hidden border ${m.vu == 1 ? 'border-green-500/50' : 'border-slate-700'}`;
- card.innerHTML = `
-
-
${m.titre}
-
-
-
+ // On ajoute 'flex flex-col' pour que le contenu s'empile proprement
+ card.className = `relative group bg-slate-800 rounded-xl overflow-hidden border ${m.vu == 1 ? 'border-green-500/50' : 'border-slate-700'} flex flex-col h-full`;
+
+ if (currentView === 'partner') {
+ card.innerHTML = `
+
+
-
- `;
+
+
+
${m.titre}
+
+
+
+
+
+ `;
+
+ } else if (currentView === 'common') {
+
+ card.innerHTML = `
+
+

+
+
+
+
${m.titre}
+
+
+
+
+
+ `;
+ } else {
+ card.innerHTML = `
+
+

+
+
+
+
${m.titre}
+
+
+
+
+
+
+ `;
+ }
+
grid.appendChild(card);
});
}
// Actions rapides
async function toggleVu(id) {
- const res = await fetch('RequestHandler.php', {
+ const res = await fetch('../RequestHandler.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'toggleViewed', params: { movie_id: id } })
@@ -77,7 +162,7 @@ async function toggleVu(id) {
async function deleteMovie(id) {
if(!confirm("Supprimer ce film de ta liste ?")) return;
- const res = await fetch('RequestHandler.php', {
+ const res = await fetch('../RequestHandler.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'deleteMovie', params: { movie_id: id } })
@@ -89,4 +174,127 @@ async function deleteMovie(id) {
}
}
+let currentView = 'my'; // 'my', 'common', ou 'partner'
+
+async function switchTab(view) {
+ currentView = view;
+
+ // Mise à jour visuelle des boutons
+ const tabs = ['my', 'common', 'partner'];
+ tabs.forEach(t => {
+ const btn = document.getElementById(`tab-${t}`);
+ if (t === view) {
+ btn.classList.replace('bg-slate-700/50', 'bg-slate-800');
+ btn.classList.replace('text-gray-400', 'text-white');
+ btn.classList.replace('border-transparent', 'border-blue-500');
+ } else {
+ btn.classList.replace('bg-slate-800', 'bg-slate-700/50');
+ btn.classList.replace('text-white', 'text-gray-400');
+ btn.classList.replace('border-blue-500', 'border-transparent');
+ }
+ });
+
+ // On recharge les données selon la vue
+ let action = 'getMyList';
+ if (view === 'common') action = 'getCommonList';
+ if (view === 'partner') action = 'getPartnerList'; // Il faudra créer cette action dans RequestHandler
+
+ const response = await apiRequest(action);
+ if (response.success) {
+ allMovies = response.movies || response.common_movies;
+ renderList();
+ }
+}
+
+async function showDetails(tmdbId, type, localId = null, isVu = 0) {
+ // 1. On récupère les détails complets via TMDB (comme dans search.js)
+ const mediaType = (type === 'serie') ? 'tv' : 'movie';
+
+ // On appelle ton RequestHandler pour avoir les détails + acteurs
+ const movie = await apiRequest('getMovieDetails', { id: tmdbId, type: mediaType });
+ if (!movie) return;
+
+ // 2. On remplit la modal avec les infos fraîches
+ document.getElementById('modalTitle').innerText = movie.title || movie.name;
+
+ const year = (movie.release_date || movie.first_air_date || "").substring(0, 4);
+ const duration = movie.runtime ? `${movie.runtime} min` : (movie.number_of_seasons ? `${movie.number_of_seasons} Saison(s)` : "");
+ const genres = movie.genres.map(g => g.name).join(', ');
+ document.getElementById('modalMeta').innerText = `${year} • ${genres} ${duration ? '• ' + duration : ''}`;
+
+ document.getElementById('modalOverview').innerText = movie.overview || "Aucun synopsis disponible.";
+ document.getElementById('modalVote').innerText = movie.vote_average ? movie.vote_average.toFixed(1) : "N/A";
+
+ // Image de bannière
+ const bannerUrl = movie.backdrop_path ? `https://image.tmdb.org/t/p/original${movie.backdrop_path}` : '';
+ document.getElementById('modalBanner').style.backgroundImage = `url(${bannerUrl})`;
+
+ // Réalisateur
+ const director = movie.credits.crew.find(person => person.job === 'Director');
+ document.getElementById('modalDirector').innerText = director ? director.name : "Non renseigné";
+
+ // Casting
+ const castContainer = document.getElementById('modalCast');
+ castContainer.innerHTML = movie.credits.cast.slice(0, 8).map(actor => `
+
+

+
${actor.name}
+
+ `).join('');
+
+ // 3. LOGIQUE DU BOUTON (Vu / Pas Vu)
+ const btn = document.getElementById('modalMainBtn');
+ const ratingZone = document.getElementById('ratingZone');
+
+ if (localId) {
+ ratingZone.classList.remove('hidden'); // On montre les étoiles
+
+ if (isVu == 1) {
+ btn.innerText = "NE PLUS MARQUER COMME VU";
+ btn.className = "w-full bg-slate-700 hover:bg-slate-600 text-white py-4 rounded-xl font-black transition-all";
+ } else {
+ btn.innerText = "MARQUER COMME VU";
+ btn.className = "w-full bg-green-600 hover:bg-green-500 text-white py-4 rounded-xl font-black transition-all";
+ }
+
+ btn.onclick = async () => {
+ await toggleVu(localId); // Ta fonction qui change le statut en BDD
+ closeModal();
+ };
+ }
+
+ // 4. LOGIQYUE DES ÉTOILES
+ // On récupère la note actuelle pour ce film (si elle existe)
+ apiRequest('getStarsRating', { movie_id: localId }).then(res => {
+ if (res.success) {
+ const currentRating = res.rating || 0;
+ setRating(currentRating); // On affiche la note actuelle
+ }
+ });
+
+ // Affichage final
+ document.getElementById('movieModal').classList.remove('hidden');
+ document.body.style.overflow = 'hidden';
+}
+
+// Fonction pour les étoiles
+function setRating(note) {
+ const currentMovieId = document.getElementById('modalMainBtn').onclick.toString().match(/toggleVu\((\d+)\)/)[1]; // Extraction de l'ID du film
+ const stars = document.querySelectorAll('#starContainer span');
+ stars.forEach((star, index) => {
+ if (index < note) {
+ star.classList.replace('text-gray-600', 'text-yellow-400');
+ } else {
+ star.classList.replace('text-yellow-400', 'text-gray-600');
+ }
+ });
+ apiRequest('setStarsRating', { movie_id: currentMovieId, rating: note }); // currentMovieId doit être défini lors de l'ouverture de la modal
+}
+
+function closeModal() {
+ document.getElementById('movieModal').classList.add('hidden');
+ document.body.style.overflow = 'auto';
+}
+
loadList();
\ No newline at end of file
diff --git a/watchgether/js/index.js b/watchgether/js/search.js
similarity index 87%
rename from watchgether/js/index.js
rename to watchgether/js/search.js
index 6640eac..825abda 100644
--- a/watchgether/js/index.js
+++ b/watchgether/js/search.js
@@ -7,7 +7,7 @@
*/
async function apiRequest(action, params = {}) {
try {
- const response = await fetch('RequestHandler.php', {
+ const response = await fetch('../RequestHandler.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -21,6 +21,8 @@ async function apiRequest(action, params = {}) {
}
}
+document.getElementById('ratingZone').classList.add('hidden');
+
// --- RECHERCHE ---
/**
@@ -116,7 +118,13 @@ async function showDetails(id, type) {
// 5. Bouton Ajouter (on passe les infos pour la BDD)
const simplifiedType = (mediaType === 'tv') ? 'serie' : 'film';
- document.getElementById('modalAddBtn').onclick = () => addMovie(movie.id, movie.title || movie.name, movie.poster_path, simplifiedType);
+ const btn = document.getElementById('modalMainBtn');
+ btn.innerText = "+ AJOUTER À LA LISTE";
+ btn.className = "w-full bg-blue-600 hover:bg-blue-500 text-white py-4 rounded-xl font-black shadow-lg transition-all active:scale-95";
+ btn.onclick = () => addMovie(movie.id, movie.title || movie.name, movie.poster_path, simplifiedType);
+
+ // Cache les étoiles en mode recherche
+ document.getElementById('ratingZone').classList.add('hidden');
// Affichage
modal.classList.remove('hidden');
@@ -157,4 +165,16 @@ document.getElementById('searchInput').addEventListener('keypress', function (e)
if (e.key === 'Enter') {
performSearch();
}
-});
\ No newline at end of file
+});
+
+async function LogOut() {
+ const res = await fetch('../RequestHandler.php', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ action: 'logout' })
+ });
+ const data = await res.json();
+ if (data.success) {
+ window.location.href = '../index.php';
+ }
+}
\ No newline at end of file
diff --git a/watchgether/ma-liste/index.php b/watchgether/ma-liste/index.php
index d17a2cc..d0e1487 100644
--- a/watchgether/ma-liste/index.php
+++ b/watchgether/ma-liste/index.php
@@ -1,3 +1,11 @@
+
+
@@ -10,7 +18,24 @@
+
+
+
+
+
+
+
@@ -50,7 +75,7 @@
-
+
diff --git a/watchgether/modal-template.php b/watchgether/modal-template.php
index e8c80b2..2b4d5b2 100644
--- a/watchgether/modal-template.php
+++ b/watchgether/modal-template.php
@@ -1,4 +1,4 @@
-
+
@@ -34,12 +33,25 @@
/ 10
+
Réalisateur
-
diff --git a/watchgether/search/index.php b/watchgether/search/index.php
new file mode 100644
index 0000000..3deed23
--- /dev/null
+++ b/watchgether/search/index.php
@@ -0,0 +1,45 @@
+
+
+
+
+
+