import { useEffect, useState } from "react";
import { adminListBoards } from "../../lib/adminApi";
import { getAdminToken } from "../../lib/adminAuth";
import { Box, Typography, List, ListItem, ListItemText } from "@mui/material";

export default function AdminBoards() {
    const [items, setItems] = useState<any[]>([]);
    useEffect(()=>{
        const t = getAdminToken()!;
        adminListBoards(t).then(setItems).catch(console.error);
    }, []);
    return (
        <Box>
            <Typography variant="h6" mb={1}>게시판 관리</Typography>
            <List dense>
                {items.map(b=>(
                    <ListItem key={b.id}><ListItemText primary={`${b.code} — ${b.name}`} secondary={b.description} /></ListItem>
                ))}
            </List>
        </Box>
    );
}
