From 5327cc86c6280992aa6c8e0eb4d4eda584854b8b Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 17 Mar 2026 18:47:35 +0100 Subject: [PATCH] feat: add note field to Users schema and implement NoteUtenteDialog for user notes management --- .../area-riservata/userViewHeader.tsx | 67 ++++++++++++++++++- apps/infoalloggi/src/schemas/public/Users.ts | 2 + .../src/server/api/routers/comunicazioni.ts | 5 +- .../src/server/api/routers/event_queue.ts | 5 +- 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx b/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx index e668652..0938956 100644 --- a/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx +++ b/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx @@ -3,6 +3,7 @@ import { ExternalLink, Mail, MessagesSquare, + NotebookPen, Paperclip, Search, ShoppingBag, @@ -12,7 +13,18 @@ import { import Link from "next/link"; import { usePathname } from "next/navigation"; import { useRouter } from "next/router"; +import { useState } from "react"; import toast from "react-hot-toast"; +import LoadingButton from "~/components/custom_ui/loading-button"; +import { Textarea } from "~/components/custom_ui/textarea"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "~/components/ui/dialog"; import { useUserViewContext } from "~/lib/userViewContext"; import { api } from "~/utils/api"; import { Confirm } from "../confirm"; @@ -45,7 +57,7 @@ export const UserViewHeader = () => { if (!data) return
Errore
; return (
-
+
{data.username}
@@ -72,6 +84,7 @@ export const UserViewHeader = () => { Invita al sito +
@@ -205,8 +218,8 @@ const IntestazioneMaker = () => { } // Format names - const cognome = titleCase(data.cognome); - const nome = titleCase(data.nome); + const cognome = data.cognome.toUpperCase(); + const nome = data.nome.toUpperCase(); const viaResidenza = titleCase(data.via_residenza); const comuneNascita = titleCase(comune_nascita.nome); const comuneResidenza = titleCase(comune_residenza.nome); @@ -260,3 +273,51 @@ function titleCase(str: string | null | undefined): string { }) .join(" "); } + +const NoteUtenteDialog = () => { + const { id, note } = useUserViewContext(); + const [newNote, setNewNote] = useState(note || ""); + const utils = api.useUtils(); + const { mutate, isPending } = api.users.editUser.useMutation({ + onSuccess: async () => { + toast.success("Note aggiornate con successo"); + await utils.users.invalidate(); + }, + onError: (error) => { + toast.error(error.message); + }, + }); + + return ( + + + + + + + Note Utente + note + +
+