import { CodeSquare, RefreshCcw, TriangleAlert } from "lucide-react"; import toast from "react-hot-toast"; import { Confirm } from "~/components/confirm"; import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; import { AnnunciTable } from "~/components/tables/annunci-tables"; import { Button } from "~/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger, } from "~/components/ui/popover"; import type { NextPageWithLayout } from "~/pages/_app"; import { generateSSGHelper } from "~/server/utils/ssgHelper"; import { api } from "~/utils/api"; const Admin_Annunci: NextPageWithLayout = () => { const { data, isLoading, refetch } = api.annunci.getAnnunciList.useQuery(); const { mutateAsync: update } = api.settings.updateAllAnnunci.useMutation({ onSettled: async () => { toast.success( "La revalidazione dell'annuncio è stata richiesta con successo,\n potrebbero volerci alcuni minuti prima che le modifiche siano visibili.", { duration: 5000, }, ); }, }); const { mutateAsync: revalidate } = api.settings.revalidateAllAnnunci.useMutation({ onSettled: async () => { toast.success("Revalidazione completata"); }, }); if (isLoading) return ; if (!data) return ; return (

Annunci

{ await update(); }} title="Aggiornamento Annunci" >
); }; export async function getServerSideProps() { const helpers = generateSSGHelper(); await helpers.annunci.getAnnunciList.prefetch(); return { props: { trpcState: helpers.dehydrate(), }, }; } export default Admin_Annunci; Admin_Annunci.getLayout = function getLayout(page) { return {page}; };