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

41 lines
713 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: _consegna_da,
2025-08-28 18:27:07 +02:00
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 `${mesi[consegna]}`;
2025-08-28 18:27:07 +02:00
}
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
};