import React, { useEffect, useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { get } from '../../lib/api'; import { Box, IconButton, Typography } from '@mui/material'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; const HelpPage = () => { const { guildId } = useParams(); const navigate = useNavigate(); const [commands, setCommands] = useState([]); useEffect(() => { get(`/api/servers/${guildId}/commands`).then(res => { const cmds = res.data || []; // sort: locked commands first (preserve relative order), then others alphabetically const locked = cmds.filter(c => c.locked); const others = cmds.filter(c => !c.locked).sort((a, b) => a.name.localeCompare(b.name)); setCommands([...locked, ...others]); }) .catch(() => setCommands([])); }, [guildId]); const handleBack = () => { // Navigate back to server settings and instruct it to open Commands accordion navigate(`/server/${guildId}`, { state: { openCommands: true } }); } return ( Commands List {commands.length === 0 && No commands available.} {commands.map(cmd => ( /{cmd.name} {cmd.locked ? 'Locked' : (cmd.enabled ? 'Enabled' : 'Disabled')} {cmd.description} ))} ); } export default HelpPage;