Skip to content

Commit 5459368

Browse files
committed
refactor: use Partial type for form data in authentication and profile components
1 parent e329ad2 commit 5459368

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

resources/js/components/delete-user.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, Di
1313

1414
export default function DeleteUser() {
1515
const passwordInput = useRef<HTMLInputElement>(null);
16-
const { data, setData, delete: destroy, processing, reset, errors, clearErrors } = useForm({ password: '' });
16+
const { data, setData, delete: destroy, processing, reset, errors, clearErrors } = useForm<Partial<{ password: string }>>({ password: '' });
1717

1818
const deleteUser: FormEventHandler = (e) => {
1919
e.preventDefault();

resources/js/pages/auth/confirm-password.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Label } from '@/components/ui/label';
1010
import AuthLayout from '@/layouts/auth-layout';
1111

1212
export default function ConfirmPassword() {
13-
const { data, setData, post, processing, errors, reset } = useForm({
13+
const { data, setData, post, processing, errors, reset } = useForm<Partial<{ password: string }>>({
1414
password: '',
1515
});
1616

resources/js/pages/auth/forgot-password.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Label } from '@/components/ui/label';
1111
import AuthLayout from '@/layouts/auth-layout';
1212

1313
export default function ForgotPassword({ status }: { status?: string }) {
14-
const { data, setData, post, processing, errors } = useForm({
14+
const { data, setData, post, processing, errors } = useForm<Partial<{ email: string }>>({
1515
email: '',
1616
});
1717

resources/js/pages/auth/login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface LoginProps {
2222
}
2323

2424
export default function Login({ status, canResetPassword }: LoginProps) {
25-
const { data, setData, post, processing, errors, reset } = useForm<LoginForm>({
25+
const { data, setData, post, processing, errors, reset } = useForm<Partial<LoginForm>>({
2626
email: '',
2727
password: '',
2828
remember: false,

resources/js/pages/auth/register.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface RegisterForm {
1717
}
1818

1919
export default function Register() {
20-
const { data, setData, post, processing, errors, reset } = useForm<RegisterForm>({
20+
const { data, setData, post, processing, errors, reset } = useForm<Partial<RegisterForm>>({
2121
name: '',
2222
email: '',
2323
password: '',

resources/js/pages/auth/reset-password.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface ResetPasswordForm {
2121
}
2222

2323
export default function ResetPassword({ token, email }: ResetPasswordProps) {
24-
const { data, setData, post, processing, errors, reset } = useForm<ResetPasswordForm>({
24+
const { data, setData, post, processing, errors, reset } = useForm<Partial<ResetPasswordForm>>({
2525
token: token,
2626
email: email,
2727
password: '',

resources/js/pages/settings/profile.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ const breadcrumbs: BreadcrumbItem[] = [
1919
},
2020
];
2121

22+
interface ProfileForm {
23+
name: string;
24+
email: string;
25+
}
26+
2227
export default function Profile({ mustVerifyEmail, status }: { mustVerifyEmail: boolean; status?: string }) {
2328
const { auth } = usePage<SharedData>().props;
2429

25-
const { data, setData, patch, errors, processing, recentlySuccessful } = useForm({
30+
const { data, setData, patch, errors, processing, recentlySuccessful } = useForm<Partial<ProfileForm>>({
2631
name: auth.user.name,
2732
email: auth.user.email,
2833
});

0 commit comments

Comments
 (0)