diff --git a/apps/infoalloggi/src/components/annuncio-interactions/annuncio_interactions.tsx b/apps/infoalloggi/src/components/annuncio-interactions/annuncio_interactions.tsx index f960c3a..bdd16d3 100644 --- a/apps/infoalloggi/src/components/annuncio-interactions/annuncio_interactions.tsx +++ b/apps/infoalloggi/src/components/annuncio-interactions/annuncio_interactions.tsx @@ -1,8 +1,9 @@ -import { ArrowRight, BadgePlus } from "lucide-react"; +import { ArrowRight, BadgePlus, Edit, Printer } from "lucide-react"; import Link from "next/link"; import toast from "react-hot-toast"; import { ContattoAnnuncio } from "~/components/annuncio-interactions/contatto_modal"; import LoadingButton from "~/components/custom_ui/loading-button"; +import { IncrociDialog } from "~/components/servizio/incroci"; import { Button } from "~/components/ui/button"; import { useAnnuncio } from "~/providers/AnnuncioProvider"; import { useTranslation } from "~/providers/I18nProvider"; @@ -14,9 +15,13 @@ import { api } from "~/utils/api"; export const AnnuncioInteractions = ({ disabled }: { disabled?: boolean }) => { const { user } = useSession(); - const { id, tipo } = useAnnuncio(); const { locale } = useTranslation(); if (!user) return null; + + if (user.isAdmin) { + return ; + } + if (disabled) { return (
@@ -26,6 +31,39 @@ export const AnnuncioInteractions = ({ disabled }: { disabled?: boolean }) => {
); } + return ; +}; +const AdminInteractions = () => { + const { id } = useAnnuncio(); + return ( +
+ + + + + + + +
+ ); +}; + +const UserInteractions = () => { + const { user } = useSession(); + const { id, tipo } = useAnnuncio(); + const { locale } = useTranslation(); + if (!user) return null; return (
{user ? ( @@ -41,25 +79,11 @@ export const AnnuncioInteractions = ({ disabled }: { disabled?: boolean }) => { ) : (
- {/* oppure - - - */}
)}
); }; - const ServizioInteraction = ({ userId, tipologia, diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx index e7d8ced..839d892 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx @@ -13,6 +13,7 @@ import { } from "lucide-react"; import Link from "next/link"; import toast from "react-hot-toast"; +import { IncrociDialog } from "~/components/servizio/incroci"; import { AlertDialog, AlertDialogCancel, @@ -73,6 +74,10 @@ export const AdminActions = () => {

Azioni Admin:

+ | null>; data: ServizioAnnuncioData; }) => { - const [newNote, setNewNote] = useState(data.note); - const utils = api.useUtils(); const { onMutate, onSettled } = MutationPageRestore(tableRef); - const { mutate, isPending } = api.servizio.updateServizioAnnunci.useMutation({ - onMutate, - onSettled, - onSuccess: async () => { - toast.success("Note aggiornate"); - await utils.servizio.invalidate(); - }, - onError: () => { - toast.error("Errore nell'aggiornamento note"); - }, - }); - const isDesktop = useMediaQuery("(min-width: 40rem)"); + return ( @@ -164,6 +157,15 @@ export const AnnuncioCardRichieste = ({
+ + + +
@@ -176,48 +178,13 @@ export const AnnuncioCardRichieste = ({
- - - - - - -
-