From cff1620d3da83eafe352b0dc733556f56570355b Mon Sep 17 00:00:00 2001 From: mtheusreis Date: Mon, 23 Nov 2026 12:01:25 -0300 Subject: [PATCH] =?UTF-8?q?feat(profile):=20Aba=20de=20listas=20curtidas,?= =?UTF-8?q?=20criadas=20e=20salvas=20pelo=20usuario=20com=20exbi=C3=A7?= =?UTF-8?q?=C3=A3o=20por=20filtro=20dentro=20do=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/profile/Sections/ProfileNavBar.jsx | 79 ++- .../src/pages/profile/Sections/UserLists.jsx | 484 ++++++++++++++++++ frontend/src/pages/profile/index.jsx | 27 +- 3 files changed, 535 insertions(+), 55 deletions(-) create mode 100644 frontend/src/pages/profile/Sections/UserLists.jsx diff --git a/frontend/src/pages/profile/Sections/ProfileNavBar.jsx b/frontend/src/pages/profile/Sections/ProfileNavBar.jsx index a2c0cb2..c15c65e 100644 --- a/frontend/src/pages/profile/Sections/ProfileNavBar.jsx +++ b/frontend/src/pages/profile/Sections/ProfileNavBar.jsx @@ -1,48 +1,33 @@ -import {Gamepad2, Calendar, TableProperties, Heart, Trophy} from "lucide-react" +import { Gamepad2, Calendar, TableProperties, Heart, Trophy } from "lucide-react"; -export default function ProfileNavBar() { - return ( -
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- ) -} \ No newline at end of file +const NAV_ITEMS = [ + { id: "jogos", label: "Jogos", icon: Gamepad2, iconClass: "" }, + { id: "diario", label: "Diário", icon: Calendar, iconClass: "" }, + { id: "listas", label: "Listas", icon: TableProperties, iconClass: "" }, + { id: "curtidos", label: "Curtidos", icon: Heart, iconClass: "text-red-500" }, + { id: "100%", label: "100%", icon: Trophy, iconClass: "text-yellow-500" }, +]; + +export default function ProfileNavBar({ activeTab = "jogos", onTabChange }) { + return ( +
+ {NAV_ITEMS.map(({ id, label, icon: Icon, iconClass }) => { + const isActive = activeTab === id; + return ( + + ); + })} +
+ ); +} \ No newline at end of file diff --git a/frontend/src/pages/profile/Sections/UserLists.jsx b/frontend/src/pages/profile/Sections/UserLists.jsx new file mode 100644 index 0000000..0431fa4 --- /dev/null +++ b/frontend/src/pages/profile/Sections/UserLists.jsx @@ -0,0 +1,484 @@ +import React, { useState, useMemo } from "react"; +import { Link, useParams } from "react-router-dom"; +import { Eye, EyeOff, Heart, Pencil, Plus, X, ArrowUpDown, Filter } from "lucide-react"; + +import gtaImg from "../../../assets/imgs/gta.png"; +import gowImg from "../../../assets/imgs/ragnarok.png"; +import silksongImg from "../../../assets/imgs/silksong.png"; +import rdr2Img from "../../../assets/imgs/rdr2.jpg"; +import cyberpunkImg from "../../../assets/imgs/cyberpunk2077.png"; +import clairImg from "../../../assets/imgs/clair-obscure.png"; + +// Catálogo mock para adicionar jogos no modal +const AVAILABLE_GAMES = [ + { id: 1, title: "GTA VI", url: gtaImg }, + { id: 2, title: "God of War", url: gowImg }, + { id: 3, title: "Red Dead Redemption 2", url: rdr2Img }, + { id: 4, title: "Hollow Knight: Silksong", url: silksongImg }, + { id: 5, title: "Clair Obscur: Expedition 33", url: clairImg }, + { id: 6, title: "Cyberpunk 2077", url: cyberpunkImg }, +]; + +// IDs "1", "2" e "3" batem com o mock atual do ListDetail; listas extras sem ID correspondente vão para "/lists" +const INITIAL_USER_LISTS = [ + { + id: "1", + detailPath: "/lists/1", + name: "Favoritos", + author: "gamer123", + isOwner: true, + isPublic: true, + likes: 15000, + createdAt: "2026-10-15T14:00:00Z", + interactedAt: "2026-10-15T14:00:00Z", + games: [AVAILABLE_GAMES[1], AVAILABLE_GAMES[0], AVAILABLE_GAMES[3], AVAILABLE_GAMES[4], AVAILABLE_GAMES[5]], + }, + { + id: "2", + detailPath: "/lists/2", + name: "Jogos que me fizeram chorar", + author: "player456", + isOwner: false, + isPublic: true, + likes: 87, + createdAt: "2026-08-10T12:00:00Z", + interactedAt: "2026-11-18T20:00:00Z", + games: [AVAILABLE_GAMES[1], AVAILABLE_GAMES[3], AVAILABLE_GAMES[4]], + }, + { + id: "3", + detailPath: "/lists/3", + name: "Open worlds imperdíveis", + author: "gamelover789", + isOwner: false, + isPublic: true, + likes: 204, + createdAt: "2026-07-05T09:00:00Z", + interactedAt: "2026-11-10T16:45:00Z", + games: [AVAILABLE_GAMES[0], AVAILABLE_GAMES[5], AVAILABLE_GAMES[2]], + }, + { + id: "4", + detailPath: "/lists", + name: "Quero Jogar", + author: "gamer123", + isOwner: true, + isPublic: false, + likes: 1, + createdAt: "2026-11-02T10:30:00Z", + interactedAt: "2026-11-02T10:30:00Z", + games: [AVAILABLE_GAMES[3], AVAILABLE_GAMES[4], AVAILABLE_GAMES[0], AVAILABLE_GAMES[2]], + }, + { + id: "5", + detailPath: "/lists", + name: "Platinados", + author: "gamer123", + isOwner: true, + isPublic: true, + likes: 10000, + createdAt: "2026-09-20T18:15:00Z", + interactedAt: "2026-09-20T18:15:00Z", + games: [AVAILABLE_GAMES[1], AVAILABLE_GAMES[2], AVAILABLE_GAMES[5], AVAILABLE_GAMES[3]], + }, +]; + +function formatLikes(num) { + if (num >= 1000) return `${(num / 1000).toFixed(num % 1000 === 0 ? 0 : 1)}k`; + return String(num); +} + +// Pilha horizontal de capas +function OverlappingCovers({ games }) { + const visible = games.slice(0, 5); + return ( +
+ {visible.length > 0 ? ( + visible.map((game, idx) => ( +
+ {game.title} +
+ )) + ) : ( +
+ Sem jogos +
+ )} +
+ ); +} + +// Modal de Criar / Editar Lista +function EditListModal({ isOpen, onClose, onSave, initialData }) { + const [name, setName] = useState(""); + const [isPublic, setIsPublic] = useState(true); + const [gameQuery, setGameQuery] = useState(""); + const [selectedGames, setSelectedGames] = useState([]); + + React.useEffect(() => { + if (initialData) { + setName(initialData.name); + setIsPublic(initialData.isPublic); + setSelectedGames(initialData.games || []); + } else { + setName(""); + setIsPublic(true); + setSelectedGames([]); + } + setGameQuery(""); + }, [initialData, isOpen]); + + if (!isOpen) return null; + + const searchResults = AVAILABLE_GAMES.filter((g) => + g.title.toLowerCase().includes(gameQuery.toLowerCase()) + ); + + const handleAddGame = (game) => { + if (!selectedGames.some((g) => g.id === game.id)) { + setSelectedGames((prev) => [...prev, game]); + } + }; + + const handleRemoveGame = (id) => { + setSelectedGames((prev) => prev.filter((g) => g.id !== id)); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + if (!name.trim()) return; + onSave({ name: name.trim(), isPublic, games: selectedGames }); + onClose(); + }; + + return ( +
+
e.stopPropagation()} + className="bg-[#2c2c2c] border border-white/15 rounded-2xl w-full max-w-xl p-6 shadow-2xl text-white flex flex-col gap-6" + > +
+

+ {initialData ? "Editar Lista" : "Adicionar Lista"} +

+ +
+ + {/* Campos superiores: Nome/Visibilidade à esquerda e Busca de jogos à direita */} +
+
+
+ + setName(e.target.value)} + placeholder="Ex: Favoritos" + className="w-full bg-white text-black text-sm rounded-full px-4 py-1.5 outline-none focus:ring-2 focus:ring-purple-500" + /> +
+ +
+ Público? + + +
+
+ +
+ + setGameQuery(e.target.value)} + placeholder="Buscar jogo..." + className="w-full bg-white text-black text-sm rounded-full px-4 py-1.5 outline-none focus:ring-2 focus:ring-purple-500" + /> +
+ {searchResults.slice(0, 3).map((game) => ( +
+ {game.title} + +
+ ))} +
+
+
+ + {/* Jogos Adicionados */} +
+

Jogos Adicionados

+ {selectedGames.length > 0 ? ( +
+ {selectedGames.map((game) => ( +
+ {game.title} + +
+ ))} +
+ ) : ( +

+ Clique no "+" nos jogos acima para adicionar à lista. +

+ )} +
+ +
+ +
+
+
+ ); +} + +export default function UserLists() { + const { username } = useParams(); + const [lists, setLists] = useState(INITIAL_USER_LISTS); + const [originFilter, setOriginFilter] = useState("all"); // all | created | liked + const [sortBy, setSortBy] = useState("recent"); // recent | oldest | alpha-asc | alpha-desc + const [modalOpen, setModalOpen] = useState(false); + const [editingList, setEditingList] = useState(null); + + const filteredAndSortedLists = useMemo(() => { + const byOrigin = lists.filter((list) => { + if (originFilter === "created") return list.isOwner; + if (originFilter === "liked") return !list.isOwner; + return true; + }); + + return [...byOrigin].sort((a, b) => { + if (sortBy === "alpha-asc") return a.name.localeCompare(b.name, "pt-BR"); + if (sortBy === "alpha-desc") return b.name.localeCompare(a.name, "pt-BR"); + const dateA = new Date(a.interactedAt || a.createdAt).getTime(); + const dateB = new Date(b.interactedAt || b.createdAt).getTime(); + return sortBy === "oldest" ? dateA - dateB : dateB - dateA; + }); + }, [lists, originFilter, sortBy]); + + const handleSaveList = (data) => { + if (editingList) { + setLists((prev) => + prev.map((l) => (l.id === editingList.id ? { ...l, ...data } : l)) + ); + setEditingList(null); + } else { + const now = new Date().toISOString(); + const newList = { + id: String(Date.now()), + detailPath: "/lists", + ...data, + author: username || "gamer123", + isOwner: true, + likes: 0, + createdAt: now, + interactedAt: now, + }; + setLists((prev) => [newList, ...prev]); + } + }; + + const openCreateModal = () => { + setEditingList(null); + setModalOpen(true); + }; + + const openEditModal = (list) => { + setEditingList(list); + setModalOpen(true); + }; + + return ( +
+ { + setModalOpen(false); + setEditingList(null); + }} + onSave={handleSaveList} + initialData={editingList} + /> + + {/* Cabeçalho da seção + Controles de Filtro (Origem e Exibição) */} +
+

Suas Listas

+ +
+ {/* Filtro 1: Origem */} +
+ + Origem: + +
+ + {/* Filtro 2: Exibição (Ordenação) */} +
+ + Exibição: + +
+
+
+ + {/* Lista vertical das coleções */} +
+ {filteredAndSortedLists.length > 0 ? ( + filteredAndSortedLists.map((list) => { + const targetPath = list.detailPath || "/lists"; + return ( +
+
+ + {list.name} + + {!list.isOwner && ( + + Curtida · @{list.author} + + )} +
+ +
+ + + + + {/* Metadados laterais (Público/Privado, Curtidas, X jogos + Lápis) */} +
+
+ {list.isPublic ? ( + <> + + Pública + + ) : ( + <> + + Privada + + )} +
+ +
+ + {formatLikes(list.likes)} +
+ +
+ {list.games.length} jogos + {list.isOwner && ( + + )} +
+
+
+
+ ); + }) + ) : ( +

+ Nenhuma lista encontrada. +

+ )} +
+ + {/* Botão "Adicionar Lista" alinhado à direita */} +
+ +
+
+ ); +} \ No newline at end of file diff --git a/frontend/src/pages/profile/index.jsx b/frontend/src/pages/profile/index.jsx index 6a40846..6f357e5 100644 --- a/frontend/src/pages/profile/index.jsx +++ b/frontend/src/pages/profile/index.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; // Componentes já criados import Navbar from '../../components/Navbar'; // Ajuste o caminho conforme sua estrutura @@ -7,8 +7,11 @@ import ProfileNavBar from './Sections/ProfileNavBar'; import Favorites from './Sections/Favorites'; import Completed from './Sections/Completed'; import RecentReviews from './Sections/RecentReviews'; +import UserLists from './Sections/UserLists'; export default function ProfilePage() { + const [activeTab, setActiveTab] = useState('jogos'); + return ( // Container Mestre: Ocupa no mínimo a tela toda, fundo escuro, flex em coluna
@@ -23,16 +26,24 @@ export default function ProfilePage() {
-
+
+ +
- {/* Jogos Favoritos */} -
+ {activeTab === 'listas' ? ( +
+ ) : ( + <> + {/* Jogos Favoritos */} +
- {/* Jogos Completados */} -
+ {/* Jogos Completados */} +
- {/* Últimas Avaliações */} -
+ {/* Últimas Avaliações */} +
+ + )}