diff --git a/apps/infoalloggi/src/pages/annuncio/[cod].tsx b/apps/infoalloggi/src/pages/annuncio/[cod].tsx index fa14969..cd6d74b 100644 --- a/apps/infoalloggi/src/pages/annuncio/[cod].tsx +++ b/apps/infoalloggi/src/pages/annuncio/[cod].tsx @@ -64,7 +64,7 @@ import { handleConsegna } from "~/lib/annuncio_details"; import { replaceWithBr } from "~/lib/newlineToBr"; import { getStorageUrl } from "~/lib/storage_utils"; import { cn } from "~/lib/utils"; -import { AnnuncioContext } from "~/providers/AnnuncioProvider"; +import { AnnuncioContext, useAnnuncio } from "~/providers/AnnuncioProvider"; import { useTranslation } from "~/providers/I18nProvider"; import { buildRicercaUrl } from "~/providers/RicercaProvider"; import { useSession } from "~/providers/SessionProvider"; @@ -211,14 +211,7 @@ const AnnuncioView = ({ cod, flag }: Omit) => { {data.tipo && (data.tipo === "Transitorio" || data.tipo === "Stabile") && ( <> - + )} @@ -282,15 +275,13 @@ export const getStaticPaths: GetStaticPaths = async () => { export default AnnuncioDettaglio; -const Pricing = ({ - isDesktop, - tipologia, -}: { - isDesktop: boolean; - tipologia: TipologiaPosizioneEnum; -}) => { +const Pricing = ({ isDesktop }: { isDesktop: boolean }) => { const { t } = useTranslation(); - + const { prezzo, tipo } = useAnnuncio(); + const tipologia = + tipo === "Transitorio" + ? TipologiaPosizioneEnum.Transitorio + : TipologiaPosizioneEnum.Stabile; const { data: prezziario, isLoading } = api.prezziario.getPrezziPerTipologia.useQuery({ tipologia, @@ -328,6 +319,16 @@ const Pricing = ({ secondPayment: s.prezzo_cent / 100, })); + //se stabile, mostra il prezzo basato sul canone in default + const defaultValue = + tipologia === TipologiaPosizioneEnum.Stabile + ? prezzo > 70000 + ? 2 + : prezzo > 50000 + ? 1 + : 0 + : undefined; + if (isDesktop) { return (