Det9999 commited on
Commit
d65f2e9
·
verified ·
1 Parent(s): ab91dca

Upload components/ConfigModal.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/ConfigModal.jsx +121 -0
components/ConfigModal.jsx ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react';
2
+ import { X, Settings, Save } from 'lucide-react';
3
+
4
+ export default function ConfigModal({ isOpen, onClose, onSave, initialConfig }) {
5
+ const [spotifyId, setSpotifyId] = useState('');
6
+ const [spotifySecret, setSpotifySecret] = useState('');
7
+ const [aiProvider, setAiProvider] = useState('openai');
8
+ const [aiApiKey, setAiApiKey] = useState('');
9
+ const [aiModel, setAiModel] = useState('gpt-3.5-turbo');
10
+
11
+ useEffect(() => {
12
+ if (initialConfig) {
13
+ setSpotifyId(initialConfig.spotifyId || '');
14
+ setSpotifySecret(initialConfig.spotifySecret || '');
15
+ setAiProvider(initialConfig.aiProvider || 'openai');
16
+ setAiApiKey(initialConfig.aiApiKey || '');
17
+ setAiModel(initialConfig.aiModel || 'gpt-3.5-turbo');
18
+ }
19
+ }, [initialConfig, isOpen]);
20
+
21
+ if (!isOpen) return null;
22
+
23
+ const handleSave = () => {
24
+ onSave({ spotifyId, spotifySecret, aiProvider, aiApiKey, aiModel });
25
+ onClose();
26
+ };
27
+
28
+ return (
29
+ <div className="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4">
30
+ <div className="bg-[#282828] rounded-xl w-full max-w-md border border-white/10 shadow-2xl">
31
+ <div className="flex justify-between items-center p-5 border-b border-white/10">
32
+ <div className="flex items-center gap-2">
33
+ <Settings className="w-5 h-5 text-spotify-green" />
34
+ <h2 className="text-lg font-bold">Configuration</h2>
35
+ </div>
36
+ <button
37
+ onClick={onClose}
38
+ className="text-gray-400 hover:text-white transition-colors"
39
+ >
40
+ <X className="w-5 h-5" />
41
+ </button>
42
+ </div>
43
+
44
+ <div className="p-6 space-y-5 max-h-[70vh] overflow-y-auto">
45
+ <div className="space-y-3">
46
+ <h3 className="text-sm font-semibold text-spotify-green uppercase tracking-wider">Spotify Credentials</h3>
47
+ <p className="text-xs text-gray-400">
48
+ Create an app at <a href="https://developer.spotify.com/dashboard" target="_blank" rel="noreferrer" className="underline hover:text-white">Spotify Dashboard</a> to get these.
49
+ </p>
50
+ <div>
51
+ <label className="block text-sm font-medium text-gray-300 mb-1">Client ID</label>
52
+ <input
53
+ type="text"
54
+ value={spotifyId}
55
+ onChange={(e) => setSpotifyId(e.target.value)}
56
+ placeholder="Enter Spotify Client ID"
57
+ className="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-spotify-green transition-colors"
58
+ />
59
+ </div>
60
+ <div>
61
+ <label className="block text-sm font-medium text-gray-300 mb-1">Client Secret</label>
62
+ <input
63
+ type="password"
64
+ value={spotifySecret}
65
+ onChange={(e) => setSpotifySecret(e.target.value)}
66
+ placeholder="Enter Spotify Client Secret"
67
+ className="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-spotify-green transition-colors"
68
+ />
69
+ </div>
70
+ </div>
71
+
72
+ <div className="space-y-3 pt-4 border-t border-white/10">
73
+ <h3 className="text-sm font-semibold text-purple-400 uppercase tracking-wider">AI Configuration</h3>
74
+ <div>
75
+ <label className="block text-sm font-medium text-gray-300 mb-1">Provider</label>
76
+ <select
77
+ value={aiProvider}
78
+ onChange={(e) => setAiProvider(e.target.value)}
79
+ className="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-purple-400 transition-colors"
80
+ >
81
+ <option value="openai">OpenAI</option>
82
+ <option value="anthropic">Anthropic (Claude)</option>
83
+ <option value="custom">Custom Endpoint</option>
84
+ </select>
85
+ </div>
86
+ <div>
87
+ <label className="block text-sm font-medium text-gray-300 mb-1">API Key</label>
88
+ <input
89
+ type="password"
90
+ value={aiApiKey}
91
+ onChange={(e) => setAiApiKey(e.target.value)}
92
+ placeholder="sk-..."
93
+ className="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-purple-400 transition-colors"
94
+ />
95
+ </div>
96
+ <div>
97
+ <label className="block text-sm font-medium text-gray-300 mb-1">Model Name</label>
98
+ <input
99
+ type="text"
100
+ value={aiModel}
101
+ onChange={(e) => setAiModel(e.target.value)}
102
+ placeholder="e.g. gpt-4, claude-3-opus"
103
+ className="w-full bg-black/40 border border-white/20 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-purple-400 transition-colors"
104
+ />
105
+ </div>
106
+ </div>
107
+ </div>
108
+
109
+ <div className="p-5 border-t border-white/10 bg-black/20 rounded-b-xl flex justify-end">
110
+ <button
111
+ onClick={handleSave}
112
+ className="flex items-center gap-2 bg-spotify-green hover:bg-green-500 text-black font-semibold px-5 py-2 rounded-full transition-all transform active:scale-95"
113
+ >
114
+ <Save className="w-4 h-4" />
115
+ Save Configuration
116
+ </button>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ );
121
+ }