source: frontend/src/components/userProfile/UserListModal.tsx@ 1579b4f

main
Last change on this file since 1579b4f 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
Line 
1import { useNavigate } from "react-router-dom";
2import { baseURL } from "../../api/axiosInstance";
3import type { BaseNonAdminUser } from "../../utils/types";
4
5interface ModalProps {
6 title: string;
7 users: BaseNonAdminUser[];
8 onClose: () => void;
9 onFollowToggle: (targetUsername: string) => Promise<void>;
10}
11
12const UserListModal = ({
13 title,
14 users,
15 onClose,
16 onFollowToggle,
17}: ModalProps) => {
18 const navigate = useNavigate();
19
20 return (
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>
25 <button
26 onClick={onClose}
27 className="text-gray-400 hover:text-white text-2xl cursor-pointer transition-colors"
28 >
29 &times;
30 </button>
31 </div>
32
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}
40 className="flex items-center justify-between p-3 hover:bg-white/5 rounded-lg transition-colors"
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 >
49 <div className="w-10 h-10 rounded-full bg-[#282828] overflow-hidden shrink-0 flex items-center justify-center">
50 {u.profilePhoto ? (
51 <img
52 src={`${baseURL}/${u.profilePhoto}`}
53 className="w-full h-full object-cover"
54 alt=""
55 />
56 ) : (
57 <span className="text-[#1db954] font-bold">
58 {u.fullName.charAt(0)}
59 </span>
60 )}
61 </div>
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>
66 </div>
67
68 <button
69 onClick={() => onFollowToggle(u.username)}
70 className={`px-4 py-1.5 text-sm font-medium rounded-full transition-colors cursor-pointer ${
71 u.isFollowedByCurrentUser
72 ? "bg-white/10 text-white hover:bg-white/20"
73 : "bg-[#1db954] text-black hover:bg-[#1ed760]"
74 }`}
75 >
76 {u.isFollowedByCurrentUser ? "Following" : "Follow"}
77 </button>
78 </div>
79 ))
80 )}
81 </div>
82 </div>
83 <div className="absolute inset-0 -z-10" onClick={onClose}></div>
84 </div>
85 );
86};
87
88export default UserListModal;
Note: See TracBrowser for help on using the repository browser.