diff --git a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx index fb7ccbc..1839781 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx @@ -15,7 +15,10 @@ import { getStorageUrl } from "~/lib/storage_utils"; import { cn, formatCurrency } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; import { useServizio, useServizioAnnuncio } from "~/providers/ServizioProvider"; +import type { AnnunciId } from "~/schemas/public/Annunci"; +import type { ServizioServizioId } from "~/schemas/public/Servizio"; import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; +import type { ServizioAnnuncioData } from "~/server/controllers/servizio.controller"; import { api } from "~/utils/api"; import { Button } from "../ui/button"; import { @@ -30,15 +33,9 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { const { data } = useServizioAnnuncio(); return ( - @@ -60,20 +57,22 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { ) } + isAdmin={isAdmin} /> ); }; -export const BasicAnnuncioCard = ({ +export const AnnuncioCardContent = ({ interactions, className, data, + isAdmin, }: { interactions?: React.ReactNode; className?: string; - data: AnnuncioRicerca; + data: ServizioAnnuncioData; + isAdmin: boolean; }) => { - const { isAdmin } = useServizio(); return ( {interactions} - {isAdmin && } + {isAdmin && ( + + )} ); }; -const AnnuncioNote = () => { - const { servizioId } = useServizio(); - const { data } = useServizioAnnuncio(); - - const [newNote, setNewNote] = useState(data.note || ""); +const AnnuncioNote = ({ + servizioId, + annuncioId, + note, +}: { + servizioId: ServizioServizioId; + annuncioId: AnnunciId; + note: string | null; +}) => { + const [newNote, setNewNote] = useState(note); const utils = api.useUtils(); const { mutate, isPending } = api.servizio.updateServizioAnnunci.useMutation({ onSuccess: async () => { @@ -142,21 +152,22 @@ const AnnuncioNote = () => {