22import AlertError from ' @/components/AlertError.vue' ;
33import InputError from ' @/components/InputError.vue' ;
44import { Button } from ' @/components/ui/button' ;
5- import { Spinner } from ' @/components/ui/spinner' ;
65import {
76 Dialog ,
87 DialogContent ,
@@ -11,10 +10,11 @@ import {
1110 DialogTitle ,
1211} from ' @/components/ui/dialog' ;
1312import {
14- PinInput ,
15- PinInputGroup ,
16- PinInputSlot ,
17- } from ' @/components/ui/pin-input' ;
13+ InputOTP ,
14+ InputOTPGroup ,
15+ InputOTPSlot ,
16+ } from ' @/components/ui/input-otp' ;
17+ import { Spinner } from ' @/components/ui/spinner' ;
1818import { useTwoFactorAuth } from ' @/composables/useTwoFactorAuth' ;
1919import { confirm } from ' @/routes/two-factor' ;
2020import { Form } from ' @inertiajs/vue3' ;
@@ -35,8 +35,7 @@ const { qrCodeSvg, manualSetupKey, clearSetupData, fetchSetupData, errors } =
3535 useTwoFactorAuth ();
3636
3737const showVerificationStep = ref (false );
38- const code = ref <number []>([]);
39- const codeValue = computed <string >(() => code .value .join (' ' ));
38+ const code = ref <string >(' ' );
4039
4140const pinInputContainerRef = useTemplateRef (' pinInputContainerRef' );
4241
@@ -91,7 +90,7 @@ const resetModalState = () => {
9190 }
9291
9392 showVerificationStep .value = false ;
94- code .value = [] ;
93+ code .value = ' ' ;
9594};
9695
9796watch (
@@ -234,35 +233,32 @@ watch(
234233 <Form
235234 v-bind =" confirm.form()"
236235 reset-on-error
237- @finish =" code = [] "
236+ @finish =" code = '' "
238237 @success =" isOpen = false"
239238 v-slot =" { errors, processing }"
240239 >
241- <input type =" hidden" name =" code" :value =" codeValue " />
240+ <input type =" hidden" name =" code" :value =" code " />
242241 <div
243242 ref =" pinInputContainerRef"
244243 class =" relative w-full space-y-3"
245244 >
246245 <div
247246 class =" flex w-full flex-col items-center justify-center space-y-3 py-2"
248247 >
249- <PinInput
248+ <InputOTP
250249 id =" otp"
251- placeholder =" ○"
252250 v-model =" code"
253- type = " number "
254- otp
251+ :maxlength = " 6 "
252+ :disabled = " processing "
255253 >
256- <PinInputGroup >
257- <PinInputSlot
258- autofocus
259- v-for =" (id, index) in 6"
260- :key =" id"
261- :index =" index"
262- :disabled =" processing"
254+ <InputOTPGroup >
255+ <InputOTPSlot
256+ v-for =" index in 6"
257+ :key =" index"
258+ :index =" index - 1"
263259 />
264- </PinInputGroup >
265- </PinInput >
260+ </InputOTPGroup >
261+ </InputOTP >
266262 <InputError
267263 :message ="
268264 errors?.confirmTwoFactorAuthentication
@@ -284,9 +280,7 @@ watch(
284280 <Button
285281 type =" submit"
286282 class =" w-auto flex-1"
287- :disabled ="
288- processing || codeValue.length < 6
289- "
283+ :disabled =" processing || code.length < 6"
290284 >
291285 Confirm
292286 </Button >
0 commit comments