Make Discord update server types dynamic from server list
All checks were successful
Deploy GSM / deploy (push) Successful in 23s

Server dropdown now shows actual servers from the API instead of
hardcoded list.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alexander Zielonka
2026-01-19 12:28:02 +01:00
parent bc69201139
commit 0f1fdca66a
10 changed files with 26 additions and 17 deletions

View File

@@ -1,18 +1,7 @@
import { useState } from 'react' import { useState, useMemo } from 'react'
import { sendDiscordUpdate } from '../api' import { sendDiscordUpdate } from '../api'
import { useUser } from '../context/UserContext' import { useUser } from '../context/UserContext'
const SERVER_TYPES = [
{ value: 'general', label: 'Allgemein', icon: '📢', titleTemplate: '' },
{ value: 'minecraft', label: 'Minecraft', icon: '⛏️', titleTemplate: 'Minecraft Server Update' },
{ value: 'factorio', label: 'Factorio', icon: '⚙️', titleTemplate: 'Factorio Server Update' },
{ value: 'terraria', label: 'Terraria', icon: '⚔️', titleTemplate: 'Terraria Server Update' },
{ value: 'palworld', label: 'Palworld', icon: '🦎', titleTemplate: 'Palworld Server Update' },
{ value: 'vrising', label: 'V Rising', icon: '🧛', titleTemplate: 'V Rising Server Update' },
{ value: 'zomboid', label: 'Project Zomboid', icon: '🧟', titleTemplate: 'Project Zomboid Server Update' },
{ value: 'hytale', label: 'Hytale', icon: '🏰', titleTemplate: 'Hytale Server Update' },
]
const COLORS = [ const COLORS = [
{ value: 0x5865F2, label: 'Blau', hex: '#5865F2' }, { value: 0x5865F2, label: 'Blau', hex: '#5865F2' },
{ value: 0x57F287, label: 'Grün', hex: '#57F287' }, { value: 0x57F287, label: 'Grün', hex: '#57F287' },
@@ -21,7 +10,7 @@ const COLORS = [
{ value: 0x00BFFF, label: 'Cyan', hex: '#00BFFF' }, { value: 0x00BFFF, label: 'Cyan', hex: '#00BFFF' },
] ]
export default function SendUpdateModal({ onClose }) { export default function SendUpdateModal({ onClose, servers = [] }) {
const { token } = useUser() const { token } = useUser()
const [serverType, setServerType] = useState('general') const [serverType, setServerType] = useState('general')
const [title, setTitle] = useState('') const [title, setTitle] = useState('')
@@ -31,10 +20,22 @@ export default function SendUpdateModal({ onClose }) {
const [success, setSuccess] = useState(false) const [success, setSuccess] = useState(false)
const [error, setError] = useState('') const [error, setError] = useState('')
const serverTypes = useMemo(() => {
const types = [{ value: 'general', label: 'Allgemein', titleTemplate: '' }]
servers.forEach(server => {
types.push({
value: server.type || server.id,
label: server.name,
titleTemplate: `${server.name} Update`
})
})
return types
}, [servers])
const handleServerTypeChange = (e) => { const handleServerTypeChange = (e) => {
const newType = e.target.value const newType = e.target.value
setServerType(newType) setServerType(newType)
const template = SERVER_TYPES.find(t => t.value === newType)?.titleTemplate || '' const template = serverTypes.find(t => t.value === newType)?.titleTemplate || ''
setTitle(template) setTitle(template)
} }
@@ -81,9 +82,9 @@ export default function SendUpdateModal({ onClose }) {
onChange={handleServerTypeChange} onChange={handleServerTypeChange}
className="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-white focus:outline-none focus:border-purple-500" className="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-white focus:outline-none focus:border-purple-500"
> >
{SERVER_TYPES.map(type => ( {serverTypes.map(type => (
<option key={type.value} value={type.value}> <option key={type.value} value={type.value}>
{type.icon} {type.label} {type.label}
</option> </option>
))} ))}
</select> </select>

View File

@@ -322,7 +322,7 @@ export default function Dashboard({ onLogout }) {
<LoginModal onClose={() => setShowLogin(false)} /> <LoginModal onClose={() => setShowLogin(false)} />
)} )}
{showSendUpdate && ( {showSendUpdate && (
<SendUpdateModal onClose={() => setShowSendUpdate(false)} /> <SendUpdateModal onClose={() => setShowSendUpdate(false)} servers={servers} />
)} )}
</div> </div>
) )

1
tmpclaude-36cb-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-3f9a-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-7fb3-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-9bb9-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-9dd9-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-a8f7-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-b8fc-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM

1
tmpclaude-e8a5-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/ZielonkaA/Documents/GSM