source: frontend/src/components/userProfile/UserListModal.tsx@ d85e8e3

main
Last change on this file since d85e8e3 was 1579b4f, checked in by Filip Gavrilovski <filipgavrilovski28@…>, 5 months ago

refactor artist, collection, listener components to have similar style as other components; refactor some dto-s

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[2b08bed]1import { useNavigate } from "react-router-dom";
[1579b4f]2import { baseURL } from "../../api/axiosInstance";
[2b08bed]3import type { BaseNonAdminUser } from "../../utils/types";
4
5interface ModalProps {
[cb4a1da]6 title: string;
7 users: BaseNonAdminUser[];
8 onClose: () => void;
9 onFollowToggle: (targetUsername: string) => Promise<void>;
[2b08bed]10}
11
12const UserListModal = ({
[cb4a1da]13 title,
14 users,
15 onClose,
16 onFollowToggle,
[2b08bed]17}: ModalProps) => {
[cb4a1da]18 const navigate = useNavigate();
[2b08bed]19
[cb4a1da]20 return (
[1579b4f]21 <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
22 <div className="bg-[#1a1a2e] border border-white/10 rounded-xl shadow-2xl w-full max-w-md max-h-[70vh] flex flex-col">
23 <div className="p-4 border-b border-white/10 flex justify-between items-center">
24 <h2 className="text-xl font-bold text-white">{title}</h2>
[cb4a1da]25 <button
26 onClick={onClose}
[1579b4f]27 className="text-gray-400 hover:text-white text-2xl cursor-pointer transition-colors"
[cb4a1da]28 >
29 &times;
30 </button>
31 </div>
[2b08bed]32
[cb4a1da]33 <div className="overflow-y-auto p-4 flex-1">
34 {users.length === 0 ? (
35 <p className="text-center text-gray-500 py-8">No users found.</p>
36 ) : (
37 users.map((u) => (
38 <div
39 key={u.username}
[1579b4f]40 className="flex items-center justify-between p-3 hover:bg-white/5 rounded-lg transition-colors"
[cb4a1da]41 >
42 <div
43 className="flex items-center gap-4 cursor-pointer flex-1"
44 onClick={() => {
45 onClose();
46 navigate(`/users/${u.username}`);
47 }}
48 >
[1579b4f]49 <div className="w-10 h-10 rounded-full bg-[#282828] overflow-hidden shrink-0 flex items-center justify-center">
[cb4a1da]50 {u.profilePhoto ? (
51 <img
52 src={`${baseURL}/${u.profilePhoto}`}
53 className="w-full h-full object-cover"
54 alt=""
55 />
56 ) : (
[1579b4f]57 <span className="text-[#1db954] font-bold">
[cb4a1da]58 {u.fullName.charAt(0)}
59 </span>
60 )}
61 </div>
[1579b4f]62 <div>
63 <p className="font-semibold text-white">{u.fullName}</p>
64 <p className="text-sm text-gray-400">@{u.username}</p>
65 </div>
[cb4a1da]66 </div>
[2b08bed]67
[cb4a1da]68 <button
69 onClick={() => onFollowToggle(u.username)}
[1579b4f]70 className={`px-4 py-1.5 text-sm font-medium rounded-full transition-colors cursor-pointer ${
[cb4a1da]71 u.isFollowedByCurrentUser
[1579b4f]72 ? "bg-white/10 text-white hover:bg-white/20"
73 : "bg-[#1db954] text-black hover:bg-[#1ed760]"
[cb4a1da]74 }`}
75 >
[1579b4f]76 {u.isFollowedByCurrentUser ? "Following" : "Follow"}
[cb4a1da]77 </button>
78 </div>
79 ))
80 )}
81 </div>
82 </div>
83 <div className="absolute inset-0 -z-10" onClick={onClose}></div>
84 </div>
85 );
[2b08bed]86};
87
88export default UserListModal;
Note: See TracBrowser for help on using the repository browser.