import { useQuery } from "@tanstack/react-query";
import { Alert, CircularProgress, List, ListItem, ListItemText, Typography } from "@mui/material";
import { fetchAdminArticles } from "../../services/api";
import { useAppSelector } from "../../store/hooks";
const NewsManagementPage = () => {
const { token } = useAppSelector((state) => state.auth);
const { data, isLoading, error } = useQuery({
queryKey: ["admin-articles"],
queryFn: () => fetchAdminArticles(token ?? ""),
enabled: Boolean(token),
});
if (isLoading) {
return ;
}
if (error) {
return Unable to load articles.;
}
if (!data?.length) {
return No articles found.;
}
return (
{data.map((article) => (
))}
);
};
export default NewsManagementPage;