From 139f5e738448cb8adef95d7cace9eeb95d6d4c61 Mon Sep 17 00:00:00 2001 From: Mazdak Gibran <141390141+mazdakgibran@users.noreply.github.com> Date: Thu, 9 Apr 2026 12:06:33 +0500 Subject: [PATCH 1/3] third party form --- src/app/menu/menu.component.html | 338 +++++++++++++++--- src/app/menu/menu.component.ts | 74 +++- .../reset-password.component.html | 2 +- .../setup-user/setup-user.component.html | 6 +- src/app/utils/uri-enums.ts | 3 +- src/assets/data/app.uri.json | 5 + src/assets/i18n/Arabic.json | 12 +- src/assets/i18n/English.json | 16 +- 8 files changed, 390 insertions(+), 66 deletions(-) diff --git a/src/app/menu/menu.component.html b/src/app/menu/menu.component.html index 782a6a4..145bab1 100644 --- a/src/app/menu/menu.component.html +++ b/src/app/menu/menu.component.html @@ -1,67 +1,295 @@ -
+
+
- -
-
-
- -
- - - -
- {{ item.userName }} - {{ item.userId }} -
-
- - - {{ item.userName }} ({{ item.userId }}) - -
-
-
-
+
+
+
+
+ +
+
-
+ +
-

{{ "menu" | translate }}

- -
- - - - - - - - - - - +
+
+
+
+
+
+ {{ "userPermission" | translate }} +
+
+ + +
+
+
+ +
+ + +
+ {{ item.userName }} + {{ item.userId }} +
+
+ + {{ item.userName }} ({{ item.userId }}) + +
+
+ +
+
+ + +
+
+

{{ "menu" | translate }}

+
+
#{{ "type" | translate }}{{ "allow" | translate }}
+ + + + + + + + - - - + + + - - -
#{{ "type" | translate }}{{ "allow" | translate }}
{{ i + 1 }}{{ item.endpoint | translate }}{{ i + 1 }}{{ item.endpoint | translate }} + +
+ + +
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ {{ "createThirdPartyUser" | translate }} +
+
-
- +
+ +
+ +
+
+ +
+ +
+
+ {{ "fieldRequired" | translate }} +
+
+
+
+
+ + +
+
+ +
+ +
+
+ {{ "fieldRequired" | translate }} +
+
+
+
+
+
+ +
+ +
+
+ +
+ +
+
+ {{ "fieldRequired" | translate }} +
+
+
+
+
+ + +
+
+ +
+
+ +
+
+
+ {{ "fieldRequired" | translate }} +
+
+ {{ "passwordPattern" | translate }} +
+
+
+
+
+
+ +
+ +
+
+ +
+ +
+
+ {{ "fieldRequired" | translate }} +
+
+ {{ "invalidEmail" | translate }} +
+
+
+
+
+ + +
+
+ +
+ +
+
+ {{ "fieldRequired" | translate }} +
+
+
+
+
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ +
+ +
+ +
+
+
+
+
+
+
- \ No newline at end of file + + + + + \ No newline at end of file diff --git a/src/app/menu/menu.component.ts b/src/app/menu/menu.component.ts index 8de6097..bb0067f 100644 --- a/src/app/menu/menu.component.ts +++ b/src/app/menu/menu.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; import { PermissionNode } from '../utils/app.interfaces'; import { CredentialService } from '../services/credential.service'; import { I18NService } from '../services/i18n.service'; @@ -15,12 +15,13 @@ import { URIService } from '../app.uri'; @Component({ selector: 'app-menu', - imports: [TranslateModule, ReactiveFormsModule, CommonModule, TranslateModule, NgSelectModule, FormsModule], + imports: [TranslateModule, ReactiveFormsModule, ReactiveFormsModule, CommonModule, TranslateModule, NgSelectModule, FormsModule], templateUrl: './menu.component.html', styleUrl: './menu.component.scss' }) export class MenuComponent { users: any[] = []; + thirdPartyForm!: FormGroup; permission: FormGroup; showPermissions = false; permissions: PermissionNode[] = []; @@ -38,13 +39,78 @@ export class MenuComponent { this.defaultPermissions().subscribe((data: PermissionNode[]) => { this.permissions = data; }); + + } ngOnInit() { this.getAllUsers(); this.loadTransactionEndpoints(); + this.createThirdPartyUserForm(); + } + + createThirdPartyUserForm(): void{ + this.thirdPartyForm = this.fb.group({ + SUS_USERCODE: ["", [Validators.required]], + SUS_EMPCODE: ["", [Validators.required]], + SUS_NAME: ["", [Validators.required]], + SUS_PASSWORD: ['', [ + Validators.required, + Validators.minLength(8), + Validators.maxLength(20), + Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]+$/) + ]], + SUS_EMAIL: ["", [Validators.required, Validators.email]], + SUS_USERCELLNO: ["", [Validators.required]], + POR_ORGACODE: [this.credentialService.getPorOrgacode()], + SUS_ACTIVE: [true], + SUS_THIRDPARTY: [true], + + }) + } + + submitForm() { + if (this.thirdPartyForm.invalid) { + this.thirdPartyForm.markAllAsTouched(); + return; } + const f = this.thirdPartyForm.value; + const payload = { + formId: "SH_SM_US_USER", + postProcessFormId: "SH_SM_US_USER", + workFlowId: null, + operation: "nonwizard", + porOrgacode: this.credentialService.getPorOrgacode(), + usercode: this.credentialService.getUserId(), + uniqueConstraints: [["SUS_USERCODE", "POR_ORGACODE"]], + formCounters: [], + susUsercode: f.SUS_USERCODE, + susName: f.SUS_NAME, + susEmpcode: f.SUS_EMPCODE, + susPassword: f.SUS_PASSWORD, + susEmail: f.SUS_EMAIL, + susUsercellno: f.SUS_USERCELLNO, + susActive: f.SUS_ACTIVE, + susThirdparty: f.SUS_THIRDPARTY, + } + + console.log("payload",payload ) + this.httpService.requestPOST(URIKey.CREATE_THIRD_PARTY_USER, payload) + .subscribe({ + next: (response: any) => { + if (!(response instanceof HttpErrorResponse)) { + this.i18nService.success(SuccessMessages.SAVED_SUCCESSFULLY, []); + this.createThirdPartyUserForm(); + } + } + + // 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 } + }); +} + loadTransactionEndpoints() { this.httpService.requestGET(URIKey.TRANSACTION_ENDPOINTS).subscribe((response) => { if (!(response instanceof HttpErrorResponse)) { @@ -127,7 +193,9 @@ savePermissions() { next: (response: any) => { if (!(response instanceof HttpErrorResponse)) { this.i18nService.success(SuccessMessages.SAVED_SUCCESSFULLY, []); - this.onUserChange(); // this triggers one GET — expected + this.permission.reset(); + this.showPermissions = false; + this.menuItems.forEach(item => item.checked = false); } }, complete: () => { diff --git a/src/app/user-management/reset-password/reset-password.component.html b/src/app/user-management/reset-password/reset-password.component.html index 4b40e83..0f07890 100644 --- a/src/app/user-management/reset-password/reset-password.component.html +++ b/src/app/user-management/reset-password/reset-password.component.html @@ -73,7 +73,7 @@
-
+