diff --git a/src/app/user-management/third-party-registration/third-party-registration.component.html b/src/app/user-management/third-party-registration/third-party-registration.component.html index 9737b09..804e35a 100644 --- a/src/app/user-management/third-party-registration/third-party-registration.component.html +++ b/src/app/user-management/third-party-registration/third-party-registration.component.html @@ -22,7 +22,7 @@ {{'thirdPartyRegistration' | translate}}
-
+
@@ -30,14 +30,17 @@ {{ 'ThirdPartyID' | translate }}* -
+
- + + +
+ {{ 'fieldRequired' | translate }} +
@@ -51,7 +54,12 @@
+ +
+ {{ 'fieldRequired' | translate }} +
@@ -67,11 +75,18 @@
- + + +
+ {{ 'fieldRequired' | translate }} +
+
+ {{"invalidEmail" | translate}} +
@@ -85,8 +100,14 @@
+ +
+ {{ 'fieldRequired' | translate }} +
+ @@ -101,12 +122,19 @@
- -
+ + +
+ {{ 'fieldRequired' | translate }} +
+
+ {{"regPhoneNo"|translate}} +
+
@@ -119,7 +147,12 @@
+ +
+ {{ 'fieldRequired' | translate }} +
@@ -133,17 +166,20 @@ {{ 'password' | translate }}* -
- - - +
+ + + +
+ {{ 'fieldRequired' | translate }} +
+
+ {{ 'passwordTooShort' | translate }} +
+
@@ -152,18 +188,10 @@
- - +
diff --git a/src/app/user-management/third-party-registration/third-party-registration.component.ts b/src/app/user-management/third-party-registration/third-party-registration.component.ts index 75cf93b..6e1ed9c 100644 --- a/src/app/user-management/third-party-registration/third-party-registration.component.ts +++ b/src/app/user-management/third-party-registration/third-party-registration.component.ts @@ -1,28 +1,70 @@ import { CommonModule } from '@angular/common'; -import { Component, ViewChild } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; import { TranslateModule } from '@ngx-translate/core'; import { NgSelectModule } from '@ng-select/ng-select'; import { PasswordHideShowComponent } from '../../shared/components/password-hide-show/password-hide-show.component'; import { pageSizeOptions } from '../../utils/app.constants'; +import { URIKey } from '../../utils/uri-enums'; +import { HttpURIService } from '../../app.http.uri.service'; @Component({ selector: 'app-third-party-registration', - imports: [TranslateModule, CommonModule, FormsModule, PasswordHideShowComponent, NgSelectModule ], + imports: [TranslateModule, CommonModule, FormsModule, ReactiveFormsModule, PasswordHideShowComponent, NgSelectModule ], templateUrl: './third-party-registration.component.html', styleUrl: './third-party-registration.component.scss' }) -export class ThirdPartyRegistrationComponent { +export class ThirdPartyRegistrationComponent implements OnInit { + thirdPartyRegForm! : FormGroup; searchText: string = ''; passwordType: string = 'password'; renewalDataExpanded = true; pageSizeOptions = pageSizeOptions; itemsPerPage: number = 5; - + constructor(private fb: FormBuilder, private httpURIService: HttpURIService){} @ViewChild(PasswordHideShowComponent) passwordHideShow?: PasswordHideShowComponent; togglePasswordType() { this.passwordType = this.passwordHideShow?.showPassword ? 'password' : 'text'; } + + ngOnInit(): void{ + this.thirdPartyRegForm = this.fb.group({ + thirdPartyId: ['', [Validators.required]], + thirdPartyName: ['',[Validators.required]], + email: ['',[Validators.required, Validators.email]], + address: ['',[Validators.required]], + phoneNumber: ['',[Validators.required, Validators.pattern('^[0-9]{10}$') ], ], + newNumberOfAccounts: ['',[Validators.required]], + password: ['',[Validators.required, Validators.minLength(6)]], + }); + } + + get passwordError(){ + const control = this.thirdPartyRegForm.get('password'); + if (!control || !control.touched) return null; + + if (control.hasError('minlength')) return 'passwordTooShort'; + return null; + } + + onSubmit(){ + + if(this.thirdPartyRegForm.invalid){return} + + const payload = { + thirdPartyId: this.thirdPartyRegForm.value.thirdPartyId, + thirdPartyName: this.thirdPartyRegForm.value.thirdPartyName, + email: this.thirdPartyRegForm.value.email, + address: this.thirdPartyRegForm.value.address, + phoneNumber: this.thirdPartyRegForm.value.phoneNumber, + newNumberOfAccounts: this.thirdPartyRegForm.value.newNumberOfAccounts, + password: this.thirdPartyRegForm.value.password + }; + + + this.httpURIService.requestPOST(URIKey.THIRD_PARTY_REGISTER_URI, payload) + .subscribe(); + } } diff --git a/src/app/utils/uri-enums.ts b/src/app/utils/uri-enums.ts index 2d1957c..c72670d 100644 --- a/src/app/utils/uri-enums.ts +++ b/src/app/utils/uri-enums.ts @@ -10,5 +10,6 @@ export enum URIKey { USER_GET_PERMISSIONS = "USER_GET_PERMISSIONS", GET_ALL_USER_URI = "GET_ALL_USER_URI", RESET_PASSWORD_URI = "RESET_PASSWORD_URI", - CHANGE_PASSWORD_URI = "CHANGE_PASSWORD_URI" + CHANGE_PASSWORD_URI = "CHANGE_PASSWORD_URI", + THIRD_PARTY_REGISTER_URI = "THIRD_PARTY_REGISTER_URI" } \ No newline at end of file diff --git a/src/assets/data/app.uri.json b/src/assets/data/app.uri.json index a695eaa..17fbb50 100644 --- a/src/assets/data/app.uri.json +++ b/src/assets/data/app.uri.json @@ -49,7 +49,7 @@ }, { "Id" : "ENTITY_RESET_PASSWORD_URI", - "URI": "/user/reset-password", + "URI": "/user/resetPassword", "UUID": "RESET_PASSWORD_URI" }, { @@ -61,6 +61,11 @@ "Id" : "ENTITY_USER_SAVE_PERMISSION", "URI": "/user/updatePermissions", "UUID": "USER_SAVE_PERMISSION" + }, + { + "Id" : "ENTITY_THIRD_PARTY_REGISTER_URI", + "URI": "/user/thirdPartyRegisteration", + "UUID": "THIRD_PARTY_REGISTER_URI" } ] } diff --git a/src/assets/i18n/Arabic.json b/src/assets/i18n/Arabic.json index 6f7febd..a645000 100644 --- a/src/assets/i18n/Arabic.json +++ b/src/assets/i18n/Arabic.json @@ -84,9 +84,11 @@ "name":"اسم", "EnterThirdPartyName":"أدخل اسم الطرف الثالث", "Email":"البريد الإلكتروني", + "invalidEmail": "أدخل بريدًا إلكترونيًا صالحًا يحتوي على @", "Address":"تبوك", "phoneNumber":"رقم الهاتف", "PhoneNumberPlaceHolder":"أدخل رقم الهاتف", + "regPhoneNo": "يجب أن يتكون رقم الهاتف من 10 أرقام", "NewNoOfAccounts":"عدد جديد من الحسابات", "EnterNewNumberOfAccounts":"أدخل عددًا جديدًا من الحسابات", "TotalNoOfAccounts":"العدد الإجمالي للحسابات", diff --git a/src/assets/i18n/English.json b/src/assets/i18n/English.json index 68559eb..9fbc5fd 100644 --- a/src/assets/i18n/English.json +++ b/src/assets/i18n/English.json @@ -87,6 +87,7 @@ "Address":"Address", "phoneNumber":"Phone Number", "PhoneNumberPlaceHolder":"Enter Phone Number", + "regPhoneNo": "Phone number must be 10 digits", "NewNoOfAccounts":"New No of Accounts", "EnterNewNumberOfAccounts":"Enter New Number of Accounts", "TotalNoOfAccounts":"Total No of Accounts", @@ -176,6 +177,7 @@ "emailLabel": "Email", "emailRequiredError": "Email is required.", "invalidEmailFormatError": "Invalid email format.", + "invalidEmail": "Enter a valid email with @", "passNotMatch": "Password does not match", "POR_ORGACODE": "Organization ID", "purposeSetup": "Configure Transaction Purpose",