Skip to content

Commit bde2297

Browse files
Add mask for phone number when registering (#191)
* feat: Add mask for phone number when registering * feat: Implement user sign-up component with form validation and API integration. * feat: add user configuration page UI template
1 parent 807e646 commit bde2297

4 files changed

Lines changed: 30 additions & 42 deletions

File tree

timeless-api/src/main/webui/package-lock.json

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

timeless-api/src/main/webui/src/app/pages/sign/sign-up/sign-up.component.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ <h1 class="text-xl font-thin my-2 text-center">
4444
<label for="email">Seu melhor e-mail</label>
4545
</p-float-label>
4646
<p-float-label variant="in">
47-
<input
47+
<p-inputMask
4848
id="phone_number"
49-
class="w-full text-center font-medium"
50-
type="text"
51-
pSize="small"
52-
pInputText
49+
styleClass="w-full text-center font-medium"
50+
mask="(99) 99999-9999"
5351
formControlName="phoneNumber"
54-
autocomplete="false"
52+
autocomplete="off"
5553
/>
5654
<label for="phone_number">Seu número de telefone</label>
5755
</p-float-label>

timeless-api/src/main/webui/src/app/pages/sign/sign-up/sign-up.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { FloatLabel } from 'primeng/floatlabel';
1313
import { TimelessApiService } from '../../../timeless-api.service';
1414
import { catchError } from 'rxjs';
1515
import { ToastService } from '../../../services/toast.service';
16+
import { InputMask } from 'primeng/inputmask';
1617

1718
@Component({
1819
selector: 'app-sign-up',
@@ -23,13 +24,13 @@ import { ToastService } from '../../../services/toast.service';
2324
RouterLink,
2425
ReactiveFormsModule,
2526
FloatLabel,
27+
InputMask,
2628
],
2729
templateUrl: './sign-up.component.html',
2830
styleUrl: './sign-up.component.scss',
2931
})
3032
export class SignUpComponent {
3133
formBuilder = inject(FormBuilder);
32-
regex = /^\+?\d{1,3}?[\s-]?\(?\d{1,4}\)?([\s-]?\d{2,4}){1,3}$/;
3334
form: FormGroup = this.formBuilder.group({
3435
email: ['', [Validators.email, Validators.required]],
3536
password: [
@@ -38,7 +39,7 @@ export class SignUpComponent {
3839
],
3940
firstName: ['', [Validators.required, Validators.minLength(1)]],
4041
lastName: ['', [Validators.required, Validators.minLength(1)]],
41-
phoneNumber: ['', [Validators.required, Validators.pattern(this.regex)]],
42+
phoneNumber: ['', [Validators.required]],
4243
});
4344

4445
constructor(

0 commit comments

Comments
 (0)