@@ -17,10 +17,8 @@ export interface PINLockModalProps {
1717 onSave : ( pin : string | null ) => void ;
1818}
1919
20- // PIN validation schemas with detailed error messages
21- const pinDigitSchema = z . string ( ) . regex ( / ^ \d { 4 } $ / , {
22- message : "PIN must be exactly 4 digits" ,
23- } ) ;
20+ // PIN validation schema - with empty validation message
21+ const pinDigitSchema = z . string ( ) . regex ( / ^ \d { 4 } $ / , { message : '' } ) ;
2422
2523// Schema for verifying existing PIN
2624const verifyPinSchema = z . object ( {
@@ -97,6 +95,30 @@ const PINLockModal: React.FC<PINLockModalProps> = ({
9795 // Create refs for the submit buttons
9896 const submitBtnRef = useRef < HTMLButtonElement > ( null ) ;
9997
98+ // Get current PIN values for each form to check if they're complete
99+ const currentVerifyPin = verifyForm . watch ( 'pin' ) || '' ;
100+ const isVerifyPinComplete = currentVerifyPin . length === 4 ;
101+
102+ const currentCreatePin = createForm . watch ( 'pin' ) || '' ;
103+ const isCreatePinComplete = currentCreatePin . length === 4 ;
104+
105+ const currentConfirmPin = confirmForm . watch ( 'pin' ) || '' ;
106+ const isConfirmPinComplete = currentConfirmPin . length === 4 ;
107+
108+ // Helper to get whether the submit button should be disabled based on current stage
109+ const isSubmitDisabled = ( ) => {
110+ switch ( stage ) {
111+ case "verify" :
112+ return ! isVerifyPinComplete ;
113+ case "create" :
114+ return ! isCreatePinComplete ;
115+ case "confirm" :
116+ return ! isConfirmPinComplete ;
117+ default :
118+ return true ;
119+ }
120+ } ;
121+
100122 // Helper to get the active input ref based on current stage
101123 const getActiveInputRef = ( ) => {
102124 switch ( stage ) {
@@ -340,15 +362,15 @@ const PINLockModal: React.FC<PINLockModalProps> = ({
340362 isOpen = { isOpen }
341363 onClose = { onClose }
342364 title = {
343- < div className = "flex items-center gap-2" >
365+ < div className = "flex items-center gap-2 select-none " >
344366 < LockIcon size = { 18 } />
345367 < span > PIN Lock</ span >
346368 </ div >
347369 }
348370 maxWidth = "max-w-md"
349371 >
350372 < div className = "p-4 space-y-4 overflow-hidden" onKeyDown = { handleKeyDown } >
351- < div className = "text-center space-y-2" >
373+ < div className = "text-center space-y-2 select-none " >
352374 < h3 className = "text-lg font-semibold" > { title ( ) } </ h3 >
353375 < p className = "text-sm text-muted-foreground" > { description ( ) } </ p >
354376 </ div >
@@ -415,7 +437,7 @@ const PINLockModal: React.FC<PINLockModalProps> = ({
415437 onClick = { handleBackFromConfirm }
416438 className = "w-1/3 mr-2 rounded-full cursor-pointer"
417439 >
418- Back
440+ < span className = "select-none" > Back</ span >
419441 </ Button >
420442 ) }
421443
@@ -424,8 +446,9 @@ const PINLockModal: React.FC<PINLockModalProps> = ({
424446 onClick = { handleSubmit }
425447 className = { `${ stage === "confirm" ? "w-2/3" : "w-full" } rounded-full h-10 font-medium transition-all cursor-pointer` }
426448 ref = { submitBtnRef }
449+ disabled = { isSubmitDisabled ( ) }
427450 >
428- { buttonText ( ) }
451+ < span className = "select-none" > { buttonText ( ) } </ span >
429452 </ Button >
430453 </ div >
431454 </ div >
0 commit comments