Skip to content

Commit 3b3e6b1

Browse files
refactor(email-verification): streamline verification code input and error handling
- Replace individual digit inputs with a single input for the 6-digit verification code to simplify user interaction. - Update error messages for clarity and consistency, particularly for already linked emails. - Enhance the timer functionality and cleanup logic to improve component lifecycle management. Jira Ticket: https://linuxfoundation.atlassian.net/browse/LFXV2-502 Generated with [Cursor](https://cursor.com/) Signed-off-by: Mauricio Zanetti Salomao <msalomao@contractor.linuxfoundation.org>
1 parent e6001d5 commit 3b3e6b1

File tree

3 files changed

+61
-251
lines changed

3 files changed

+61
-251
lines changed

apps/lfx-one/src/app/modules/profile/email/email-verification-modal/email-verification-modal.component.html

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h2 class="text-xl font-semibold text-gray-900 mb-2">Verify Your Email Address</
2626
'text-orange-600': timeRemaining() <= 60 && timeRemaining() > 30,
2727
'text-red-600': timeRemaining() <= 30,
2828
}">
29-
{{ formattedTime }}
29+
{{ formattedTime() }}
3030
</span>
3131
</div>
3232
</div>
@@ -47,26 +47,18 @@ <h2 class="text-xl font-semibold text-gray-900 mb-2">Verify Your Email Address</
4747
<form [formGroup]="verificationForm" (ngSubmit)="submitCode()">
4848
<div class="mb-6">
4949
<label class="block text-sm font-medium text-gray-700 mb-3">Verification Code</label>
50-
<div class="flex gap-3 justify-center mb-3">
51-
@for (digit of [1, 2, 3, 4, 5, 6]; track digit) {
52-
<input
53-
type="text"
54-
[id]="'digit' + digit"
55-
[formControlName]="'digit' + digit"
56-
inputmode="numeric"
57-
pattern="\d"
58-
(input)="onDigitInput($event, digit)"
59-
(keydown)="onDigitKeyDown($event, digit)"
60-
(paste)="onDigitPaste($event)"
61-
class="w-12 h-14 text-center text-2xl font-bold border-2 rounded-lg transition-all duration-200 border-blue-500 focus:border-blue-600 focus:ring-2 focus:ring-blue-200"
62-
[ngClass]="{
63-
'border-red-500': verificationForm.get('digit' + digit)?.invalid && verificationForm.get('digit' + digit)?.touched
64-
}"
65-
[attr.data-testid]="'digit-' + digit + '-input'"
66-
autocomplete="off" />
67-
}
50+
<div class="flex justify-center mb-3">
51+
<p-inputOtp
52+
formControlName="code"
53+
[length]="6"
54+
[integerOnly]="true"
55+
[autofocus]="true"
56+
styleClass="gap-3"
57+
inputClass="w-12 h-14 text-center text-2xl font-bold"
58+
data-testid="otp-input">
59+
</p-inputOtp>
6860
</div>
69-
@if (verificationForm.invalid && (verificationForm.touched || verificationForm.dirty)) {
61+
@if (verificationForm.get('code')?.invalid && (verificationForm.get('code')?.touched || verificationForm.get('code')?.dirty)) {
7062
<div class="text-red-600 text-xs text-center mb-2" data-testid="verification-code-error">
7163
Please enter all 6 digits
7264
</div>

0 commit comments

Comments
 (0)