diff --git a/src/app/menu/menu.component.ts b/src/app/menu/menu.component.ts
index bb0067f..a6fc206 100644
--- a/src/app/menu/menu.component.ts
+++ b/src/app/menu/menu.component.ts
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { PermissionNode } from '../utils/app.interfaces';
import { CredentialService } from '../services/credential.service';
@@ -10,12 +10,14 @@ import { HttpErrorResponse, HttpParams } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { NgSelectModule } from '@ng-select/ng-select';
import { filter, Observable, take } from 'rxjs';
-import { SuccessMessages } from '../utils/enums';
+import { ErrorMessages, SuccessMessages } from '../utils/enums';
import { URIService } from '../app.uri';
+import { PasswordHideShowComponent } from '../shared/components/password-hide-show/password-hide-show.component';
+import { error } from 'console';
@Component({
selector: 'app-menu',
- imports: [TranslateModule, ReactiveFormsModule, ReactiveFormsModule, CommonModule, TranslateModule, NgSelectModule, FormsModule],
+ imports: [TranslateModule, ReactiveFormsModule, ReactiveFormsModule, CommonModule, TranslateModule, NgSelectModule, FormsModule, PasswordHideShowComponent],
templateUrl: './menu.component.html',
styleUrl: './menu.component.scss'
})
@@ -26,8 +28,10 @@ export class MenuComponent {
showPermissions = false;
permissions: PermissionNode[] = [];
saving = false;
+ passwordType: string = 'password';
menuItems: { endpoint: string; checked: boolean }[] = [];
-
+ @ViewChild('passShowMenu') passwordHideShow?: PasswordHideShowComponent;
+
constructor(
private credentialService: CredentialService,
private fb: FormBuilder,
@@ -48,6 +52,9 @@ export class MenuComponent {
this.loadTransactionEndpoints();
this.createThirdPartyUserForm();
}
+ toggleSetupPass() {
+ this.passwordType = this.passwordHideShow?.showPassword ? 'password' : 'text';
+ }
createThirdPartyUserForm(): void{
this.thirdPartyForm = this.fb.group({
@@ -61,14 +68,22 @@ export class MenuComponent {
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]+$/)
]],
SUS_EMAIL: ["", [Validators.required, Validators.email]],
- SUS_USERCELLNO: ["", [Validators.required]],
+ SUS_USERCELLNO: ["", [
+ Validators.required,
+ Validators.pattern(/^[0-9]+$/)
+ ]],
POR_ORGACODE: [this.credentialService.getPorOrgacode()],
SUS_ACTIVE: [true],
SUS_THIRDPARTY: [true],
})
}
-
+ onlyNumbers(event: KeyboardEvent) {
+ const charCode = event.which ? event.which : event.keyCode;
+ if (charCode < 48 || charCode > 57) {
+ event.preventDefault();
+ }
+}
submitForm() {
if (this.thirdPartyForm.invalid) {
this.thirdPartyForm.markAllAsTouched();
@@ -102,12 +117,28 @@ export class MenuComponent {
if (!(response instanceof HttpErrorResponse)) {
this.i18nService.success(SuccessMessages.SAVED_SUCCESSFULLY, []);
this.createThirdPartyUserForm();
+ this.getAllUsers();
+ this.permission.reset();
+ this.showPermissions = false;
}
- }
+ },
- // handle error codes e.g. ERR_TRX_0006
- // Once backend is ready, check response for errorCode field
- // e.g. if (response?.errorCode === 'ERR_TRX_0006') { show error }
+ error: (error: any) => {
+ const errorCode = error?.error?.errorCode || error?.errorCode;
+
+ switch (errorCode) {
+ case 'ERR_SEC_0002':
+ this.i18nService.error(ErrorMessages.USERNAME_ALREADY_EXISTS, []);
+ break;
+
+ case 'ERR_SEC_0001':
+ this.i18nService.error(ErrorMessages.EMAIL_ALREADY_EXISTS, []);
+ break;
+
+ default:
+ this.i18nService.error('Unexpected error', []);
+ }
+ }
});
}
diff --git a/src/app/utils/enums.ts b/src/app/utils/enums.ts
index 7f91996..12f36d4 100644
--- a/src/app/utils/enums.ts
+++ b/src/app/utils/enums.ts
@@ -12,6 +12,8 @@ export enum ErrorMessages{
USER_FETCH_FAILED = "USER_FETCH_FAILED",
RESET_PASSWORD_FAILED = "RESET_PASSWORD_FAILED",
CHANGE_PASSWORD_FAILED = "ERR_SEC_0007",
+ EMAIL_ALREADY_EXISTS = "ERR_SEC_0001",
+ USERNAME_ALREADY_EXISTS = "ERR_SEC_0002"
}
diff --git a/src/assets/i18n/English.json b/src/assets/i18n/English.json
index 726ede2..f516c8d 100644
--- a/src/assets/i18n/English.json
+++ b/src/assets/i18n/English.json
@@ -254,7 +254,7 @@
"noThirdPartyRegFound": "No Third Party Registration Details Found",
"ERR_SEC_0001": "Email already exists",
"ERR_SEC_0007": "New password cannot be same as old password",
- "ERR_SEC_0002": "User ID already exists",
+ "ERR_SEC_0002": "Username already exists",
"ERR_SEC_0003": "Old Password is not correct",
"ERR_SEC_0004": "Invalid credentials",
"ERR_SEC_0005": "User not found",
From e013e1374ecdfa53c3738335ebe35160b07c29b2 Mon Sep 17 00:00:00 2001
From: Mazdak Gibran <141390141+mazdakgibran@users.noreply.github.com>
Date: Thu, 9 Apr 2026 15:38:22 +0500
Subject: [PATCH 3/3] cell limit
---
src/app/menu/menu.component.html | 1 +
src/app/menu/menu.component.ts | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/menu/menu.component.html b/src/app/menu/menu.component.html
index b154bb5..3a17e7d 100644
--- a/src/app/menu/menu.component.html
+++ b/src/app/menu/menu.component.html
@@ -237,6 +237,7 @@
formControlName="SUS_USERCELLNO"
placeholder="{{ 'SUS_USERCELLNO' | translate }}"
(keypress)="onlyNumbers($event)"
+ maxlength="10"
appNoWhitespaces />
diff --git a/src/app/menu/menu.component.ts b/src/app/menu/menu.component.ts
index a6fc206..03a0e01 100644
--- a/src/app/menu/menu.component.ts
+++ b/src/app/menu/menu.component.ts
@@ -70,7 +70,6 @@ export class MenuComponent {
SUS_EMAIL: ["", [Validators.required, Validators.email]],
SUS_USERCELLNO: ["", [
Validators.required,
- Validators.pattern(/^[0-9]+$/)
]],
POR_ORGACODE: [this.credentialService.getPorOrgacode()],
SUS_ACTIVE: [true],