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

40 lines
713 B
TypeScript

import type { LangDict } from "~/i18n/locales";
export const handleConsegna = ({
consegna,
consegna_da: _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 `${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";
};