diff --git a/apps/infoalloggi/biome.json b/apps/infoalloggi/biome.json index 535d410..9960411 100644 --- a/apps/infoalloggi/biome.json +++ b/apps/infoalloggi/biome.json @@ -68,6 +68,7 @@ "linter": { "domains": { "next": "recommended", + "project": "recommended", "react": "recommended" }, "enabled": true, @@ -82,19 +83,33 @@ }, "correctness": { + "noUndeclaredVariables": "on", "useExhaustiveDependencies": "off", "useHookAtTopLevel": "off", "useParseIntRadix": "off" }, + "nursery": { + "useExhaustiveSwitchCases": "on" + }, "performance": { - "noImgElement": "off" + "noImgElement": "off", + "useGoogleFontPreconnect": "on" }, "recommended": true, "security": { "noDangerouslySetInnerHtml": "off" }, + "style": { + "noNestedTernary": "info", + "noUselessElse": "on", + "noYodaExpression": "on", + "useThrowNewError": "on", + "useThrowOnlyError": "on" + }, "suspicious": { "noArrayIndexKey": "off", + "noDocumentImportInPage": "on", + "noHeadImportInDocument": "on", "noUnknownAtRules": "off", "useIterableCallbackReturn": "off" } diff --git a/apps/infoalloggi/emails/email-interessato.tsx b/apps/infoalloggi/emails/email-interessato.tsx index 505b4d5..f2ad2e3 100644 --- a/apps/infoalloggi/emails/email-interessato.tsx +++ b/apps/infoalloggi/emails/email-interessato.tsx @@ -19,11 +19,6 @@ const EmailContattoInteressato = ({ indirizzo, sesso, }: EmailContattoInteressatoProps) => { - const sig = sesso - ? sesso === "M" - ? "Il Sig." - : "La Sig.ra" - : "Il/La Sig./Sig.ra"; return ( <> @@ -34,9 +29,15 @@ const EmailContattoInteressato = ({ Gentile proprietario {nome_cognome}, le comunichiamo che a breve - la contatterà {sig} {nome_cognome_utente} (tel: {telefono}), - cliente Arca abbonato tramite il nostro servizio online - Infoalloggi.it interessato a vedere il Suo immobile{" "} + la contatterà {(() => { + if (sesso) { + if (sesso === "M") return "il Sig."; + if (sesso === "F") return "la Sig.ra"; + } + return "il Sig./la Sig.ra"; + })()} {nome_cognome_utente} (tel: {telefono}), cliente Arca + abbonato tramite il nostro servizio online Infoalloggi.it + interessato a vedere il Suo immobile{" "} {indirizzo ? `di ${indirizzo}` : ""}. diff --git a/apps/infoalloggi/src/components/IconComponents.tsx b/apps/infoalloggi/src/components/IconComponents.tsx index 391dd3f..ae74c35 100644 --- a/apps/infoalloggi/src/components/IconComponents.tsx +++ b/apps/infoalloggi/src/components/IconComponents.tsx @@ -202,6 +202,8 @@ export const IconMatrix = ({ type, ...rest }: IconMatrixProps) => { return ; case "thumbs-up": return ; + default: + return
Icon not found
; } }; diff --git a/apps/infoalloggi/src/components/acquisto_processing.tsx b/apps/infoalloggi/src/components/acquisto_processing.tsx index 9fa30cf..43f629c 100644 --- a/apps/infoalloggi/src/components/acquisto_processing.tsx +++ b/apps/infoalloggi/src/components/acquisto_processing.tsx @@ -56,43 +56,49 @@ export const AcquistoProcessing = ({

{t.acquisto.titolo}

- {!generatedIntent ? ( - { - setGeneratedIntent(true); - mutate({ - paymentId, - }); - }} - packId={packId} - /> - ) : isPending ? ( - - ) : ( - stripeIntent?.clientSecret && ( - <> - { + if (!generatedIntent) { + return ( + { + setGeneratedIntent(true); + mutate({ + paymentId, + }); }} - stripe={stripePromise} - > - - - - ) - )} + packId={packId} + /> + ); + } + if (isPending) { + return ; + } + if (stripeIntent?.clientSecret) { + return ( + <> + + + + + ); + } + })()} ); }; diff --git a/apps/infoalloggi/src/components/annuncio_card.tsx b/apps/infoalloggi/src/components/annuncio_card.tsx index 0c894d5..db7a4f4 100644 --- a/apps/infoalloggi/src/components/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/annuncio_card.tsx @@ -256,33 +256,32 @@ export const CarouselAnnuncio = ({ if (!video) return null; if (video.includes("youtu")) { return null; - } else { - return ( - - - - - handleOpenModal(immagini?.length || 0 + idx) - } - /> - - ); } + return ( + + + + + handleOpenModal(immagini?.length || 0 + idx) + } + /> + + ); })} @@ -322,20 +321,19 @@ export const CarouselAnnuncio = ({ if (!video) return null; if (video.includes("youtu")) { return null; - } else { - return ( - - - - ); } + return ( + + + + ); })} diff --git a/apps/infoalloggi/src/components/area-riservata/allegati.tsx b/apps/infoalloggi/src/components/area-riservata/allegati.tsx index 180ae66..4bd033e 100644 --- a/apps/infoalloggi/src/components/area-riservata/allegati.tsx +++ b/apps/infoalloggi/src/components/area-riservata/allegati.tsx @@ -193,36 +193,37 @@ export const ExtIcon = ({ if (!ext) return ; if (ext.includes("pdf")) { return ; - } else if ( + } + if ( ext.includes("image") || ["jpg", "jpeg", "png", "gif", "svg", "webp"].some((ext) => ext.includes(ext), ) ) { return ; - } else if ( + } + if ( ["html", "css", "js", "jsx", "ts", "tsx", "json", "xml"].some((ext) => ext.includes(ext), ) ) { return ; - } else if (["xls", "xlsx", "csv"].some((ext) => ext.includes(ext))) { + } + if (["xls", "xlsx", "csv"].some((ext) => ext.includes(ext))) { return ( ); - } else if ( - ["zip", "rar", "7z", "tar", "gz"].some((ext) => ext.includes(ext)) - ) { - return ; - } else if (["mp3", "wav", "ogg", "flac"].some((ext) => ext.includes(ext))) { - return ; - } else if ( - ["mp4", "avi", "mov", "wmv", "webm"].some((ext) => ext.includes(ext)) - ) { - return ; - } else { - return ; } + if (["zip", "rar", "7z", "tar", "gz"].some((ext) => ext.includes(ext))) { + return ; + } + if (["mp3", "wav", "ogg", "flac"].some((ext) => ext.includes(ext))) { + return ; + } + if (["mp4", "avi", "mov", "wmv", "webm"].some((ext) => ext.includes(ext))) { + return ; + } + return ; }; const EditFileDialog = ({ diff --git a/apps/infoalloggi/src/components/banners.tsx b/apps/infoalloggi/src/components/banners.tsx index 71cf4b8..1e85a09 100644 --- a/apps/infoalloggi/src/components/banners.tsx +++ b/apps/infoalloggi/src/components/banners.tsx @@ -6,6 +6,7 @@ import { IconMatrix, type IconType } from "~/components/IconComponents"; import { cn } from "~/lib/utils"; import type { Banners } from "~/schemas/public/Banners"; +const defaultHideDuration = 365; // days export const BannerFactory = (bannerData: Banners) => { const NEW_BANNER_KEY = `bannercookie_${bannerData.idbanner}`; @@ -55,7 +56,7 @@ export const BannerFactory = (bannerData: Banners) => { e.preventDefault(); Cookies.set(NEW_BANNER_KEY, "true", { - expires: bannerData.hide_duration || 365, + expires: bannerData.hide_duration || defaultHideDuration, }); setIsBannerToShow(false); }; diff --git a/apps/infoalloggi/src/components/chat/chat-bubble.tsx b/apps/infoalloggi/src/components/chat/chat-bubble.tsx index 01bd67e..57c0bc1 100644 --- a/apps/infoalloggi/src/components/chat/chat-bubble.tsx +++ b/apps/infoalloggi/src/components/chat/chat-bubble.tsx @@ -60,9 +60,8 @@ type ChatBubbleReadStatusProps = { export const ChatBubbleReadStatus = ({ isread }: ChatBubbleReadStatusProps) => { if (isread) { return ; - } else { - return ; } + return ; }; // ChatBubbleMessage diff --git a/apps/infoalloggi/src/components/custom_ui/dataTable-header.tsx b/apps/infoalloggi/src/components/custom_ui/dataTable-header.tsx index adf177d..455d26c 100644 --- a/apps/infoalloggi/src/components/custom_ui/dataTable-header.tsx +++ b/apps/infoalloggi/src/components/custom_ui/dataTable-header.tsx @@ -41,13 +41,13 @@ export function DataTableColumnHeader({ variant="ghost" > {title} - {column.getIsSorted() === "desc" ? ( - - ) : column.getIsSorted() === "asc" ? ( - - ) : ( - - )} + {(() => { + if (column.getIsSorted() === "desc") + return ; + if (column.getIsSorted() === "asc") + return ; + return ; + })()} diff --git a/apps/infoalloggi/src/components/custom_ui/fileUpload.tsx b/apps/infoalloggi/src/components/custom_ui/fileUpload.tsx index d27e509..b163121 100644 --- a/apps/infoalloggi/src/components/custom_ui/fileUpload.tsx +++ b/apps/infoalloggi/src/components/custom_ui/fileUpload.tsx @@ -916,13 +916,13 @@ const FileUploadItem = forwardRef( if (!fileState) return null; - const statusText = fileState.error - ? `Error: ${fileState.error}` - : fileState.status === "uploading" - ? `Uploading: ${fileState.progress}% complete` - : fileState.status === "success" - ? "Upload complete" - : "Ready to upload"; + const statusText = (() => { + if (fileState.error) return `Error: ${fileState.error}`; + if (fileState.status === "uploading") + return `Uploading: ${fileState.progress}% complete`; + if (fileState.status === "success") return "Upload complete"; + return "Ready to upload"; + })(); const ItemPrimitive = asChild ? Slot : "div"; diff --git a/apps/infoalloggi/src/components/map/custom_marker.tsx b/apps/infoalloggi/src/components/map/custom_marker.tsx index c380a14..8b41ccc 100644 --- a/apps/infoalloggi/src/components/map/custom_marker.tsx +++ b/apps/infoalloggi/src/components/map/custom_marker.tsx @@ -37,9 +37,8 @@ const getCoordsFromPointExpression = (expression?: PointExpression) => { if (!expression) return []; if (Array.isArray(expression)) { return expression; - } else { - return [expression.x, expression.y] as PointTuple; } + return [expression.x, expression.y] as PointTuple; }; const useCoordsFromPointExpression = (expression?: PointExpression) => diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx index c923f1e..fab9c15 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx @@ -199,10 +199,9 @@ const parseContrattoImport = (ingest: string) => { ? new Date(parsed.data.contratto_scadenza) : null, }; - } else { - console.error("Invalid format:", parsed.error); - return undefined; } + console.error("Invalid format:", parsed.error); + return undefined; }; const ContrattoImport = ({ @@ -950,10 +949,9 @@ const parseCaparra = (ingest: string) => { const parsed = CaparraSchema.safeParse(parsedJson); if (parsed.success) { return parsed.data; - } else { - console.error("Invalid caparra format:", parsed.error); - return undefined; } + console.error("Invalid caparra format:", parsed.error); + return undefined; }; const Caparra = ({ @@ -1165,19 +1163,16 @@ const SendConferma = ({

); - } else { - return ( - <> -

- Budget (da preferenze): {formatCurrency(servizio.budget)} -

-

- Canone Mensile (da descrizione):{" "} - {formatCurrency(data.prezzo / 100)} -

- - ); } + return ( + <> +

Budget (da preferenze): {formatCurrency(servizio.budget)}

+

+ Canone Mensile (da descrizione):{" "} + {formatCurrency(data.prezzo / 100)} +

+ + ); })()}
diff --git a/apps/infoalloggi/src/components/tables/orders-table.tsx b/apps/infoalloggi/src/components/tables/orders-table.tsx index 38d5175..20fc205 100644 --- a/apps/infoalloggi/src/components/tables/orders-table.tsx +++ b/apps/infoalloggi/src/components/tables/orders-table.tsx @@ -144,14 +144,13 @@ export const OrdiniTable = ({ data, isAdmin, userId }: PaymentsTableProps) => { Pagato ); - } else { - return ( - - - Non pagato - - ); } + return ( + + + Non pagato + + ); }, filterFn: (row, id, value) => { diff --git a/apps/infoalloggi/src/components/tables/prezziario-tables.tsx b/apps/infoalloggi/src/components/tables/prezziario-tables.tsx index 192e278..beec786 100644 --- a/apps/infoalloggi/src/components/tables/prezziario-tables.tsx +++ b/apps/infoalloggi/src/components/tables/prezziario-tables.tsx @@ -102,13 +102,13 @@ export const PrezzarioTable = ({ cell: ({ row }) => { return (
- {row.original.isTransitorio - ? row.original.isStabile - ? "Transitorio/Stabile" - : "Transitorio" - : row.original.isStabile - ? "Stabile" - : ""} + {(() => { + if (row.original.isTransitorio && row.original.isStabile) + return "Transitorio/Stabile"; + if (row.original.isTransitorio) return "Transitorio"; + if (row.original.isStabile) return "Stabile"; + return ""; + })()}
); }, diff --git a/apps/infoalloggi/src/components/tables/ricerca-table.tsx b/apps/infoalloggi/src/components/tables/ricerca-table.tsx index 9da77ed..28c0219 100644 --- a/apps/infoalloggi/src/components/tables/ricerca-table.tsx +++ b/apps/infoalloggi/src/components/tables/ricerca-table.tsx @@ -79,13 +79,14 @@ const Row = ({ Affitto {servizio.tipologia}
- {servizio.isInterrotto ? ( - Interrotto - ) : servizio.isOkAcconto && servizio.decorrenza !== null ? ( - Attivo - ) : ( - Inattivo - )} + {(() => { + if (servizio.isInterrotto) + return Interrotto; + if (servizio.isOkAcconto && servizio.decorrenza !== null) { + return Attivo; + } + return Inattivo; + })()}
{servizio.created_at.toLocaleDateString("it", { diff --git a/apps/infoalloggi/src/components/tables/servizio-table.tsx b/apps/infoalloggi/src/components/tables/servizio-table.tsx index 0f157d6..14aef73 100644 --- a/apps/infoalloggi/src/components/tables/servizio-table.tsx +++ b/apps/infoalloggi/src/components/tables/servizio-table.tsx @@ -132,13 +132,13 @@ export const TabServizio = ({ )} - {servizio.isInterrotto ? ( - Interrotto - ) : servizio.isOkAcconto && servizio.decorrenza !== null ? ( - Attivo - ) : ( - Inattivo - )} + {(() => { + if (servizio.isInterrotto) + return Interrotto; + if (servizio.isOkAcconto && servizio.decorrenza !== null) + return Attivo; + return Inattivo; + })()} & SliderProps) { - const _values = React.useMemo( - () => - Array.isArray(value) - ? value - : Array.isArray(defaultValue) - ? defaultValue - : [min, max], - [value, defaultValue, min, max], - ); + const _values = React.useMemo(() => { + if (Array.isArray(value)) return value; + if (Array.isArray(defaultValue)) return defaultValue; + return [min, max]; + }, [value, defaultValue, min, max]); return ( { if (colorOptions.has(str)) { // biome-ignore lint/style/noNonNullAssertion: return colorOptions.get(str)!; - } else { - const usercolor = getHexColorFromString(str); - colorOptions.set(str, usercolor); - return usercolor; } + const usercolor = getHexColorFromString(str); + colorOptions.set(str, usercolor); + return usercolor; }; export const UserAvatar = ({ diff --git a/apps/infoalloggi/src/middlewares/auth_middleware.ts b/apps/infoalloggi/src/middlewares/auth_middleware.ts index da050ba..6392246 100644 --- a/apps/infoalloggi/src/middlewares/auth_middleware.ts +++ b/apps/infoalloggi/src/middlewares/auth_middleware.ts @@ -79,11 +79,10 @@ export const authMiddleware = async (req: NextRequest) => { return NextResponse.redirect( new URL("/area-riservata/dashboard", req.nextUrl), ); - } else { - return NextResponse.redirect( - new URL("/area-riservata/dashboard", req.nextUrl), - ); } + return NextResponse.redirect( + new URL("/area-riservata/dashboard", req.nextUrl), + ); } // If access token is invalid, delete it const destination = new URL("/login", req.nextUrl); diff --git a/apps/infoalloggi/src/pages/annunci.tsx b/apps/infoalloggi/src/pages/annunci.tsx index 4bc83cf..e103e2f 100644 --- a/apps/infoalloggi/src/pages/annunci.tsx +++ b/apps/infoalloggi/src/pages/annunci.tsx @@ -198,10 +198,9 @@ const RicercaFilters = () => { if (t.preferenze.mesi.includes(value)) { await setConsegna(t.preferenze.mesi.indexOf(value)); return; - } else { - console.warn("Value not found in preferenze.mesi"); - await setConsegna(null); } + console.warn("Value not found in preferenze.mesi"); + await setConsegna(null); }} options={mappedConsegnaOptions} placeholder={t.seleziona_placeholder} diff --git a/apps/infoalloggi/src/pages/annuncio/[cod].tsx b/apps/infoalloggi/src/pages/annuncio/[cod].tsx index 931dd59..88244c6 100644 --- a/apps/infoalloggi/src/pages/annuncio/[cod].tsx +++ b/apps/infoalloggi/src/pages/annuncio/[cod].tsx @@ -309,32 +309,31 @@ const Pricing = ({ } /> ); - } else { - return ( - - - - {t.pricing_cmp.cta_costo} - - - - - - - ); } + return ( + + + + {t.pricing_cmp.cta_costo} + + + + + + + ); }; const TestiAnnuncio = ({ @@ -459,11 +458,13 @@ const CardInfos = ({ data }: { data: Annunci }) => {
- {data.numero_camere && data.numero_camere - ? data.numero_camere > 1 - ? `${data.numero_camere} ${t.card.camere2}` - : `${data.numero_camere} ${t.card.camere1}` - : "N/A"} + {(() => { + if (!data.numero_camere) return "N/A"; + if (data.numero_camere > 1) + return `${data.numero_camere} ${t.card.camere2}`; + if (data.numero_camere === 1) + return `${data.numero_camere} ${t.card.camere1}`; + })()}
@@ -492,11 +493,12 @@ const CardInfos = ({ data }: { data: Annunci }) => {
- {data.piano && data.piano === "0" - ? "piano terra" - : data.piano === "0.5" - ? "piano rialz." - : `${data.piano}° piano`} + {(() => { + if (data.piano === "0") return "piano terra"; + if (data.piano === "0.5") return "piano rialz."; + if (data.piano) return `${data.piano}° piano`; + return ""; + })()}
@@ -635,27 +637,15 @@ const AnnuncioFooter = ({ if (!video) return null; if (video.includes("youtu")) { return null; - /*return ( -