From ddb8e56a0dffac4ad4be200258a06356bfb7c3ca Mon Sep 17 00:00:00 2001 From: Andres Date: Sat, 10 May 2025 18:57:51 +0200 Subject: [PATCH] add commentators list --- .../_components/obs-control-panel-client.tsx | 109 +++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/src/app/(home)/admin/stream/obs-control-panel/_components/obs-control-panel-client.tsx b/src/app/(home)/admin/stream/obs-control-panel/_components/obs-control-panel-client.tsx index dde42dc..20e553c 100644 --- a/src/app/(home)/admin/stream/obs-control-panel/_components/obs-control-panel-client.tsx +++ b/src/app/(home)/admin/stream/obs-control-panel/_components/obs-control-panel-client.tsx @@ -32,6 +32,11 @@ import { PlayerSelector } from './player-selector' const obs = new OBSController() +type Commentator = { + id: string + name: string +} + export function ObsControlPanelClient() { useEffect(() => { if (window.location.protocol === 'https:') { @@ -41,7 +46,10 @@ export function ObsControlPanelClient() { } }, []) const [isConnected, setIsConnected] = useState(false) - + const [commentators, setCommentators] = useLocalStorage( + 'commentators', + [] + ) const players = api.leaderboard.get_leaderboard.useQuery({ channel_id: RANKED_CHANNEL, }) @@ -297,6 +305,47 @@ export function ObsControlPanelClient() { +
+

Commentators

+
+ + +
+ +
+ + +
+
+ @@ -316,6 +365,12 @@ type FormField = { function Settings() { const [isLoading, setIsLoading] = useState(true) const [obsSources, setObsSources] = useState([]) + const [commentators, setCommentators] = useLocalStorage( + 'commentators', + [] + ) + const [newCommentatorName, setNewCommentatorName] = useState('') + const [mappings, setMappings] = useLocalStorage( 'obs-field-mappings', [] @@ -335,7 +390,23 @@ function Settings() { { id: 'player2Rank', label: 'Player 2 - Rank' }, { id: 'player1WinRate', label: 'Player 1 - Win Rate' }, { id: 'player2WinRate', label: 'Player 2 - Win Rate' }, + { id: 'commentator1', label: 'Commentator 1' }, + { id: 'commentator2', label: 'Commentator 2' }, ] + const addCommentator = () => { + if (newCommentatorName.trim()) { + setCommentators([ + ...commentators, + { id: crypto.randomUUID(), name: newCommentatorName.trim() }, + ]) + setNewCommentatorName('') + } + } + + const removeCommentator = (id: string) => { + setCommentators(commentators.filter((c) => c.id !== id)) + } + useEffect(() => { async function fetchSources() { try { @@ -443,6 +514,42 @@ function Settings() { No mappings configured. Add one to get started. )} +
+

Commentators

+ +
+ setNewCommentatorName(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + addCommentator() + e.preventDefault() + } + }} + placeholder='Enter commentator name' + /> + +
+ +
+ {commentators.map((commentator) => ( +
+ {commentator.name} + +
+ ))} +
+
) }