Bloc A - Code mort: - Suppression Studio (components, views, features) - Suppression gamification + services mock (projectService, storageService, gamificationService) - Mise à jour Sidebar, Navbar, locales Bloc B - Frontend: - Suppression modal.tsx deprecated, Modal.stories (doublon Dialog) - Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true - Suppression 19 tests orphelins, retrait exclusions vitest.config Bloc C - Backend: - Extraction routes_auth.go depuis router.go Bloc D - Rust: - Suppression security_legacy.rs (code mort, patterns déjà dans security/)
107 lines
3.5 KiB
TypeScript
107 lines
3.5 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Button } from '../../ui/button';
|
|
import { Input } from '../../ui/input';
|
|
import { X, Lock, Globe } from 'lucide-react';
|
|
import { useToast } from '../../../components/feedback/ToastProvider';
|
|
|
|
interface SaveQueueAsPlaylistModalProps {
|
|
onClose: () => void;
|
|
onSave: (name: string, isPublic: boolean) => void | Promise<void>;
|
|
}
|
|
|
|
export const SaveQueueAsPlaylistModal: React.FC<
|
|
SaveQueueAsPlaylistModalProps
|
|
> = ({ onClose, onSave }) => {
|
|
const { addToast } = useToast();
|
|
const [name, setName] = useState('');
|
|
const [isPublic, setIsPublic] = useState(false);
|
|
|
|
const [saving, setSaving] = useState(false);
|
|
const handleSubmit = async () => {
|
|
if (!name) {
|
|
addToast('Please name your playlist', 'error');
|
|
return;
|
|
}
|
|
setSaving(true);
|
|
try {
|
|
await onSave(name, isPublic);
|
|
onClose();
|
|
} catch (err) {
|
|
addToast(
|
|
err instanceof Error ? err.message : 'Failed to save playlist',
|
|
'error',
|
|
);
|
|
} finally {
|
|
setSaving(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4">
|
|
<div
|
|
className="absolute inset-0 bg-background/90 backdrop-blur-sm"
|
|
onClick={onClose}
|
|
></div>
|
|
<div className="relative w-full max-w-md bg-card border border-border rounded-xl shadow-2xl animate-scaleIn">
|
|
<div className="p-4 border-b border-border bg-card flex justify-between items-center">
|
|
<h3 className="font-bold text-foreground">Save Queue as Playlist</h3>
|
|
<button onClick={onClose}>
|
|
<X className="w-5 h-5 text-muted-foreground hover:text-foreground" />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 space-y-4">
|
|
<Input
|
|
label="Playlist Name"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
autoFocus
|
|
placeholder="My Queue Session"
|
|
/>
|
|
|
|
<div
|
|
className="flex items-center justify-between p-4 bg-card rounded border border-border cursor-pointer hover:border-border"
|
|
onClick={() => setIsPublic(!isPublic)}
|
|
>
|
|
<div className="flex items-center gap-4">
|
|
{isPublic ? (
|
|
<Globe className="w-5 h-5 text-muted-foreground" />
|
|
) : (
|
|
<Lock className="w-5 h-5 text-warning" />
|
|
)}
|
|
<div>
|
|
<div className="text-sm font-bold text-foreground">
|
|
{isPublic ? 'Public Playlist' : 'Private Playlist'}
|
|
</div>
|
|
<div className="text-xs text-muted-foreground">
|
|
{isPublic ? 'Visible on your profile' : 'Only visible to you'}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div
|
|
className={`w-10 h-5 rounded-full relative transition-colors ${isPublic ? 'bg-primary' : 'bg-muted'}`}
|
|
>
|
|
<div
|
|
className={`absolute top-1 w-3 h-3 bg-white rounded-full transition-all ${isPublic ? 'left-6' : 'left-1'}`}
|
|
></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="p-4 border-t border-border bg-card flex justify-end gap-4">
|
|
<Button variant="ghost" onClick={onClose}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
variant="primary"
|
|
onClick={handleSubmit}
|
|
disabled={saving}
|
|
loading={saving}
|
|
>
|
|
Save Playlist
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|