Implement nickname for table
All checks were successful
Lint Pull Request / lint (push) Successful in 22s
release-image / release-image (push) Successful in 10m26s

This commit is contained in:
Logan Cusano
2025-06-29 03:46:43 -04:00
parent 6a74cd55a0
commit 8373fdd685
2 changed files with 15 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Checkbox } from '@/components/ui/checkbox'; import { Checkbox } from '@/components/ui/checkbox';
import { DRB_BASE_API_URL } from '@/constants/api'; import { DRB_BASE_API_URL } from '@/constants/api';
import { DiscordId, System, ErrorResponse } from '@/types'; import { DiscordId, System, ErrorResponse, ActiveClient } from '@/types';
import { authAwareFetch } from '@/utils/AuthAwareFetch'; import { authAwareFetch } from '@/utils/AuthAwareFetch';
interface BotsManagementProps { interface BotsManagementProps {
@@ -20,7 +20,7 @@ interface BotsManagementProps {
} }
const BotsManagement: React.FC<BotsManagementProps> = ({ token, logoutUser }) => { const BotsManagement: React.FC<BotsManagementProps> = ({ token, logoutUser }) => {
const [bots, setBots] = useState<string[]>([]); const [bots, setBots] = useState<ActiveClient[]>([]);
const [discordIds, setDiscordIds] = useState<DiscordId[]>([]); const [discordIds, setDiscordIds] = useState<DiscordId[]>([]);
const [systems, setSystems] = useState<System[]>([]); const [systems, setSystems] = useState<System[]>([]);
const [loading, setLoading] = useState<boolean>(true); // Set to true initially const [loading, setLoading] = useState<boolean>(true); // Set to true initially
@@ -61,7 +61,7 @@ const BotsManagement: React.FC<BotsManagementProps> = ({ token, logoutUser }) =>
]); ]);
if (nodesRes.ok) { if (nodesRes.ok) {
const botsData: any = await nodesRes.json(); const botsData: ActiveClient[] = await nodesRes.json();
setBots(botsData); setBots(botsData);
} else { } else {
let errorMsg = `Failed to fetch bots (${nodesRes.status})`; let errorMsg = `Failed to fetch bots (${nodesRes.status})`;
@@ -270,12 +270,12 @@ const BotsManagement: React.FC<BotsManagementProps> = ({ token, logoutUser }) =>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
{bots.length > 0 ? ( {bots.length > 0 ? (
bots.map((botClientId) => { bots.map((active_bot) => {
return ( return (
<TableRow key={botClientId}> <TableRow key={active_bot.client_id}>
<TableCell className="font-medium"> <TableCell className="font-medium">
<Link href={`/nodes/${botClientId}`} className="text-blue-600 hover:underline"> <Link href={`/nodes/${active_bot.client_id}`} className="text-blue-600 hover:underline">
{botClientId} {active_bot.nickname} ({active_bot.client_id})
</Link> </Link>
</TableCell> </TableCell>
</TableRow> </TableRow>
@@ -420,8 +420,8 @@ const BotsManagement: React.FC<BotsManagementProps> = ({ token, logoutUser }) =>
<SelectValue placeholder="Select a bot client ID" /> <SelectValue placeholder="Select a bot client ID" />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{bots.map((botId) => ( {bots.map((active_bot) => (
<SelectItem key={botId} value={botId}>{botId}</SelectItem> <SelectItem key={active_bot.client_id} value={active_bot.client_id}>{active_bot.client_id}</SelectItem>
))} ))}
</SelectContent> </SelectContent>
</Select> </Select>

View File

@@ -53,6 +53,12 @@ export enum DemodTypes {
discord_status: string; discord_status: string;
} }
} }
export interface ActiveClient {
active_token: string;
nickname: string;
client_id: string;
}
// Auth Context Types // Auth Context Types
export interface AuthContextType { export interface AuthContextType {