diff --git a/package-lock.json b/package-lock.json index 27eaffd2c..c37c83189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -974,9 +974,9 @@ } }, "node_modules/@inertiajs/core": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@inertiajs/core/-/core-2.1.1.tgz", - "integrity": "sha512-FcX5dDdrtt55sNAJpfqqwfpLLyTO3+au0KxMTCtRZ/ZzjUrWkPe1V9ysI41NKNRtTfyRT6S4qWKkct9pOBjmaQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@inertiajs/core/-/core-2.1.2.tgz", + "integrity": "sha512-fS3bDanwIZMEhtndhs1NvDvFN7y9Nx+FPkuBLSjIvYXFVmwieZmj+q2SYLXVl/jKt0qg69GwfLVrNm+gFiFbMg==", "dependencies": { "axios": "^1.8.2", "es-toolkit": "^1.34.1", @@ -984,11 +984,11 @@ } }, "node_modules/@inertiajs/react": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@inertiajs/react/-/react-2.1.1.tgz", - "integrity": "sha512-V675kDbnRsVBwnpL/07LQ9gjr1NZa5Epe0Puuz1LnN1UQgerix85X8tUKE8gNSOw24q6Fbo8Yv+qP3M+58FnSg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@inertiajs/react/-/react-2.1.2.tgz", + "integrity": "sha512-hh3dQxoEumdjSRyMajYkEnG3fb3xkyexBD8tTSjo5OeulE/VteEjS7ZM8tNseM7ya/jb3G6ccoc5MSlYEh6atg==", "dependencies": { - "@inertiajs/core": "2.1.1", + "@inertiajs/core": "2.1.2", "es-toolkit": "^1.33.0" }, "peerDependencies": { @@ -2635,9 +2635,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.17.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.17.1.tgz", - "integrity": "sha512-y3tBaz+rjspDTylNjAX37jEC3TETEFGNJL6uQDxwF9/8GLLIjW1rvVHlynyuUKMnMr1Roq8jOv3vkopBjC4/VA==", + "version": "22.17.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.17.2.tgz", + "integrity": "sha512-gL6z5N9Jm9mhY+U2KXZpteb+09zyffliRkZyZOHODGATyC5B1Jt/7TzuuiLkFsSUMLbS1OLmlj/E+/3KF4Q/4w==", "devOptional": true, "dependencies": { "undici-types": "~6.21.0" @@ -3614,9 +3614,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.200", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.200.tgz", - "integrity": "sha512-rFCxROw7aOe4uPTfIAx+rXv9cEcGx+buAF4npnhtTqCJk5KDFRnh3+KYj7rdVh6lsFt5/aPs+Irj9rZ33WMA7w==" + "version": "1.5.202", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.202.tgz", + "integrity": "sha512-NxbYjRmiHcHXV1Ws3fWUW+SLb62isauajk45LUJ/HgIOkUA7jLZu/X2Iif+X9FBNK8QkF9Zb4Q2mcwXCcY30mg==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -6650,9 +6650,12 @@ } }, "node_modules/tinyglobby/node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -7025,9 +7028,12 @@ } }, "node_modules/vite/node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, diff --git a/resources/js/components/delete-user.tsx b/resources/js/components/delete-user.tsx index 0af86a760..25870ab2f 100644 --- a/resources/js/components/delete-user.tsx +++ b/resources/js/components/delete-user.tsx @@ -37,7 +37,7 @@ export default function DeleteUser() { preserveScroll: true, }} onError={() => passwordInput.current?.focus()} - onSubmitComplete={(form) => form.reset()} + resetOnSuccess className="space-y-6" > {({ resetAndClearErrors, processing, errors }) => ( diff --git a/resources/js/pages/auth/confirm-password.tsx b/resources/js/pages/auth/confirm-password.tsx index 4d05d49fe..817b7decf 100644 --- a/resources/js/pages/auth/confirm-password.tsx +++ b/resources/js/pages/auth/confirm-password.tsx @@ -14,7 +14,7 @@ export default function ConfirmPassword() { > -
form.reset('password')}> + {({ processing, errors }) => (
diff --git a/resources/js/pages/auth/login.tsx b/resources/js/pages/auth/login.tsx index 991232aac..6eee80912 100644 --- a/resources/js/pages/auth/login.tsx +++ b/resources/js/pages/auth/login.tsx @@ -18,7 +18,7 @@ export default function Login({ status, canResetPassword }: LoginProps) { - form.reset('password')} className="flex flex-col gap-6"> + {({ processing, errors }) => ( <>
diff --git a/resources/js/pages/auth/register.tsx b/resources/js/pages/auth/register.tsx index ba81583e6..608f4ab21 100644 --- a/resources/js/pages/auth/register.tsx +++ b/resources/js/pages/auth/register.tsx @@ -15,7 +15,7 @@ export default function Register() { form.reset('password', 'password_confirmation')} + resetOnSuccess={['password', 'password_confirmation']} disableWhileProcessing className="flex flex-col gap-6" > diff --git a/resources/js/pages/auth/reset-password.tsx b/resources/js/pages/auth/reset-password.tsx index 694c54d27..c6d248f55 100644 --- a/resources/js/pages/auth/reset-password.tsx +++ b/resources/js/pages/auth/reset-password.tsx @@ -21,7 +21,7 @@ export default function ResetPassword({ token, email }: ResetPasswordProps) { method="post" action={route('password.store')} transform={(data) => ({ ...data, token, email })} - onSubmitComplete={(form) => form.reset('password', 'password_confirmation')} + resetOnSuccess={['password', 'password_confirmation']} > {({ processing, errors }) => (
diff --git a/resources/js/pages/settings/password.tsx b/resources/js/pages/settings/password.tsx index e308836cb..a42b84fd0 100644 --- a/resources/js/pages/settings/password.tsx +++ b/resources/js/pages/settings/password.tsx @@ -3,8 +3,8 @@ import AppLayout from '@/layouts/app-layout'; import SettingsLayout from '@/layouts/settings/layout'; import { type BreadcrumbItem } from '@/types'; import { Transition } from '@headlessui/react'; -import { Head, useForm } from '@inertiajs/react'; -import { FormEventHandler, useRef } from 'react'; +import { Form, Head } from '@inertiajs/react'; +import { useRef } from 'react'; import HeadingSmall from '@/components/heading-small'; import { Button } from '@/components/ui/button'; @@ -22,32 +22,6 @@ export default function Password() { const passwordInput = useRef(null); const currentPasswordInput = useRef(null); - const { data, setData, errors, put, reset, processing, recentlySuccessful } = useForm({ - current_password: '', - password: '', - password_confirmation: '', - }); - - const updatePassword: FormEventHandler = (e) => { - e.preventDefault(); - - put(route('password.update'), { - preserveScroll: true, - onSuccess: () => reset(), - onError: (errors) => { - if (errors.password) { - reset('password', 'password_confirmation'); - passwordInput.current?.focus(); - } - - if (errors.current_password) { - reset('current_password'); - currentPasswordInput.current?.focus(); - } - }, - }); - }; - return ( @@ -56,71 +30,90 @@ export default function Password() {
- -
- - - setData('current_password', e.target.value)} - type="password" - className="mt-1 block w-full" - autoComplete="current-password" - placeholder="Current password" - /> - - -
- -
- - - setData('password', e.target.value)} - type="password" - className="mt-1 block w-full" - autoComplete="new-password" - placeholder="New password" - /> - - -
- -
- - - setData('password_confirmation', e.target.value)} - type="password" - className="mt-1 block w-full" - autoComplete="new-password" - placeholder="Confirm password" - /> - - -
- -
- - - -

Saved

-
-
- +
{ + if (errors.password) { + passwordInput.current?.focus(); + } + + if (errors.current_password) { + currentPasswordInput.current?.focus(); + } + }} + className="space-y-6" + > + {({ errors, processing, recentlySuccessful }) => ( + <> +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +

Saved

+
+
+ + )} +