Skip to content

Commit ab5140c

Browse files
committed
Simplify Inertia Form
1 parent e2972bb commit ab5140c

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

package-lock.json

Lines changed: 26 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@headlessui/react": "^2.2.0",
28-
"@inertiajs/react": "^2.1.0",
28+
"@inertiajs/react": "^2.1.4",
2929
"@radix-ui/react-avatar": "^1.1.3",
3030
"@radix-ui/react-checkbox": "^1.1.4",
3131
"@radix-ui/react-collapsible": "^1.1.3",

resources/js/components/two-factor-setup-modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,14 @@ export default function TwoFactorSetupModal({
174174
</div>
175175
</>
176176
) : (
177-
<Form {...confirm.form()} onSuccess={() => onClose()} resetOnError transform={(data) => ({ ...data, code })}>
177+
<Form {...confirm.form()} onSuccess={() => onClose()} resetOnError resetOnSuccess>
178178
{({ processing, errors }: { processing: boolean; errors?: { confirmTwoFactorAuthentication?: { code?: string } } }) => (
179179
<>
180180
<div ref={pinInputContainerRef} className="relative w-full space-y-3">
181181
<div className="flex w-full flex-col items-center justify-center space-y-3 py-2">
182182
<InputOTP
183183
id="otp"
184+
name="code"
184185
maxLength={OTP_MAX_LENGTH}
185186
onChange={(value) => setCode(value)}
186187
disabled={processing}

resources/js/pages/auth/two-factor-challenge.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ export default function TwoFactorChallenge() {
4242

4343
<div className="space-y-6">
4444
{!showRecoveryInput ? (
45-
<Form {...store.form()} className="space-y-4" resetOnError transform={(data) => ({ ...data, code })}>
45+
<Form {...store.form()} className="space-y-4" resetOnError resetOnSuccess>
4646
{({ errors, processing, clearErrors }) => (
4747
<>
4848
<div className="flex flex-col items-center justify-center space-y-3 text-center">
4949
<div className="flex w-full items-center justify-center">
5050
<InputOTP
51+
name="code"
5152
maxLength={OTP_MAX_LENGTH}
5253
value={code}
5354
onChange={(value) => setCode(value)}

0 commit comments

Comments
 (0)