infoalloggi-monorepo/apps/infoalloggi/src/lib/annuncio_details.ts

56 lines
1 KiB
TypeScript
Raw Normal View History

2025-08-04 17:45:44 +02:00
import type { LangDict } from "~/i18n/locales";
export const handleConsegna = ({
consegna,
consegna_da,
mesi,
subito,
aggiornamento,
}: {
consegna: number | null;
consegna_da: string;
mesi: string[];
subito: string;
aggiornamento: string;
}) => {
const currentMonth = new Date().getMonth() + 1;
if (consegna !== null) {
if (consegna !== currentMonth) {
return `${consegna_da} ${mesi[consegna]}`;
}
return subito;
}
return aggiornamento;
};
export const camereTesti = ({
camere,
testi,
}: {
camere: number | null;
testi: LangDict["card"];
}) => {
if (camere) {
if (camere > 1) {
return `${camere} ${testi.camere2}`;
}
return `${camere} ${testi.camere1}`;
}
return "N/A";
};
export const getTitoloTranslation = ({
locale,
titolo_it,
titolo_en,
}: {
locale: string;
titolo_it: string | null;
titolo_en: string | null;
}) => {
if (locale === "it") {
return titolo_it != null ? titolo_it : "";
}
return titolo_en != null ? titolo_en : "";
};