feat: refactor password input handling across multiple components

- Replaced individual password and confirm password fields with a shared-password-input component in the following components:
  - Partner Account Password Form
  - Consumer Account Form
  - Consumer User Form
  - Consumer Pos Form
  - Super Admin Consumer Account Form
  - Super Admin Partner Account Form
  - Super Admin Provider Form
  - Super Admin User Account Form
  - Modify Login Info Page

- Introduced a new SharedPasswordInputComponent to encapsulate password input logic and validation messages.
- Updated form handling to utilize reactive forms with shared components for better maintainability and consistency.
- Added a ChangePasswordFormDialogComponent for changing passwords with validation.
- Created API routes for business activity goods in the consumer module.
This commit is contained in:
2026-04-26 20:26:30 +03:30
parent baa9409e9e
commit c085104976
54 changed files with 293 additions and 601 deletions
@@ -7,34 +7,10 @@
(onHide)="close()"
>
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
<uikit-field label="رمز عبور" class="" [control]="form.controls.password">
<p-password
id="password1"
name="password"
formControlName="password"
autocomplete="password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.password.touched && form.controls.password.invalid"
/>
<span class="text-xs mt-1 text-muted-color">
رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.
</span>
</uikit-field>
<uikit-field label="تکرار رمز عبور" class="" [control]="form.controls.confirmPassword">
<p-password
id="confirmPassword"
name="confirmPassword"
formControlName="confirmPassword"
autocomplete="new-password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
/>
</uikit-field>
<shared-password-input
[passwordControl]="form.controls.password"
[confirmPasswordControl]="form.controls.confirmPassword"
/>
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
</form>
@@ -1,18 +1,17 @@
import { MustMatch, password } from '@/core/validators';
import { AbstractFormDialog } from '@/shared/abstractClasses';
import { SharedPasswordInputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { UikitFieldComponent } from '@/uikit';
import { Component, inject, Input } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { Password } from 'primeng/password';
import { IAccountRequest, IAccountResponse } from '../models';
import { AccountsService } from '../services/main.service';
@Component({
selector: 'account-password-form',
templateUrl: './form.component.html',
imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, UikitFieldComponent, Password],
imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, SharedPasswordInputComponent],
})
export class PartnerAccountPasswordFormComponent extends AbstractFormDialog<
IAccountRequest,
@@ -9,34 +9,10 @@
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
<app-input label="نام کاربری" [control]="form.controls.username" name="username" />
<app-enum-select [control]="form.controls.role" name="role" type="consumerRole" />
<uikit-field label="رمز عبور" class="" [control]="form.controls.password">
<p-password
id="password1"
name="password"
formControlName="password"
autocomplete="password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.password.touched && form.controls.password.invalid"
/>
<span class="text-xs mt-2 text-muted-color">
رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.
</span>
</uikit-field>
<uikit-field label="تکرار رمز عبور" class="" [control]="form.controls.confirmPassword">
<p-password
id="confirmPassword"
name="confirmPassword"
formControlName="confirmPassword"
autocomplete="new-password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
/>
</uikit-field>
<shared-password-input
[passwordControl]="form.controls.password"
[confirmPasswordControl]="form.controls.confirmPassword"
/>
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
</form>
</p-dialog>
@@ -2,13 +2,11 @@ import { MustMatch, password } from '@/core/validators';
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
import { AbstractFormDialog } from '@/shared/abstractClasses';
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
import { InputComponent } from '@/shared/components';
import { InputComponent, SharedPasswordInputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { UikitFieldComponent } from '@/uikit';
import { Component, inject, Input } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { Password } from 'primeng/password';
import { IConsumerAccountRequest, IConsumerAccountResponse } from '../../models';
import { PartnerConsumerAccountsService } from '../../services/accounts.service';
@@ -20,8 +18,7 @@ import { PartnerConsumerAccountsService } from '../../services/accounts.service'
Dialog,
InputComponent,
FormFooterActionsComponent,
UikitFieldComponent,
Password,
SharedPasswordInputComponent,
EnumSelectComponent,
],
})
@@ -16,34 +16,10 @@
<p-divider align="center"> اطلاعات ورود </p-divider>
<!-- @ts-ignore -->
<app-input label="نام کاربری" [control]="form.controls.username" name="username" [isLtrInput]="true" />
<uikit-field label="رمز عبور" class="" [control]="form.controls.password">
<p-password
id="password1"
name="password"
formControlName="password"
autocomplete="password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.password.touched && form.controls.password.invalid"
/>
<span class="text-xs mt-1 text-muted-color">
رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.
</span>
</uikit-field>
<uikit-field label="تکرار رمز عبور" class="" [control]="form.controls.confirmPassword">
<p-password
id="confirmPassword"
name="confirmPassword"
formControlName="confirmPassword"
autocomplete="new-password"
[toggleMask]="true"
[fluid]="true"
[feedback]="false"
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
/>
</uikit-field>
<shared-password-input
[passwordControl]="form.controls.password"
[confirmPasswordControl]="form.controls.confirmPassword"
/>
<p-divider align="center"> اطلاعات لایسنس </p-divider>
<uikit-datepicker
label="تاریخ شروع لایسنس"
@@ -1,15 +1,14 @@
import { mobileValidator, MustMatch } from '@/core/validators';
import { nationalIdValidator } from '@/core/validators/national-id.validator';
import { AbstractFormDialog } from '@/shared/abstractClasses';
import { InputComponent } from '@/shared/components';
import { InputComponent, SharedPasswordInputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { UikitFieldComponent, UikitFlatpickrJalaliComponent } from '@/uikit';
import { UikitFlatpickrJalaliComponent } from '@/uikit';
import { nowJalali } from '@/utils';
import { Component, computed, inject, Input } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { Divider } from 'primeng/divider';
import { Password } from 'primeng/password';
import { IConsumerRequest, IConsumerResponse } from '../models';
import { ConsumersService } from '../services/main.service';
@@ -22,9 +21,8 @@ import { ConsumersService } from '../services/main.service';
InputComponent,
FormFooterActionsComponent,
Divider,
UikitFieldComponent,
Password,
UikitFlatpickrJalaliComponent,
SharedPasswordInputComponent,
],
})
export class ConsumerUserFormComponent extends AbstractFormDialog<
@@ -11,31 +11,10 @@
@if (!editMode) {
<p-divider align="center"> اطلاعات ورود </p-divider>
<app-input label="نام کاربری" [control]="form.controls.username" name="username" [isLtrInput]="true" />
<uikit-field label="رمز عبور" [control]="form.controls.password">
<p-password
id="password"
name="password"
formControlName="password"
autocomplete="new-password"
inputStyleClass="w-full"
[toggleMask]="true"
[feedback]="false"
[invalid]="form.controls.password.touched && form.controls.password.invalid"
/>
</uikit-field>
<uikit-field label="تکرار رمز عبور" [control]="form.controls.confirmPassword">
<p-password
id="confirmPassword"
name="confirmPassword"
formControlName="confirmPassword"
autocomplete="new-password"
inputStyleClass="w-full"
[toggleMask]="true"
[feedback]="false"
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
/>
</uikit-field>
<shared-password-input
[passwordControl]="form.controls.password"
[confirmPasswordControl]="form.controls.confirmPassword"
/>
}
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
@@ -4,13 +4,11 @@ import { AbstractForm } from '@/shared/abstractClasses';
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
import { CatalogProviderSelectComponent } from '@/shared/catalog';
import { CatalogDeviceSelectComponent } from '@/shared/catalog/devices';
import { InputComponent } from '@/shared/components';
import { InputComponent, SharedPasswordInputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { UikitFieldComponent } from '@/uikit';
import { Component, inject, Input } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Divider } from 'primeng/divider';
import { Password } from 'primeng/password';
import { IPosRequest, IPosResponse } from '../../models';
import { PartnerPosesService } from '../../services/poses.service';
@@ -24,9 +22,8 @@ import { PartnerPosesService } from '../../services/poses.service';
CatalogDeviceSelectComponent,
CatalogProviderSelectComponent,
EnumSelectComponent,
UikitFieldComponent,
Password,
Divider,
SharedPasswordInputComponent,
],
})
export class ConsumerPosFormContentComponent extends AbstractForm<IPosRequest, IPosResponse> {