Refactor nested column definitions and improve license info handling

- Updated column definitions in various components to use `nestedOption` instead of `nestedPath` for better clarity and consistency.
- Removed commented-out license status checks and related UI elements from the layout component.
- Simplified license info interface by removing unnecessary properties.
- Enhanced consumer accounts and business activities components to display additional license information.
- Adjusted form components to conditionally include fields based on selected device type.
- Improved the handling of discount calculations in the gold payload form component.
- Added new fields for branch code in complex components and adjusted related views.
- Cleaned up unused console logs in form data utility.
This commit is contained in:
2026-04-24 02:23:47 +03:30
parent e58bcbef57
commit d857361cb7
41 changed files with 268 additions and 121 deletions
@@ -20,9 +20,19 @@ export class PartnerAccountsComponent extends AbstractList<IAccountResponse> {
override setColumns(): void {
this.columns = [
{ field: 'id', header: 'شناسه', type: 'id' },
{ field: 'username', header: 'نام کاربری', type: 'nested', nestedPath: 'account.username' },
{
field: 'username',
header: 'نام کاربری',
type: 'nested',
nestedOption: { path: 'account.username' },
},
{ field: 'role', header: 'نقش' },
{ field: 'status', header: 'وضعیت', type: 'nested', nestedPath: 'account.status' },
{
field: 'status',
header: 'وضعیت',
type: 'nested',
nestedOption: { path: 'account.status' },
},
{
field: 'created_at',
header: 'تاریخ ایجاد',
@@ -20,17 +20,17 @@ export class ConsumerAccountListComponent extends AbstractList<IConsumerAccountR
@Input() header: IColumn[] = [
{ field: 'id', header: 'شناسه', type: 'id' },
{
field: 'username',
field: 'account',
header: 'نام کاربری',
type: 'nested',
nestedPath: 'account.username',
nestedOption: { path: 'account.username' },
},
{ field: 'role', header: 'نوع حساب' },
{
field: 'status',
header: 'وضعیت',
type: 'nested',
nestedPath: 'account.status',
nestedOption: { path: 'account.status' },
},
{
field: 'created_at',
@@ -22,7 +22,24 @@ export class ConsumerBusinessActivitiesComponent extends AbstractList<IBusinessA
@Input() header: IColumn[] = [
{ field: 'id', header: 'شناسه', type: 'id' },
{ field: 'name', header: 'عنوان' },
{ field: 'guild', header: 'صنف', type: 'nested', nestedPath: 'name' },
{ field: 'guild', header: 'صنف', type: 'nested', nestedOption: { path: 'guild.name' } },
{
field: 'license_info',
header: 'محدودیت کاربر',
customDataModel(item) {
const licenseInfo = (item as IBusinessActivityResponse).license_info;
if (!licenseInfo) {
return 'بدون مجوز';
}
return `${licenseInfo.accounts_limit} کاربر`;
},
},
{
field: 'license_info',
header: 'انقضای مجوز',
type: 'nested',
nestedOption: { path: 'license_info.expires_at', type: 'date' },
},
{
field: 'created_at',
header: 'تاریخ ایجاد',
@@ -8,10 +8,10 @@
>
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
<app-input label="عنوان" [control]="form.controls.name" name="name" />
<app-input label="سریال دستگاه" [control]="form.controls.serial" name="serial" />
<!-- <app-input label="مدل دستگاه" [control]="form.controls.model" name="model" /> -->
<app-enum-select [control]="form.controls.pos_type" type="posType" name="pos_type" />
@if (form.controls.pos_type.value === "PSP") {
<app-input label="سریال دستگاه" [control]="form.controls.serial" name="serial" />
<catalog-device-select [control]="form.controls.device_id" />
<catalog-provider-select [control]="form.controls.provider_id" />
}
@@ -43,6 +43,13 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
});
form.controls.pos_type.valueChanges.subscribe((value) => {
if (value === 'PSP') {
form.addControl(
'serial',
this.fb.control<string>(this.initialValues?.serial ?? '', {
nonNullable: true,
validators: [Validators.required],
}),
);
form.addControl(
'device_id',
this.fb.control<string>(this.initialValues?.device?.id ?? '', {
@@ -58,6 +65,8 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
}),
);
} else {
// @ts-ignore
form.removeControl('serial');
// @ts-ignore
form.removeControl('device_id');
// @ts-ignore
@@ -24,10 +24,15 @@ export class ConsumerPosesComponent extends AbstractList<IPosResponse> {
@Input() header: IColumn[] = [
{ field: 'id', header: 'شناسه', type: 'id' },
{ field: 'name', header: 'عنوان' },
{ field: 'serial', header: 'شماره سریال' },
{ field: 'device', header: 'دستگاه', type: 'nested', nestedPath: 'device.name' },
{ field: 'serial_number', header: 'شماره سریال' },
{ field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
{ field: 'pos_type', header: 'نوع دستگاه' },
{ field: 'provider', header: 'ارایه‌دهنده', type: 'nested', nestedPath: 'provider.name' },
{
field: 'provider',
header: 'ارایه‌دهنده',
type: 'nested',
nestedOption: { path: 'provider.name' },
},
{ field: 'status', header: 'وضعیت' },
{
field: 'created_at',
@@ -1,10 +1,12 @@
import ISummary from '@/core/models/summary';
export interface IBusinessActivityRawResponse {
id: string;
name: string;
economic_code: string;
guild: ISummary;
id: string;
created_at: string;
license_info: LicenseInfo;
}
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
@@ -13,3 +15,10 @@ export interface IBusinessActivityRequest {
economic_code: string;
guild_id: string;
}
interface LicenseInfo {
id: string;
starts_at: string;
expires_at: string;
accounts_limit: number;
}
@@ -5,6 +5,8 @@
<app-key-value label="عنوان" [value]="businessActivity()?.name" />
<app-key-value label="کد اقتصادی" [value]="businessActivity()?.economic_code" />
<app-key-value label="صنف" [value]="businessActivity()?.guild?.name" />
<app-key-value label="تاریخ انقضای مجوز" [value]="businessActivity()?.license_info?.expires_at" type="date" />
<app-key-value label="تعداد کاربران مجاز" [value]="businessActivity()?.license_info?.accounts_limit" />
</div>
</div>
</app-card-data>
@@ -3,6 +3,7 @@
<div class="flex flex-col gap-4">
<div class="grid grid-cols-3 gap-4 items-center">
<app-key-value label="عنوان" [value]="complex()?.name" />
<app-key-value label="کد شعبه" [value]="complex()?.branch_code" />
<app-key-value label="آدرس" [value]="complex()?.address" />
</div>
</div>
@@ -6,25 +6,6 @@
<app-key-value label="نام مشتری" [value]="consumer()?.fullname" />
<app-key-value label="شماره موبایل" [value]="consumer()?.mobile_number" />
<app-key-value label="وضعیت" [value]="consumer()?.status" />
@if (licenseStatus() === "EXPIRED") {
<app-key-value label="وضعیت لایسنس">
<p-button size="small" outlined severity="warn" (onClick)="openLicenseForm()">
منقضی شده در <span [jalaliDate]="license()!.expires_at"></span>
</p-button>
</app-key-value>
<!-- <app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرم‌افزار'" /> -->
} @else if (licenseStatus() === "ACTIVE") {
<app-key-value label="وضعیت لایسنس">
<p-button size="small" outlined severity="success" (onClick)="openLicenseForm()">
تا تاریخ <span [jalaliDate]="license()!.expires_at"></span>
</p-button>
</app-key-value>
<!-- <app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرم‌افزار'" /> -->
} @else {
<app-key-value label="وضعیت لایسنس">
<p-button size="small" outlined severity="danger" (onClick)="openLicenseForm()"> ارایه نشده </p-button>
</app-key-value>
}
</div>
</div>
</app-card-data>
@@ -39,13 +20,4 @@
[initialValues]="consumer() || undefined"
(onSubmit)="getData()"
/>
<partner-consumer-license-form
[(visible)]="visibleLicenseForm"
[editMode]="!!license()?.id"
[consumerId]="consumerId()"
[licenseId]="license()?.id"
[initialValues]="license() || undefined"
(onSubmit)="getData()"
/>
</div>