2026-01-07 09:31:02 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { Button } from '../../ui/button';
|
|
|
|
|
import { X, Search, Plus, Check } from 'lucide-react';
|
|
|
|
|
import { useToast } from '../../../context/ToastContext';
|
2026-01-07 18:39:21 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
interface AddToPlaylistModalProps {
|
2026-01-13 18:47:57 +00:00
|
|
|
onClose: () => void;
|
|
|
|
|
onAdd: (playlistIds: string[]) => void;
|
2026-01-07 09:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mock user playlists
|
2026-01-07 10:15:48 +00:00
|
|
|
const MOCK_USER_PLAYLISTS: any[] = [
|
2026-01-13 18:47:57 +00:00
|
|
|
{
|
|
|
|
|
id: 'p1',
|
|
|
|
|
title: 'Cyberpunk Essentials',
|
|
|
|
|
creator: 'Cyber_Producer',
|
|
|
|
|
userId: 'u1',
|
|
|
|
|
is_public: true,
|
|
|
|
|
cover_url: 'https://picsum.photos/100',
|
|
|
|
|
track_count: 45,
|
|
|
|
|
likes: 120,
|
|
|
|
|
tags: [],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'p2',
|
|
|
|
|
title: 'Late Night Coding',
|
|
|
|
|
creator: 'Cyber_Producer',
|
|
|
|
|
userId: 'u1',
|
|
|
|
|
is_public: false,
|
|
|
|
|
cover_url: 'https://picsum.photos/101',
|
|
|
|
|
track_count: 22,
|
|
|
|
|
likes: 15,
|
|
|
|
|
tags: [],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'p3',
|
|
|
|
|
title: 'Gym Phonk',
|
|
|
|
|
creator: 'Cyber_Producer',
|
|
|
|
|
userId: 'u1',
|
|
|
|
|
is_public: true,
|
|
|
|
|
cover_url: 'https://picsum.photos/102',
|
|
|
|
|
track_count: 105,
|
|
|
|
|
likes: 300,
|
|
|
|
|
tags: [],
|
|
|
|
|
},
|
2026-01-07 09:31:02 +00:00
|
|
|
];
|
|
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
export const AddToPlaylistModal: React.FC<AddToPlaylistModalProps> = ({
|
|
|
|
|
onClose,
|
|
|
|
|
onAdd,
|
|
|
|
|
}) => {
|
|
|
|
|
const { addToast } = useToast();
|
|
|
|
|
const [search, setSearch] = useState('');
|
|
|
|
|
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
const filteredPlaylists = MOCK_USER_PLAYLISTS.filter((p) =>
|
|
|
|
|
p.title.toLowerCase().includes(search.toLowerCase()),
|
|
|
|
|
);
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
const toggleSelection = (id: string) => {
|
|
|
|
|
setSelectedIds((prev) =>
|
|
|
|
|
prev.includes(id) ? prev.filter((pid) => pid !== id) : [...prev, id],
|
|
|
|
|
);
|
|
|
|
|
};
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
const handleConfirm = () => {
|
|
|
|
|
if (selectedIds.length === 0) return;
|
|
|
|
|
onAdd(selectedIds);
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
return (
|
|
|
|
|
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
|
|
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 bg-kodo-void/90 backdrop-blur-sm"
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
></div>
|
|
|
|
|
<div className="relative w-full max-w-md bg-kodo-graphite border border-kodo-steel rounded-xl shadow-2xl animate-scaleIn overflow-hidden flex flex-col max-h-[70vh]">
|
|
|
|
|
<div className="p-4 border-b border-kodo-steel bg-kodo-ink flex justify-between items-center">
|
|
|
|
|
<h3 className="font-bold text-white">Add to Playlist</h3>
|
|
|
|
|
<button onClick={onClose}>
|
2026-01-16 00:59:31 +00:00
|
|
|
<X className="w-5 h-5 text-kodo-content-dim hover:text-white" />
|
2026-01-13 18:47:57 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<div className="p-4">
|
|
|
|
|
<div className="relative mb-4">
|
|
|
|
|
<input
|
2026-01-16 10:40:13 +00:00
|
|
|
className="w-full bg-kodo-void border border-kodo-steel rounded-lg py-2 pl-9 pr-4 text-white text-sm focus:border-kodo-steel outline-none"
|
2026-01-13 18:47:57 +00:00
|
|
|
placeholder="Find playlist"
|
|
|
|
|
value={search}
|
|
|
|
|
onChange={(e) => setSearch(e.target.value)}
|
|
|
|
|
autoFocus
|
|
|
|
|
/>
|
2026-01-16 00:59:31 +00:00
|
|
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-kodo-content-dim" />
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
2026-01-07 10:15:48 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
2026-01-16 09:51:30 +00:00
|
|
|
className="w-full justify-start border border-dashed border-kodo-steel mb-4 hover:border-kodo-steel/50 hover:text-white group"
|
2026-01-13 18:47:57 +00:00
|
|
|
onClick={() => addToast('New Playlist Flow')}
|
|
|
|
|
>
|
2026-01-16 10:00:12 +00:00
|
|
|
<div className="w-8 h-8 bg-kodo-steel rounded flex items-center justify-center mr-3 group-hover:bg-white/5">
|
2026-01-13 18:47:57 +00:00
|
|
|
<Plus className="w-4 h-4" />
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-sm font-bold">New Playlist</span>
|
|
|
|
|
</Button>
|
2026-01-07 10:15:48 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<div className="space-y-1 overflow-y-auto max-h-64 custom-scrollbar">
|
|
|
|
|
{filteredPlaylists.map((playlist) => (
|
|
|
|
|
<div
|
|
|
|
|
key={playlist.id}
|
|
|
|
|
onClick={() => toggleSelection(playlist.id)}
|
|
|
|
|
className={`flex items-center p-2 rounded cursor-pointer group transition-colors ${selectedIds.includes(playlist.id) ? 'bg-kodo-cyan/10' : 'hover:bg-white/5'}`}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={playlist.cover_url}
|
|
|
|
|
className="w-10 h-10 rounded object-cover mr-3"
|
|
|
|
|
/>
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<div
|
|
|
|
|
className={`text-sm font-bold truncate ${selectedIds.includes(playlist.id) ? 'text-kodo-cyan' : 'text-white'}`}
|
|
|
|
|
>
|
|
|
|
|
{playlist.title}
|
|
|
|
|
</div>
|
2026-01-16 00:59:31 +00:00
|
|
|
<div className="text-xs text-kodo-content-dim">
|
2026-01-13 18:47:57 +00:00
|
|
|
{playlist.track_count} tracks
|
|
|
|
|
</div>
|
2026-01-07 10:15:48 +00:00
|
|
|
</div>
|
2026-01-13 18:47:57 +00:00
|
|
|
<div
|
2026-01-16 00:59:31 +00:00
|
|
|
className={`w-5 h-5 rounded-full border flex items-center justify-center ${selectedIds.includes(playlist.id) ? 'bg-kodo-cyan border-kodo-cyan' : 'border-kodo-steel'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
>
|
|
|
|
|
{selectedIds.includes(playlist.id) && (
|
|
|
|
|
<Check className="w-3 h-3 text-black" />
|
|
|
|
|
)}
|
2026-01-07 10:15:48 +00:00
|
|
|
</div>
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
2026-01-13 18:47:57 +00:00
|
|
|
|
|
|
|
|
<div className="p-4 border-t border-kodo-steel bg-kodo-ink flex justify-end">
|
|
|
|
|
<Button
|
|
|
|
|
variant="primary"
|
|
|
|
|
onClick={handleConfirm}
|
|
|
|
|
disabled={selectedIds.length === 0}
|
|
|
|
|
>
|
|
|
|
|
Done
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2026-01-07 09:31:02 +00:00
|
|
|
};
|