From 0f1fdca66acefda002fbbbb0a8aebce2993d64ad Mon Sep 17 00:00:00 2001 From: Alexander Zielonka Date: Mon, 19 Jan 2026 12:28:02 +0100 Subject: [PATCH] Make Discord update server types dynamic from server list Server dropdown now shows actual servers from the API instead of hardcoded list. Co-Authored-By: Claude Opus 4.5 --- .../src/components/SendUpdateModal.jsx | 33 ++++++++++--------- gsm-frontend/src/pages/Dashboard.jsx | 2 +- tmpclaude-36cb-cwd | 1 + tmpclaude-3f9a-cwd | 1 + tmpclaude-7fb3-cwd | 1 + tmpclaude-9bb9-cwd | 1 + tmpclaude-9dd9-cwd | 1 + tmpclaude-a8f7-cwd | 1 + tmpclaude-b8fc-cwd | 1 + tmpclaude-e8a5-cwd | 1 + 10 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 tmpclaude-36cb-cwd create mode 100644 tmpclaude-3f9a-cwd create mode 100644 tmpclaude-7fb3-cwd create mode 100644 tmpclaude-9bb9-cwd create mode 100644 tmpclaude-9dd9-cwd create mode 100644 tmpclaude-a8f7-cwd create mode 100644 tmpclaude-b8fc-cwd create mode 100644 tmpclaude-e8a5-cwd diff --git a/gsm-frontend/src/components/SendUpdateModal.jsx b/gsm-frontend/src/components/SendUpdateModal.jsx index c9b35c7..b309aef 100644 --- a/gsm-frontend/src/components/SendUpdateModal.jsx +++ b/gsm-frontend/src/components/SendUpdateModal.jsx @@ -1,18 +1,7 @@ -import { useState } from 'react' +import { useState, useMemo } from 'react' import { sendDiscordUpdate } from '../api' 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 = [ { value: 0x5865F2, label: 'Blau', hex: '#5865F2' }, { value: 0x57F287, label: 'Grün', hex: '#57F287' }, @@ -21,7 +10,7 @@ const COLORS = [ { value: 0x00BFFF, label: 'Cyan', hex: '#00BFFF' }, ] -export default function SendUpdateModal({ onClose }) { +export default function SendUpdateModal({ onClose, servers = [] }) { const { token } = useUser() const [serverType, setServerType] = useState('general') const [title, setTitle] = useState('') @@ -31,10 +20,22 @@ export default function SendUpdateModal({ onClose }) { const [success, setSuccess] = useState(false) 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 newType = e.target.value setServerType(newType) - const template = SERVER_TYPES.find(t => t.value === newType)?.titleTemplate || '' + const template = serverTypes.find(t => t.value === newType)?.titleTemplate || '' setTitle(template) } @@ -81,9 +82,9 @@ export default function SendUpdateModal({ onClose }) { 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" > - {SERVER_TYPES.map(type => ( + {serverTypes.map(type => ( ))} diff --git a/gsm-frontend/src/pages/Dashboard.jsx b/gsm-frontend/src/pages/Dashboard.jsx index 27408e2..b91c093 100644 --- a/gsm-frontend/src/pages/Dashboard.jsx +++ b/gsm-frontend/src/pages/Dashboard.jsx @@ -322,7 +322,7 @@ export default function Dashboard({ onLogout }) { setShowLogin(false)} /> )} {showSendUpdate && ( - setShowSendUpdate(false)} /> + setShowSendUpdate(false)} servers={servers} /> )} ) diff --git a/tmpclaude-36cb-cwd b/tmpclaude-36cb-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-36cb-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-3f9a-cwd b/tmpclaude-3f9a-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-3f9a-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-7fb3-cwd b/tmpclaude-7fb3-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-7fb3-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-9bb9-cwd b/tmpclaude-9bb9-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-9bb9-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-9dd9-cwd b/tmpclaude-9dd9-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-9dd9-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-a8f7-cwd b/tmpclaude-a8f7-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-a8f7-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-b8fc-cwd b/tmpclaude-b8fc-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-b8fc-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM diff --git a/tmpclaude-e8a5-cwd b/tmpclaude-e8a5-cwd new file mode 100644 index 0000000..e130620 --- /dev/null +++ b/tmpclaude-e8a5-cwd @@ -0,0 +1 @@ +/c/Users/ZielonkaA/Documents/GSM