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

56 lines
990 B
TypeScript
Raw Normal View History

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