'use client'; import { getGuilds, getTextChannels, getVoiceChannels, getVolume, pauseTrack, playTrack, resumeTrack, sendMessage, setVolume, skipTrack, stopTrack } from '@/api/guilds'; import { GuildChannel, GuildInfo } from '@/api/guilds.types'; import Auth from '@/components/Auth'; import { userState } from '@/state/auth'; import { Button, Card, Grid, Select, Slider, Tabs, TextInput, Textarea } from '@mantine/core'; import { useForm } from '@mantine/form'; import { useRouter } from 'next/navigation'; import React, { useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; function Page() { const user = useRecoilValue(userState); const [guilds, setGuilds] = useState([]); const [activeGuild, setActiveGuild] = useState(null); const router = useRouter(); useEffect(() => { // Check if the user is logged in and an admin, otherwise redirect to the home page // if (!user || !user.roles.includes('admin')) { if (!user || user.role !== 'admin') { router.push('/'); } else { getGuilds().then((g) => { setGuilds(g); if (g.length > 0) { setActiveGuild(g[0]); } }); } }, []); return ( {guilds && guilds.map((guild) => ( setActiveGuild(guild)}> {guild.name} ))} {guilds && guilds.map((guild) => (

{guild.name}

))}
); } export default Auth(Page); function TextChannelCard({ guild }: { guild: GuildInfo | null }) { const [textChannels, setTextChannels] = useState([]); const [activeChannel, setActiveChannel] = useState(null); const form = useForm({ initialValues: { message: '' } }); useEffect(() => { if (guild) { getTextChannels(guild.id).then((c) => setTextChannels(c)); } }, [guild]); return (

Text Channels