From 71036954c98297c362628e54f61cc1236084b738 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 14 Apr 2026 16:36:10 +0200 Subject: [PATCH] refactor: unify password hook usage across forms and update related imports --- apps/infoalloggi/src/forms/FormChangePassword.tsx | 8 +++++--- apps/infoalloggi/src/forms/FormNewUser.tsx | 4 ++-- apps/infoalloggi/src/forms/FormOverridePassword.tsx | 4 ++-- apps/infoalloggi/src/forms/FormRstPwFromToken.tsx | 4 ++-- apps/infoalloggi/src/hooks/usePassword.ts | 4 ++++ .../infoalloggi/src/pages/auth/accetta-invito/[token].tsx | 4 ++-- apps/infoalloggi/src/server/api/routers/auth.ts | 4 ++-- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/infoalloggi/src/forms/FormChangePassword.tsx b/apps/infoalloggi/src/forms/FormChangePassword.tsx index 1bdee1f..343d617 100644 --- a/apps/infoalloggi/src/forms/FormChangePassword.tsx +++ b/apps/infoalloggi/src/forms/FormChangePassword.tsx @@ -12,7 +12,7 @@ import { } from "~/components/custom_ui/form"; import { Button } from "~/components/ui/button"; import Input from "~/components/ui/input"; -import { useMildPassword } from "~/hooks/usePassword"; +import { usePassword } from "~/hooks/usePassword"; import { cn } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; import { useTranslation } from "~/providers/I18nProvider"; @@ -27,7 +27,7 @@ export const ChangePasswordForm = () => { strengthScore, maxStrength, toggleVisibility, - } = useMildPassword(); + } = usePassword(); const router = useRouter(); const ChangePasswordFormSchema = z @@ -173,7 +173,9 @@ export const ChangePasswordForm = () => { "h-full transition-all duration-500 ease-out", getStrengthColor(strengthScore), )} - style={{ width: `${(strengthScore / maxStrength) * 100}%` }} + style={{ + width: `${(strengthScore / maxStrength) * 100}%`, + }} /> diff --git a/apps/infoalloggi/src/forms/FormNewUser.tsx b/apps/infoalloggi/src/forms/FormNewUser.tsx index 6b0e4ad..5699121 100644 --- a/apps/infoalloggi/src/forms/FormNewUser.tsx +++ b/apps/infoalloggi/src/forms/FormNewUser.tsx @@ -12,7 +12,7 @@ import { import { Button } from "~/components/ui/button"; import Input from "~/components/ui/input"; import { PhoneInput } from "~/components/ui/phone-input"; -import { useMildPassword } from "~/hooks/usePassword"; +import { usePassword } from "~/hooks/usePassword"; import { generatePassword } from "~/lib/basicPwGenerator"; import { cn } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; @@ -32,7 +32,7 @@ export const FormNewUser = ({ strengthScore, toggleVisibility, maxStrength, - } = useMildPassword(); + } = usePassword(); const NewUserSchema = z .object({ diff --git a/apps/infoalloggi/src/forms/FormOverridePassword.tsx b/apps/infoalloggi/src/forms/FormOverridePassword.tsx index 5d119ff..c9ccb43 100644 --- a/apps/infoalloggi/src/forms/FormOverridePassword.tsx +++ b/apps/infoalloggi/src/forms/FormOverridePassword.tsx @@ -22,7 +22,7 @@ import { import Input from "~/components/ui/input"; import { Label } from "~/components/ui/label"; import { Separator } from "~/components/ui/separator"; -import { useMildPassword } from "~/hooks/usePassword"; +import { usePassword } from "~/hooks/usePassword"; import { generatePassword } from "~/lib/basicPwGenerator"; import { cn } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; @@ -39,7 +39,7 @@ export const OverridePasswordForm = ({ id }: { id: UsersId }) => { strengthScore, toggleVisibility, maxStrength, - } = useMildPassword(); + } = usePassword(); const OverridePasswordFormSchema = z .object({ diff --git a/apps/infoalloggi/src/forms/FormRstPwFromToken.tsx b/apps/infoalloggi/src/forms/FormRstPwFromToken.tsx index 598cb77..6699bba 100644 --- a/apps/infoalloggi/src/forms/FormRstPwFromToken.tsx +++ b/apps/infoalloggi/src/forms/FormRstPwFromToken.tsx @@ -11,7 +11,7 @@ import { FormMessage, } from "~/components/custom_ui/form"; import Input from "~/components/ui/input"; -import { useMildPassword } from "~/hooks/usePassword"; +import { usePassword } from "~/hooks/usePassword"; import { cn } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; import { useTranslation } from "~/providers/I18nProvider"; @@ -29,7 +29,7 @@ export const FormRstPwFromToken = (props: { token: string }) => { strengthScore, toggleVisibility, maxStrength, - } = useMildPassword(); + } = usePassword(); const ResetFormSchema = z .object({ diff --git a/apps/infoalloggi/src/hooks/usePassword.ts b/apps/infoalloggi/src/hooks/usePassword.ts index 113415b..56d9d5f 100644 --- a/apps/infoalloggi/src/hooks/usePassword.ts +++ b/apps/infoalloggi/src/hooks/usePassword.ts @@ -188,3 +188,7 @@ export const useMildPassword = (): PasswordManager => { maxStrength: 3, }; }; + +export const zPassword = zMildPassword; + +export const usePassword = useMildPassword; diff --git a/apps/infoalloggi/src/pages/auth/accetta-invito/[token].tsx b/apps/infoalloggi/src/pages/auth/accetta-invito/[token].tsx index 41acbbd..2e32716 100644 --- a/apps/infoalloggi/src/pages/auth/accetta-invito/[token].tsx +++ b/apps/infoalloggi/src/pages/auth/accetta-invito/[token].tsx @@ -30,7 +30,7 @@ import { } from "~/components/ui/alert-dialog"; import { Button } from "~/components/ui/button"; import Input from "~/components/ui/input"; -import { useMildPassword } from "~/hooks/usePassword"; +import { usePassword } from "~/hooks/usePassword"; import { cn } from "~/lib/utils"; import { useZodForm } from "~/lib/zodForm"; import type { NextPageWithLayout } from "~/pages/_app"; @@ -65,7 +65,7 @@ const AcceptInvitePage: NextPageWithLayout = ({ strengthScore, toggleVisibility, maxStrength, - } = useMildPassword(); + } = usePassword(); const router = useRouter(); const schema = z diff --git a/apps/infoalloggi/src/server/api/routers/auth.ts b/apps/infoalloggi/src/server/api/routers/auth.ts index b29abe1..1e2229a 100644 --- a/apps/infoalloggi/src/server/api/routers/auth.ts +++ b/apps/infoalloggi/src/server/api/routers/auth.ts @@ -1,5 +1,5 @@ import { z } from "zod/v4"; -import { zMildPassword } from "~/hooks/usePassword"; +import { zPassword } from "~/hooks/usePassword"; import { adminProcedure, createTRPCRouter, @@ -38,7 +38,7 @@ export const authRouter = createTRPCRouter({ cognome: z.string().nonempty("Inserisci un cognome valido"), email: z.email(), nome: z.string().nonempty("Inserisci un nome valido"), - password: zMildPassword, + password: zPassword, telefono: z.string().nonempty("Inserisci un numero di telefono"), }), )