From 7de7d90b95bc5a3b8e9c0cf89c9e7a1bf54c7861 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Mon, 15 Dec 2025 12:23:41 +0100 Subject: [PATCH] cleanup --- .../components/area-riservata/potenziali.tsx | 2 +- .../src/components/custom_ui/InputNumber.tsx | 2 +- .../components/custom_ui/animated-button.tsx | 128 ---------- apps/infoalloggi/src/components/prezzi.tsx | 72 ------ .../components/schedaAnnuncioStampabile.tsx | 2 +- .../servizio/service-duration-display.tsx | 128 ---------- .../components/servizio/servizio_actions.tsx | 2 +- .../src/components/subscriptionDbg.tsx | 65 ----- apps/infoalloggi/src/components/timeline.tsx | 231 ------------------ .../src/components/upload_modal.tsx | 2 +- apps/infoalloggi/src/lib/annuncio_details.ts | 15 -- apps/infoalloggi/src/lib/catasto.ts | 8 +- apps/infoalloggi/src/lib/userViewContext.tsx | 2 +- .../src/server/api/routers/potenziali.ts | 8 +- .../server/controllers/catasto.controller.ts | 3 +- .../src/server/services/password.service.ts | 5 - 16 files changed, 15 insertions(+), 660 deletions(-) delete mode 100644 apps/infoalloggi/src/components/custom_ui/animated-button.tsx delete mode 100644 apps/infoalloggi/src/components/servizio/service-duration-display.tsx delete mode 100644 apps/infoalloggi/src/components/subscriptionDbg.tsx delete mode 100644 apps/infoalloggi/src/components/timeline.tsx diff --git a/apps/infoalloggi/src/components/area-riservata/potenziali.tsx b/apps/infoalloggi/src/components/area-riservata/potenziali.tsx index db11d9e..37b79a3 100644 --- a/apps/infoalloggi/src/components/area-riservata/potenziali.tsx +++ b/apps/infoalloggi/src/components/area-riservata/potenziali.tsx @@ -192,7 +192,7 @@ export const NewColumn = () => { ); }; -export const NewCard = ({ columnId }: { columnId: PotenzialiGroupsId }) => { +const NewCard = ({ columnId }: { columnId: PotenzialiGroupsId }) => { const [newItemName, setNewItemName] = useState(""); const [newItemDescrizione, setNewItemDescrizione] = useState(""); const [newItemUserid, setNewItemUserid] = useState(null); diff --git a/apps/infoalloggi/src/components/custom_ui/InputNumber.tsx b/apps/infoalloggi/src/components/custom_ui/InputNumber.tsx index adaf6a5..5bf3ee8 100644 --- a/apps/infoalloggi/src/components/custom_ui/InputNumber.tsx +++ b/apps/infoalloggi/src/components/custom_ui/InputNumber.tsx @@ -5,7 +5,7 @@ import { cn } from "~/lib/utils"; import { Button } from "../ui/button"; import { Input } from "../ui/input"; -export interface NumberInputProps +interface NumberInputProps extends Omit { stepper?: number; thousandSeparator?: string; diff --git a/apps/infoalloggi/src/components/custom_ui/animated-button.tsx b/apps/infoalloggi/src/components/custom_ui/animated-button.tsx deleted file mode 100644 index fe5e4d9..0000000 --- a/apps/infoalloggi/src/components/custom_ui/animated-button.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { type AnimationSequence, useAnimate } from "framer-motion"; -import { - type ComponentPropsWithoutRef, - forwardRef, - useImperativeHandle, -} from "react"; -import { IconMatrix, type IconType } from "~/components/IconComponents"; -import { Button } from "~/components/ui/button"; -import { cn } from "~/lib/utils"; - -const randomNumberBetween = (min: number, max: number) => { - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -export interface AnimatedButtonRef { - sparkle: () => void; -} - -interface AnimatedButtonProps extends ComponentPropsWithoutRef { - sparklesRadius?: number; - sparklesNumber?: number; - sparklesClassName?: string; - sparklesIcon?: IconType; - sparklesScale?: [number, number]; -} - -export const AnimatedButton = forwardRef< - AnimatedButtonRef, - AnimatedButtonProps ->( - ( - { - sparklesRadius = 100, - sparklesNumber = 20, - sparklesClassName = "fill-blue-500 stroke-transparent", - sparklesIcon = "star", - sparklesScale = [1.5, 2.5], - ...props - }, - ref, - ) => { - const [scope, animate] = useAnimate(); - - const Sparkles = () => { - const sparkles = Array.from({ length: sparklesNumber }); - const sparklesAnimation: AnimationSequence = sparkles.map((_, index) => [ - `.sparkle-${index}`, - { - opacity: 1, - scale: randomNumberBetween(sparklesScale[0], sparklesScale[1]), - x: randomNumberBetween(-sparklesRadius, sparklesRadius), - y: randomNumberBetween(-sparklesRadius, sparklesRadius), - }, - { - at: "<", - delay: index * 0.01, - duration: 0.4, - }, - ]); - - const sparklesFadeOut: AnimationSequence = sparkles.map((_, index) => [ - `.sparkle-${index}`, - { - opacity: 0, - scale: 0, - }, - { - at: "<", - duration: 0.3, - }, - ]); - - const sparklesReset: AnimationSequence = sparkles.map((_, index) => [ - `.sparkle-${index}`, - { - x: 0, - y: 0, - }, - { - duration: 0.000001, - }, - ]); - - animate([ - ...sparklesReset, - ["button", { scale: 0.8 }, { at: "<", duration: 0.1 }], - ["button", { scale: 1 }, { duration: 0.1 }], - ...sparklesAnimation, - ["button", { duration: 0.000001 }], - ...sparklesFadeOut, - ]); - }; - - useImperativeHandle(ref, () => ({ - sparkle: Sparkles, - })); - - return ( -
- -
- ); - }, -); - -AnimatedButton.displayName = "AnimatedButton"; diff --git a/apps/infoalloggi/src/components/prezzi.tsx b/apps/infoalloggi/src/components/prezzi.tsx index f3d4764..96727e8 100644 --- a/apps/infoalloggi/src/components/prezzi.tsx +++ b/apps/infoalloggi/src/components/prezzi.tsx @@ -311,75 +311,3 @@ export const PricingComponentConsulenza = ({ ); }; - -export const PrezziShow = () => { - const { t } = useTranslation(); - const { data: prezziario, isLoading } = - api.prezziario.getPrezziPerTipologiaAll.useQuery(); - if (isLoading) return ; - if (!prezziario) return null; - - const pricingBreve = prezziario.transitorio.saldi.map((s) => ({ - downPayment: prezziario.transitorio.acconto.prezzo_cent / 100, - secondPayment: s.prezzo_cent / 100, - })); - - const pricingStabile = prezziario.stabile.saldi.map((s) => ({ - downPayment: prezziario.stabile.acconto.prezzo_cent / 100, - secondPayment: s.prezzo_cent / 100, - })); - return ( -
-
-

- Quanto costa il servizio? -

-

- Il nostro servizio è pensato per essere accessibile e conveniente, con - tariffe chiare e senza sorprese. Basate sul tipo di affitto che - desideri, le nostre tariffe sono suddivise in due categorie - principali: Affitto Transitorio e Affitto Stabile. -

-
- - - - Affitto Transitorio - - - Affitto Stabile - - - - - - - - - -
- ); -}; diff --git a/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx b/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx index 8814747..2f683a8 100644 --- a/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx +++ b/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx @@ -229,7 +229,7 @@ export function SchedaAnnuncioStampabile({ data }: { data: Annunci }) { ); } -export function SchedaAnnuncio({ data }: { data: Annunci }) { +function SchedaAnnuncio({ data }: { data: Annunci }) { const companyAddress = "Via Beata Giovanna, 1 a Bassano del Grappa (VI)\nTel. +39 0424529869\nEmail: arca@infoalloggi.it"; diff --git a/apps/infoalloggi/src/components/servizio/service-duration-display.tsx b/apps/infoalloggi/src/components/servizio/service-duration-display.tsx deleted file mode 100644 index ac7f05a..0000000 --- a/apps/infoalloggi/src/components/servizio/service-duration-display.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { add, differenceInDays } from "date-fns"; -import { CalendarClock, CalendarDays, Clock, Hourglass } from "lucide-react"; -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from "~/components/ui/accordion"; -import { Card, CardContent } from "~/components/ui/card"; -import { Progress } from "~/components/ui/progress"; // Import the Progress component -import { useMediaQuery } from "~/hooks/use-media-query"; - -export const ServizioDuration = ({ - decorrenza, -}: { - decorrenza: Date | null; -}) => { - const isDesktop = useMediaQuery("(min-width: 768px)"); - if (!decorrenza) { - return null; // If decorrenza is null, do not render the component - } - return ( - - - -
- - Validità servizio -
-
- - - -
-
- ); -}; - -interface ServiceDurationDisplayProps { - decorrenza: Date; - scadenza: Date; - recessoDays: number; -} - -/** - * A sleek, light-themed component for displaying service duration, - * including start date, end date, and trial period, with a progress bar. - */ -function ServiceDurationDisplay({ - decorrenza, - scadenza, - recessoDays, -}: ServiceDurationDisplayProps) { - // Calculate remaining days - const diffDays = differenceInDays(scadenza, new Date()) + 1; - const remainingDaysText = diffDays >= 0 ? `${diffDays} giorni` : "Concluso"; - - const progressPercentage = ((60 - diffDays) / 60) * 100; // Assuming 60 days is the full duration for 100% progress - - return ( - - -
-
-
- -
-
- -
-
-
- - {/* Progress Bar */} -
- -
- {remainingDaysText} -
-
-
-
- ); -} diff --git a/apps/infoalloggi/src/components/servizio/servizio_actions.tsx b/apps/infoalloggi/src/components/servizio/servizio_actions.tsx index 3146f46..c0fc5fb 100644 --- a/apps/infoalloggi/src/components/servizio/servizio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/servizio_actions.tsx @@ -154,7 +154,7 @@ const ServizioInfos = () => { ); }; -export const ServizioBasicActions = ({ className }: { className?: string }) => { +const ServizioBasicActions = ({ className }: { className?: string }) => { const { servizio, isAdmin } = useServizio(); const canUserEdit = diff --git a/apps/infoalloggi/src/components/subscriptionDbg.tsx b/apps/infoalloggi/src/components/subscriptionDbg.tsx deleted file mode 100644 index 6e0c0fd..0000000 --- a/apps/infoalloggi/src/components/subscriptionDbg.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { cn } from "~/lib/utils"; -import { run } from "~/utils/utils"; - -export function SubscriptionStatus({ - status, - errorMsg, - reset, -}: { - status: "idle" | "connecting" | "pending" | "error"; - errorMsg: string | undefined; - reset: () => void; -}) { - return ( -
{ - switch (status) { - case "idle": - case "connecting": - return "bg-white text-gray-500 dark:bg-gray-900 dark:text-gray-400"; - case "error": - return "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"; - case "pending": - return "bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200"; - } - }), - )} - > - {run(() => { - switch (status) { - case "idle": - case "connecting": - // treat idle and connecting the same - - return ( -
- Connecting... - {errorMsg && " (There are connection problems)"} {errorMsg} -
- ); - case "error": - // something went wrong - return ( -
- Error - {errorMsg} - -
- ); - case "pending": - // we are polling for new messages - return
Connected - awaiting messages
; - } - })} -
- ); -} diff --git a/apps/infoalloggi/src/components/timeline.tsx b/apps/infoalloggi/src/components/timeline.tsx deleted file mode 100644 index 8380329..0000000 --- a/apps/infoalloggi/src/components/timeline.tsx +++ /dev/null @@ -1,231 +0,0 @@ -"use client"; - -import { Slot } from "@radix-ui/react-slot"; -import * as React from "react"; - -import { cn } from "~/lib/utils"; - -type TimelineContextProps = { - orientation: "horizontal" | "vertical"; -}; - -const TimelineContext = React.createContext(null); - -function useTimeline() { - const context = React.useContext(TimelineContext); - if (!context) { - throw new Error("useTimeline must be used within a ."); - } - - return context; -} - -interface TimelineProps extends React.ComponentPropsWithoutRef<"ol"> { - orientation?: "horizontal" | "vertical"; -} - -function Timeline({ - className, - orientation = "vertical", - ...props -}: TimelineProps) { - return ( - -
    - - ); -} -interface TimelineItemProps extends React.ComponentPropsWithoutRef<"li"> { - asChild?: boolean; -} - -function TimelineItem({ className, asChild, ...props }: TimelineItemProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "li"; - - return ( - - ); -} - -interface TimelineSeparatorProps extends React.ComponentPropsWithoutRef<"div"> { - asChild?: boolean; -} - -function TimelineSeparator({ - className, - asChild, - ...props -}: TimelineSeparatorProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -interface TimelineDotProps extends React.ComponentPropsWithoutRef<"div"> { - variant?: "default" | "outline"; - asChild?: boolean; -} - -function TimelineDot({ - variant = "default", - className, - asChild, - ...props -}: TimelineDotProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -interface TimelineConnectorProps extends React.ComponentPropsWithoutRef<"div"> { - asChild?: boolean; -} - -function TimelineConnector({ - className, - asChild, - ...props -}: TimelineConnectorProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -interface TimelineContentProps extends React.ComponentPropsWithoutRef<"div"> { - asChild?: boolean; -} - -function TimelineContent({ - className, - asChild, - ...props -}: TimelineContentProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -interface TimelineTitleProps extends React.ComponentPropsWithoutRef<"div"> { - asChild?: boolean; -} - -function TimelineTitle({ className, asChild, ...props }: TimelineTitleProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -interface TimelineDescriptionProps - extends React.ComponentPropsWithoutRef<"div"> { - asChild?: boolean; -} - -function TimelineDescription({ - className, - asChild, - ...props -}: TimelineDescriptionProps) { - const { orientation } = useTimeline(); - const Comp = asChild ? Slot : "div"; - - return ( - - ); -} - -export { - Timeline, - TimelineItem, - TimelineSeparator, - TimelineDot, - TimelineConnector, - TimelineContent, - TimelineTitle, - TimelineDescription, - useTimeline, -}; diff --git a/apps/infoalloggi/src/components/upload_modal.tsx b/apps/infoalloggi/src/components/upload_modal.tsx index a6a281b..7a482d5 100644 --- a/apps/infoalloggi/src/components/upload_modal.tsx +++ b/apps/infoalloggi/src/components/upload_modal.tsx @@ -28,7 +28,7 @@ import type { UsersId } from "~/schemas/public/Users"; import type { UsersStorageUserStorageId } from "~/schemas/public/UsersStorage"; import { api } from "~/utils/api"; -export type UploadCallback = (args: { +type UploadCallback = (args: { storageIds: string[]; userStorageIds: UsersStorageUserStorageId[]; }) => void; diff --git a/apps/infoalloggi/src/lib/annuncio_details.ts b/apps/infoalloggi/src/lib/annuncio_details.ts index 0e87752..f94bd13 100644 --- a/apps/infoalloggi/src/lib/annuncio_details.ts +++ b/apps/infoalloggi/src/lib/annuncio_details.ts @@ -38,18 +38,3 @@ export const camereTesti = ({ } 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 : ""; -}; diff --git a/apps/infoalloggi/src/lib/catasto.ts b/apps/infoalloggi/src/lib/catasto.ts index 7b4a44f..487cba2 100644 --- a/apps/infoalloggi/src/lib/catasto.ts +++ b/apps/infoalloggi/src/lib/catasto.ts @@ -3,25 +3,25 @@ import type { Nazioni } from "~/schemas/public/Nazioni"; import type { Provincie } from "~/schemas/public/Provincie"; export const ITALY_CATASTO_CODE = "0000"; -export const isNazioneCatastoValid = (str: string) => { +const isNazioneCatastoValid = (str: string) => { if (str.length !== 4) return false; if (str === ITALY_CATASTO_CODE) return true; return /^Z[0-9]{3}$/.test(str); }; -export const isComuneCatastoValid = (str: string) => { +const isComuneCatastoValid = (str: string) => { if (str.length !== 4) return false; return /^[A-Z][0-9]{3}$/.test(str); }; -export const getComuneFromCatasto = ( +const getComuneFromCatasto = ( codice_catasto: string, comuni_options: Comuni[], ): Comuni | undefined => { return comuni_options.find((c) => c.catasto === codice_catasto); }; -export const getNazioneFromCatasto = ( +const getNazioneFromCatasto = ( codice_catasto: string, nazioni_options: Nazioni[], ): Nazioni | undefined => { diff --git a/apps/infoalloggi/src/lib/userViewContext.tsx b/apps/infoalloggi/src/lib/userViewContext.tsx index b555024..cfa79e5 100644 --- a/apps/infoalloggi/src/lib/userViewContext.tsx +++ b/apps/infoalloggi/src/lib/userViewContext.tsx @@ -7,7 +7,7 @@ import { api } from "~/utils/api"; type UserViewContextType = UserWAnagrafica & { chatid: ChatsChatid | null }; -export const UserViewContext = createContext(null); +const UserViewContext = createContext(null); export const UserViewProvider: FC<{ children: ReactNode; userId: UsersId }> = ({ children, diff --git a/apps/infoalloggi/src/server/api/routers/potenziali.ts b/apps/infoalloggi/src/server/api/routers/potenziali.ts index 7f94c07..210cb42 100644 --- a/apps/infoalloggi/src/server/api/routers/potenziali.ts +++ b/apps/infoalloggi/src/server/api/routers/potenziali.ts @@ -19,26 +19,26 @@ import { updatePotenziali, } from "~/server/services/potenziali.service"; -export const zPotenzialiId = z.custom( +const zPotenzialiId = z.custom( (val) => typeof val === "string" && val.length > 0, { message: "Invalid PotenzialiId" }, ); -export const zNewPotenziali = z.custom( +const zNewPotenziali = z.custom( (val) => { return typeof val === "object" && val !== null; }, { message: "Invalid NewPotenziali" }, ); -export const zPotenzialiUpdate = z.custom( +const zPotenzialiUpdate = z.custom( (val) => { return typeof val === "object" && val !== null; }, { message: "Invalid PotenzialiUpdate" }, ); -export const zPotenzialiGroupId = z.custom( +const zPotenzialiGroupId = z.custom( (val) => typeof val === "string" && val.length > 0, { message: "Invalid PotenzialiGroupsId" }, ); diff --git a/apps/infoalloggi/src/server/controllers/catasto.controller.ts b/apps/infoalloggi/src/server/controllers/catasto.controller.ts index 0d602cf..883bdf7 100644 --- a/apps/infoalloggi/src/server/controllers/catasto.controller.ts +++ b/apps/infoalloggi/src/server/controllers/catasto.controller.ts @@ -1,9 +1,8 @@ import { TRPCError } from "@trpc/server"; -import type { Comuni, ComuniId } from "~/schemas/public/Comuni"; +import type { ComuniId } from "~/schemas/public/Comuni"; import type { NazioniId } from "~/schemas/public/Nazioni"; import { db } from "../db"; -export type Comune = Pick; export const getComuni = async () => { try { return await db.selectFrom("comuni").selectAll().execute(); diff --git a/apps/infoalloggi/src/server/services/password.service.ts b/apps/infoalloggi/src/server/services/password.service.ts index 994442a..0c81231 100644 --- a/apps/infoalloggi/src/server/services/password.service.ts +++ b/apps/infoalloggi/src/server/services/password.service.ts @@ -30,8 +30,3 @@ export async function comparePasswords({ export function generateSalt() { return crypto.randomBytes(16).toString("hex").normalize(); } - -export function generateTemporaryPassword() { - // Generate readable temporary password (e.g., "Abc12345") - return crypto.randomBytes(4).toString("hex"); -}