Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

UserSelector.tsx

61 lines1.8 KB

1interface UserSelectorProps {
2 username: string
3 onUsernameChange: (username: string) => void
4 isConnected: boolean
5}
6​
7export function UserSelector({
8 username,
9 onUsernameChange,
10 isConnected,
11}: UserSelectorProps) {
12 const personas = [
13 { value: 'Alice', label: 'πŸ‘© Alice' },
14 { value: 'Bob', label: 'πŸ‘¨ Bob' },
15 { value: 'Charlie', label: 'πŸ§‘ Charlie' },
16 { value: 'Diana', label: 'πŸ‘©β€πŸ¦° Diana' },
17 ]
18​
19 if (!isConnected) {
20 return (
21 <div className="bg-gray-800 p-4 rounded-lg border border-gray-600">
22 <div className="flex items-center justify-center text-gray-400">
23 <div className="animate-spin w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full mr-2"></div>
24 Connecting to chat server...
25 </div>
26 </div>
27 )
28 }
29​
30 return (
31 <div className="bg-gray-800 p-4 rounded-lg border border-gray-600">
32 <div className="flex items-center space-x-3">
33 <label
34 htmlFor="user-selector"
35 className="text-white font-medium whitespace-nowrap"
36 >
37 Select User:
38 </label>
39 <select
40 id="user-selector"
41 value={username}
42 onChange={(e) => onUsernameChange(e.target.value)}
43 className="flex-1 bg-gray-700 text-white border border-gray-600 rounded px-3 py-2 focus:outline-none focus:border-blue-500"
44 >
45 <option value="">Choose a persona...</option>
46 {personas.map((p) => (
47 <option key={p.value} value={p.value}>
48 {p.label}
49 </option>
50 ))}
51 </select>
52 {username && <div className="text-green-400 text-sm">βœ“</div>}
53 </div>
54 {!username && (
55 <p className="text-gray-400 text-xs mt-2">
56 πŸ’‘ Choose a user to start chatting
57 </p>
58 )}
59 </div>
60 )