From 8c98e53427539b5410f58eface71e15d49038aaf Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sat, 16 May 2026 14:49:22 +0330 Subject: [PATCH] feat: update app version and build details in ngsw-config.json fix: add baseZIndex to p-toast component in app.component.ts feat: enhance pagination support in saleInvoices list component refactor: modify saleInvoices service to accept pagination query feat: update API routes for saleInvoices to support pagination fix: adjust layout for consumer accounts in partner module style: improve layout for consumer business activities in partner module fix: update license info display in dashboard component fix: ensure price info card displays default values for discount and tax refactor: clean up gold payload form component fix: adjust root component layout for mobile view refactor: unify consumer account list configuration across modules chore: remove deprecated partner consumer account list config chore: remove deprecated superAdmin consumer account list config feat: add new consumer account list configuration style: add summary list styling in customize.scss chore: switch API base URL for TIS environment --- ngsw-config.json | 6 +- src/app.component.ts | 2 +- .../components/list.component.html | 4 + .../saleInvoices/components/list.component.ts | 11 +- .../saleInvoices/constants/apiRoutes/index.ts | 11 +- .../saleInvoices/services/main.service.ts | 6 +- .../components/accounts/list.component.ts | 4 +- .../consumers/views/single.component.html | 8 +- .../license-info-template.component.html | 2 +- .../layouts/pagesLayout/layout.component.ts | 30 +-- .../order/price-info-card.component.html | 4 +- .../payloads/gold/form.component.ts | 20 +- .../modules/landing/views/root.component.html | 2 +- .../components/accounts/list.component.ts | 4 +- .../models/businessActivities_io.d.ts | 11 +- .../businessActivities/single.component.html | 3 + .../consumers/views/single.component.html | 11 +- .../shared/abstractClasses/abstract-list.ts | 13 +- .../amount-percentage-input.component.html | 3 - .../amount-percentage-input.component.ts | 173 ++++++++++-------- .../page-data-list-table-view.component.html | 2 +- .../page-data-list-table-view.component.ts | 3 +- .../page-data-list.component.html | 3 + .../pageDataList/page-data-list.component.ts | 2 + ...onst.ts => consumer-account-list.const.ts} | 4 +- .../shared/constants/list-configs/index.ts | 3 +- .../superAdmin-consumer-account-list.const.ts | 35 ---- src/assets/customize.scss | 7 + src/environments/environment.tis.ts | 4 +- 29 files changed, 219 insertions(+), 172 deletions(-) rename src/app/shared/constants/list-configs/{partner-consumer-account-list.const.ts => consumer-account-list.const.ts} (88%) delete mode 100644 src/app/shared/constants/list-configs/superAdmin-consumer-account-list.const.ts diff --git a/ngsw-config.json b/ngsw-config.json index b5874a2..5362cee 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -1,9 +1,9 @@ { "$schema": "./node_modules/@angular/service-worker/config/schema.json", "appData": { - "appVersion": "0.0.10", - "buildDate": "2026-05-13T09:21:01.165Z", - "buildNumber": 10 + "appVersion": "0.0.12", + "buildDate": "2026-05-16T08:49:47.932Z", + "buildNumber": 12 }, "assetGroups": [ { diff --git a/src/app.component.ts b/src/app.component.ts index ce34c4c..b0d2c5d 100644 --- a/src/app.component.ts +++ b/src/app.component.ts @@ -10,7 +10,7 @@ import { brandingConfig } from './app/branding/branding.config'; standalone: true, imports: [RouterModule, ToastModule, ConfirmDialog], template: ` - + `, diff --git a/src/app/domains/consumer/modules/saleInvoices/components/list.component.html b/src/app/domains/consumer/modules/saleInvoices/components/list.component.html index 4b6bdb4..66bea4b 100644 --- a/src/app/domains/consumer/modules/saleInvoices/components/list.component.html +++ b/src/app/domains/consumer/modules/saleInvoices/components/list.component.html @@ -4,7 +4,11 @@ emptyPlaceholderTitle="فاکتوری یافت نشد" [items]="items()" [loading]="loading()" + [perPage]="responseMetaData()?.perPage" + [currentPage]="responseMetaData()?.page" + [totalRecords]="responseMetaData()?.totalRecords || items().length" [showDetails]="true" (onDetails)="toSinglePage($event)" (onRefresh)="refresh()" + (onChangePage)="changePage($event)" /> diff --git a/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts b/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts index 07f6fc8..2667f1d 100644 --- a/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts +++ b/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts @@ -1,9 +1,11 @@ // import { CatalogRoleTagComponent } from '@/shared/catalog/roles'; +import { Maybe } from '@/core'; import { AbstractList } from '@/shared/abstractClasses/abstract-list'; import { IColumn, PageDataListComponent, } from '@/shared/components/pageDataList/page-data-list.component'; +import { IPaginatedQuery } from '@/core/models/service.model'; import { saleInvoiceListConfig } from '@/shared/constants/list-configs'; import { Component, inject, Input } from '@angular/core'; import { Router } from '@angular/router'; @@ -16,7 +18,10 @@ import { ConsumerSaleInvoicesService } from '../services/main.service'; templateUrl: './list.component.html', imports: [PageDataListComponent], }) -export class ConsumerSaleInvoiceListComponent extends AbstractList { +export class ConsumerSaleInvoiceListComponent extends AbstractList< + IConsumerSaleInvoicesResponse, + IPaginatedQuery +> { @Input() fullHeight?: boolean; @Input() header: IColumn[] = saleInvoiceListConfig.columns; @@ -27,8 +32,8 @@ export class ConsumerSaleInvoiceListComponent extends AbstractList) { + return this.service.getAll(payload || undefined); } toSinglePage(item: IConsumerSaleInvoicesResponse) { diff --git a/src/app/domains/consumer/modules/saleInvoices/constants/apiRoutes/index.ts b/src/app/domains/consumer/modules/saleInvoices/constants/apiRoutes/index.ts index 14d4af5..fa640c5 100644 --- a/src/app/domains/consumer/modules/saleInvoices/constants/apiRoutes/index.ts +++ b/src/app/domains/consumer/modules/saleInvoices/constants/apiRoutes/index.ts @@ -1,6 +1,15 @@ +import { IPaginatedQuery } from '@/core/models/service.model'; + const baseUrl = () => `/api/v1/consumer/sale-invoices`; export const CONSUMER_SALE_INVOICES_API_ROUTES = { - list: () => baseUrl(), + list: (paginationQuery?: IPaginatedQuery) => { + if (!paginationQuery) return baseUrl(); + const params = new URLSearchParams(); + if (paginationQuery.page) params.set('page', String(paginationQuery.page)); + if (paginationQuery.pageSize) params.set('perPage', String(paginationQuery.pageSize)); + const query = params.toString(); + return query ? `${baseUrl()}?${query}` : baseUrl(); + }, single: (id: string) => `${baseUrl()}/${id}`, }; diff --git a/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts b/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts index 0d3b15c..6bf72d1 100644 --- a/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts +++ b/src/app/domains/consumer/modules/saleInvoices/services/main.service.ts @@ -1,4 +1,4 @@ -import { IPaginatedResponse } from '@/core/models/service.model'; +import { IPaginatedQuery, IPaginatedResponse } from '@/core/models/service.model'; import { ISaleInvoiceFullRawResponse, ISaleInvoiceFullResponse } from '@/domains/consumer/models'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; @@ -12,9 +12,9 @@ export class ConsumerSaleInvoicesService { private apiRoutes = CONSUMER_SALE_INVOICES_API_ROUTES; - getAll(): Observable> { + getAll(paginationQuery?: IPaginatedQuery): Observable> { return this.http.get>( - this.apiRoutes.list(), + this.apiRoutes.list(paginationQuery), ); } getSingle(invoiceId: string): Observable { diff --git a/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts b/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts index 1e030c8..8d88ce9 100644 --- a/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts +++ b/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts @@ -4,7 +4,7 @@ import { IColumn, PageDataListComponent, } from '@/shared/components/pageDataList/page-data-list.component'; -import { partnerConsumerAccountListConfig } from '@/shared/constants/list-configs'; +import { consumerAccountListConfig } from '@/shared/constants/list-configs'; import { Component, inject, Input } from '@angular/core'; import { IConsumerAccountResponse } from '../../models'; import { PartnerConsumerAccountsService } from '../../services/accounts.service'; @@ -18,7 +18,7 @@ import { ConsumerAccountFormComponent } from './form.component'; export class ConsumerAccountListComponent extends AbstractList { @Input({ required: true }) consumerId!: string; @Input() fullHeight?: boolean; - @Input() header: IColumn[] = partnerConsumerAccountListConfig.columns; + @Input() header: IColumn[] = consumerAccountListConfig.columns; private readonly service = inject(PartnerConsumerAccountsService); override setColumns(): void { diff --git a/src/app/domains/partner/modules/consumers/views/single.component.html b/src/app/domains/partner/modules/consumers/views/single.component.html index c2ef4e8..edc3b57 100644 --- a/src/app/domains/partner/modules/consumers/views/single.component.html +++ b/src/app/domains/partner/modules/consumers/views/single.component.html @@ -16,8 +16,12 @@ - - +
+ +
+
+ +
وضعیت {{ title }} - +

diff --git a/src/app/domains/pos/layouts/pagesLayout/layout.component.ts b/src/app/domains/pos/layouts/pagesLayout/layout.component.ts index 57d1210..f946955 100644 --- a/src/app/domains/pos/layouts/pagesLayout/layout.component.ts +++ b/src/app/domains/pos/layouts/pagesLayout/layout.component.ts @@ -8,6 +8,7 @@ import { MenuItem } from 'primeng/api'; import { Button, ButtonDirective } from 'primeng/button'; import { Card } from 'primeng/card'; import { Menu } from 'primeng/menu'; +import { finalize } from 'rxjs'; import images from 'src/assets/images'; import { PosInfoStore, PosProfileStore } from '../../store'; import { DeviceInfoStore } from '../../store/device.store'; @@ -85,19 +86,22 @@ export class PosPagesLayoutComponent { homeRouteLink = '/pos'; async getData() { - // await this.layoutService.changeFullPageLoading(true); - // await this.posProfileStore.getData().subscribe({ - // next: () => { - // this.posInfoStore - // .getData() - // .pipe( - // finalize(() => { - // this.layoutService.changeFullPageLoading(false); - // }), - // ) - // .subscribe(); - // }, - // }); + if (!this.posInfo() || !this.posProfile()) { + await this.layoutService.changeFullPageLoading(true); + await this.layoutService.changeFullPageLoading(true); + await this.posProfileStore.getData().subscribe({ + next: () => { + this.posInfoStore + .getData() + .pipe( + finalize(() => { + this.layoutService.changeFullPageLoading(false); + }), + ) + .subscribe(); + }, + }); + } } toggleMenu() { diff --git a/src/app/domains/pos/modules/landing/components/order/price-info-card.component.html b/src/app/domains/pos/modules/landing/components/order/price-info-card.component.html index 0b0e0be..834cd47 100644 --- a/src/app/domains/pos/modules/landing/components/order/price-info-card.component.html +++ b/src/app/domains/pos/modules/landing/components/order/price-info-card.component.html @@ -15,11 +15,11 @@
تخفیف - +
مالیات - +

diff --git a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts index 5a07da4..dbb92ef 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts +++ b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts @@ -31,16 +31,16 @@ export class PosGoldPayloadFormComponent extends AbstractForm< IPosOrderItem, IPosOrderItem > { - override defaultValues: Partial> = { - unit_price: 200_000_000, - quantity: 2, - payload: { - commission: 10_000, - wages: 10_000, - profit: 10_000, - karat: '18' as TGoldKarat, - } as any, - }; + // override defaultValues: Partial> = { + // unit_price: 200_000_000, + // quantity: 2, + // payload: { + // commission: 10_000, + // wages: 10_000, + // profit: 10_000, + // karat: '18' as TGoldKarat, + // } as any, + // }; @Output() onSubmitForm = new EventEmitter(); @Output() onChangeTotalAmount = new EventEmitter(); diff --git a/src/app/domains/pos/modules/landing/views/root.component.html b/src/app/domains/pos/modules/landing/views/root.component.html index 760dde9..1555aeb 100644 --- a/src/app/domains/pos/modules/landing/views/root.component.html +++ b/src/app/domains/pos/modules/landing/views/root.component.html @@ -19,9 +19,9 @@ type="button" pButton class="sticky! bottom-0 inset-x-0 w-full right-0 z-1200 border-t border-surface-border bg-surface-0 px-4 py-3 shadow-[0_-4px_16px_rgba(0,0,0,0.08)] md:hidden! rounded-b-none!" - [style.paddingBottom]="'calc(0.75rem + {{env(safe-area-inset-bottom)}})'" (click)="openInvoiceBottomSheet()" > +
مبلغ کل فاکتور diff --git a/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts b/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts index 1e38d60..8cc4c91 100644 --- a/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts +++ b/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts @@ -4,7 +4,7 @@ import { IColumn, PageDataListComponent, } from '@/shared/components/pageDataList/page-data-list.component'; -import { superAdminConsumerAccountListConfig } from '@/shared/constants/list-configs'; +import { consumerAccountListConfig } from '@/shared/constants/list-configs'; import { Component, inject, Input } from '@angular/core'; import { IConsumerAccountResponse } from '../../models'; import { AdminConsumerAccountsService } from '../../services/accounts.service'; @@ -18,7 +18,7 @@ import { ConsumerAccountFormComponent } from './form.component'; export class ConsumerAccountListComponent extends AbstractList { @Input({ required: true }) consumerId!: string; @Input() fullHeight?: boolean; - @Input() header: IColumn[] = superAdminConsumerAccountListConfig.columns; + @Input() header: IColumn[] = consumerAccountListConfig.columns; private readonly service = inject(AdminConsumerAccountsService); override setColumns(): void { diff --git a/src/app/domains/superAdmin/modules/consumers/models/businessActivities_io.d.ts b/src/app/domains/superAdmin/modules/consumers/models/businessActivities_io.d.ts index cc73022..da96128 100644 --- a/src/app/domains/superAdmin/modules/consumers/models/businessActivities_io.d.ts +++ b/src/app/domains/superAdmin/modules/consumers/models/businessActivities_io.d.ts @@ -1,12 +1,14 @@ import ISummary from '@/core/models/summary'; export interface IBusinessActivityRawResponse { + id: string; name: string; economic_code: string; fiscal_id: string; partner_token: string; guild: ISummary; - id: string; + created_at: string; + license_info: LicenseInfo; } export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {} @@ -17,3 +19,10 @@ export interface IBusinessActivityRequest { partner_token: string; guild_id: string; } + +interface LicenseInfo { + id: string; + starts_at: string; + expires_at: string; + accounts_limit: number; +} diff --git a/src/app/domains/superAdmin/modules/consumers/views/businessActivities/single.component.html b/src/app/domains/superAdmin/modules/consumers/views/businessActivities/single.component.html index c456f43..cd33abb 100644 --- a/src/app/domains/superAdmin/modules/consumers/views/businessActivities/single.component.html +++ b/src/app/domains/superAdmin/modules/consumers/views/businessActivities/single.component.html @@ -3,7 +3,10 @@
+ + +
diff --git a/src/app/domains/superAdmin/modules/consumers/views/single.component.html b/src/app/domains/superAdmin/modules/consumers/views/single.component.html index 89c638f..1f3e1e3 100644 --- a/src/app/domains/superAdmin/modules/consumers/views/single.component.html +++ b/src/app/domains/superAdmin/modules/consumers/views/single.component.html @@ -4,21 +4,24 @@
- - @if (consumer()?.type?.value === "LEGAL") { } @else { } +
- - +
+ +
+
+ +
{ } changePage(page: number) { - // this. + const perPage = this.responseMetaData()?.perPage; + this.requestPayload.update( + (prev) => + ({ + ...(prev || {}), + page, + ...(perPage ? ({ pageSize: perPage } as IPaginatedQuery) : {}), + }) as any, + ); + this.responseMetaData.update((prev) => (prev ? { ...prev, page } : prev)); + this.getData(); } } diff --git a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html index 965e006..01b797f 100644 --- a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html +++ b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html @@ -28,9 +28,7 @@ [inputStyleClass]="` w-full hasSuffix text-left ${size === 'large' ? 'p-inputtext-lg' : size === 'small' ? 'p-inputtext-sm' : ''}`" [required]="required" [invalid]="amountControl.invalid && (amountControl.touched || amountControl.dirty)" - (onInput)="onPriceInput($event)" /> - } @else { } diff --git a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts index fafe311..51439e3 100644 --- a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts +++ b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts @@ -19,7 +19,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { InputGroup } from 'primeng/inputgroup'; import { InputGroupAddon } from 'primeng/inputgroupaddon'; -import { InputNumberInputEvent, InputNumberModule } from 'primeng/inputnumber'; +import { InputNumberModule } from 'primeng/inputnumber'; import { InputText } from 'primeng/inputtext'; import { Select } from 'primeng/select'; @@ -90,83 +90,85 @@ export class AmountPercentageInputComponent { }); preparedLabel = signal(this.label); + private lastValidAmount = 0; + private lastValidPercentage = 0; - onPriceInput($event: InputNumberInputEvent) { - this.onInput($event.originalEvent, true); + private parseValue(value: Maybe) { + const normalized = `${value ?? ''}`.replace(/,/g, ''); + const parsed = parseFloat(normalized); + return Number.isFinite(parsed) ? parsed : 0; } - onInput($event: Event, isPriceType: boolean = false) { - // @ts-ignore - let value = $event.target.value as string; - // @ts-ignore - const isDotInput = $event.data === '.'; + private getRangeLabel(value: number, isPercentageType: boolean) { + return isPercentageType ? `${value}%` : formatWithCurrency(value); + } - if (isDotInput) { + private isInRange(value: number, min = 0, max = Number.MAX_SAFE_INTEGER) { + return value >= min && value <= max; + } + + private showOutOfRangeToast(value: number, isPercentageType: boolean, min = 0, max = Number.MAX_SAFE_INTEGER) { + if (value < min) { + this.toastService.warn({ + text: `مقدار ${this.label} باید بیشتر از ${this.getRangeLabel(min, isPercentageType)} باشد.`, + }); + } + if (value > max) { + this.toastService.warn({ + text: `مقدار ${this.label} باید کمتر از ${this.getRangeLabel(max, isPercentageType)} باشد.`, + }); + } + } + + private getAmountRange() { + const min = this.minAmount ?? 0; + const maxFromInput = this.maxAmount; + const max = maxFromInput ?? (this.baseAmount > 0 ? this.baseAmount : Number.MAX_SAFE_INTEGER); + return { min, max }; + } + + private getPercentageRange() { + const min = this.minPercentage ?? 0; + const max = this.maxPercentage ?? 100; + return { min, max }; + } + + private syncFromPercentage(rawValue: Maybe) { + const { min, max } = this.getPercentageRange(); + const percentageValue = this.parseValue(rawValue); + if (!this.isInRange(percentageValue, min, max)) { + this.showOutOfRangeToast(percentageValue, true, min, max); + this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false }); return; } - if (isPriceType) { - value = value.replace(/,/g, ''); - } + this.lastValidPercentage = percentageValue; + const amountValue = (this.baseAmount * percentageValue) / 100; + this.lastValidAmount = Number.isFinite(amountValue) ? amountValue : 0; - const newValueToSet = this.modifyControlsData(value); - - if (newValueToSet !== null) { - // @ts-ignore - $event.target.value = newValueToSet; - } + this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false }); + this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); + this.preparedLabel.set(this.prepareLabel(true)); } - private modifyControlsData(value: string) { - let newValueToSet: Maybe = null; - let newValue = parseFloat(value); - const isPercentageType = this.selectedType.value === 'percentage'; - - const min = (isPercentageType ? this.minPercentage : this.minAmount) || 0; - const max = (isPercentageType ? this.maxPercentage : this.maxAmount) || Number.MAX_SAFE_INTEGER; - - const maxValidator = max < newValue; - const minValidator = min > newValue; - - const notValid = minValidator || maxValidator; - - if (notValid) { - if (minValidator) { - this.toastService.warn({ - text: `مقدار ${this.label} باید بیشتر از ${formatWithCurrency(min)} باشد.`, - }); - } - if (maxValidator) { - this.toastService.warn({ - text: `مقدار ${this.label} باید کمتر از ${formatWithCurrency(max)} باشد.`, - }); - } - - newValue = parseFloat(value.slice(0, value.length - 1)); - if (newValue < 0 || isNaN(newValue)) { - newValue = 0; - } + private syncFromAmount(rawValue: Maybe) { + const { min, max } = this.getAmountRange(); + const amountValue = this.parseValue(rawValue); + if (!this.isInRange(amountValue, min, max)) { + this.showOutOfRangeToast(amountValue, false, min, max); + this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); + return; } - if (isPercentageType) { - const amountValue = (this.baseAmount * newValue) / 100; - newValueToSet = newValue + ''; - this.amountControl.setValue(isNaN(amountValue) ? 0 : amountValue, { emitEvent: false }); - if (notValid) { - this.percentageControl.setValue(newValue, { emitEvent: false }); - } - } else { - const percentageValue = ((newValue / this.baseAmount) * 100).toFixed(2); - newValueToSet = newValue + ''; - this.percentageControl.setValue(percentageValue, { emitEvent: false }); - this.preparedLabel.set(`${this.label} (${percentageValue} درصد)`); - if (notValid) { - this.amountControl.setValue(newValue, { emitEvent: false }); - } - } - this.preparedLabel.set(this.prepareLabel(isPercentageType)); + this.lastValidAmount = amountValue; + const percentageValue = this.baseAmount + ? ((amountValue / this.baseAmount) * 100).toFixed(2) + : '0'; + this.lastValidPercentage = this.parseValue(percentageValue); - return newValue; + this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); + this.percentageControl.setValue(percentageValue, { emitEvent: false }); + this.preparedLabel.set(this.prepareLabel(false)); } private prepareLabel(isPercentageType: boolean) { @@ -177,25 +179,44 @@ export class AmountPercentageInputComponent { } ngOnInit() { - const amountValue = Number(this.amountControl.value || 0); - const percentageValue = Number(this.percentageControl.value || 0); - const isPercentageType = percentageValue > 0 && amountValue <= 0; - - console.log(amountValue, percentageValue, isPercentageType); - - this.preparedLabel.set(this.prepareLabel(isPercentageType)); + const isPercentageType = this.defaultType === 'percentage'; this.selectedType.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => { this.preparedLabel.set(this.prepareLabel(value === 'percentage')); }); - this.selectedType.setValue(isPercentageType ? 'percentage' : 'amount'); + this.percentageControl.valueChanges + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((value) => { + if (this.selectedType.value === 'percentage') { + this.syncFromPercentage(value); + } + }); + + this.amountControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => { + if (this.selectedType.value === 'amount') { + this.syncFromAmount(value); + } + }); + + this.selectedType.setValue(isPercentageType ? 'percentage' : 'amount', { emitEvent: false }); + this.lastValidAmount = this.parseValue(this.amountControl.value); + this.lastValidPercentage = this.parseValue(this.percentageControl.value); + if (isPercentageType) { + this.syncFromPercentage(this.percentageControl.value); + } else { + this.syncFromAmount(this.amountControl.value); + } } ngOnChanges() { - const amountValue = Number(this.amountControl.value || 0); - const percentageValue = Number(this.percentageControl.value || 0); - const isPercentageType = percentageValue > 0 && amountValue <= 0; + const isPercentageType = this.selectedType.value === 'percentage'; + if (isPercentageType) { + this.syncFromPercentage(this.percentageControl.value); + } else { + this.syncFromAmount(this.amountControl.value); + } + this.preparedLabel.set(this.prepareLabel(isPercentageType)); } } diff --git a/src/app/shared/components/pageDataList/page-data-list-table-view.component.html b/src/app/shared/components/pageDataList/page-data-list-table-view.component.html index e4d9627..dd3a865 100644 --- a/src/app/shared/components/pageDataList/page-data-list-table-view.component.html +++ b/src/app/shared/components/pageDataList/page-data-list-table-view.component.html @@ -58,7 +58,7 @@ } @if (showIndex) { - {{ i * (currentPage || 1) + 1 }} + {{ i + 1 + (currentPage && perPage ? (currentPage - 1) * perPage : 0) }} } @for (col of columns; track col.field) { diff --git a/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts b/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts index 02c4f26..09901c9 100644 --- a/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts +++ b/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts @@ -18,8 +18,8 @@ import { SkeletonModule } from 'primeng/skeleton'; import { TableModule } from 'primeng/table'; import { KeyValueComponent } from '../key-value.component/key-value.component'; import { TableActionRowComponent } from '../table-action-row.component'; -import { PageDataValueComponent } from './page-data-value.component'; import { IColumn } from './page-data-list.component'; +import { PageDataValueComponent } from './page-data-value.component'; @Component({ selector: 'app-page-data-list-table-view', @@ -50,6 +50,7 @@ export class AppPageDataListTableView { @Input() emptyPlaceholderDescription?: string = ''; @Input() emptyPlaceholderCtaLabel?: string; @Input() currentPage?: number = 1; + @Input() perPage?: number = 1; @Input() showEdit: boolean = false; @Input() showDelete: boolean = false; @Input() showDetails: boolean = false; diff --git a/src/app/shared/components/pageDataList/page-data-list.component.html b/src/app/shared/components/pageDataList/page-data-list.component.html index 5183304..6df028b 100644 --- a/src/app/shared/components/pageDataList/page-data-list.component.html +++ b/src/app/shared/components/pageDataList/page-data-list.component.html @@ -76,6 +76,7 @@ [emptyPlaceholderCtaLabel]="emptyPlaceholderCtaLabel || addNewCtaLabel" [addNewCtaLabel]="addNewCtaLabel" [currentPage]="currentPage" + [perPage]="perPage" [showEdit]="showEdit" [showDelete]="showDelete" [showDetails]="showDetails" @@ -84,9 +85,11 @@ [expandable]="expandable" [expandableItemKey]="expandableItemKey" [expandColumns]="expandColumns" + [showPaginator]="showPaginator" (onEdit)="edit($event)" (onDelete)="remove($event)" (onDetails)="details($event)" + (onChangePage)="onPage($event)" > @if (pageTitle || showAdd || filter || showRefresh || moreActions) { diff --git a/src/app/shared/components/pageDataList/page-data-list.component.ts b/src/app/shared/components/pageDataList/page-data-list.component.ts index bb071f4..8e639a2 100644 --- a/src/app/shared/components/pageDataList/page-data-list.component.ts +++ b/src/app/shared/components/pageDataList/page-data-list.component.ts @@ -176,6 +176,8 @@ export class PageDataListComponent { }; onPage = ($event: any) => { + console.log('$event', $event); + this.onChangePage.emit($event); }; diff --git a/src/app/shared/constants/list-configs/partner-consumer-account-list.const.ts b/src/app/shared/constants/list-configs/consumer-account-list.const.ts similarity index 88% rename from src/app/shared/constants/list-configs/partner-consumer-account-list.const.ts rename to src/app/shared/constants/list-configs/consumer-account-list.const.ts index d453090..b19ec2d 100644 --- a/src/app/shared/constants/list-configs/partner-consumer-account-list.const.ts +++ b/src/app/shared/constants/list-configs/consumer-account-list.const.ts @@ -1,6 +1,6 @@ import { IListConfig } from './list-config.model'; -export const partnerConsumerAccountListConfig: IListConfig = { +export const consumerAccountListConfig: IListConfig = { pageTitle: 'مدیریت حساب‌های مشتری', addNewCtaLabel: 'افزودن حساب', emptyPlaceholderTitle: 'حسابی یافت نشد', @@ -27,7 +27,7 @@ export const partnerConsumerAccountListConfig: IListConfig = { field: 'status', header: 'وضعیت', type: 'nested', - nestedOption: { path: 'account.status.translate' }, + nestedOption: { path: 'status.translate' }, variant: 'tag', }, ], diff --git a/src/app/shared/constants/list-configs/index.ts b/src/app/shared/constants/list-configs/index.ts index 544735c..80494af 100644 --- a/src/app/shared/constants/list-configs/index.ts +++ b/src/app/shared/constants/list-configs/index.ts @@ -2,6 +2,7 @@ export * from './account-list.const'; export * from './business-activity-list.const'; export * from './category-list.const'; export * from './complex-list.const'; +export * from './consumer-account-list.const'; export * from './consumer-list.const'; export * from './device-brand-list.const'; export * from './device-list.const'; @@ -9,12 +10,10 @@ export * from './good-list.const'; export * from './license-list.const'; export * from './list-config.model'; export * from './partner-account-list.const'; -export * from './partner-consumer-account-list.const'; export * from './partner-customer-list.const'; export * from './partner-list.const'; export * from './pos-list.const'; export * from './provider-list.const'; export * from './sale-invoice-list.const'; export * from './sku-list.const'; -export * from './superAdmin-consumer-account-list.const'; export * from './user-list.const'; diff --git a/src/app/shared/constants/list-configs/superAdmin-consumer-account-list.const.ts b/src/app/shared/constants/list-configs/superAdmin-consumer-account-list.const.ts deleted file mode 100644 index 802b4ba..0000000 --- a/src/app/shared/constants/list-configs/superAdmin-consumer-account-list.const.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { IListConfig } from './list-config.model'; - -export const superAdminConsumerAccountListConfig: IListConfig = { - pageTitle: 'مدیریت حساب‌های مشتری', - addNewCtaLabel: 'افزودن حساب', - emptyPlaceholderTitle: 'حسابی یافت نشد', - emptyPlaceholderDescription: 'برای افزودن حساب، روی دکمهٔ بالا کلیک کنید.', - columns: [ - { - field: 'account', - header: 'نام کاربری', - type: 'nested', - nestedOption: { path: 'account.username' }, - }, - { field: 'role', header: 'نوع حساب', type: 'nested', nestedOption: { path: 'role.translate' } }, - { - field: 'pos', - header: 'پایانه', - customDataModel(item: any) { - return `${item.pos.name} (${item.pos.complex.name} - ${item.pos.complex.business_activity.name})`; - }, - }, - { - field: 'status', - header: 'وضعیت', - type: 'nested', - nestedOption: { path: 'account.status.translate' }, - }, - { - field: 'created_at', - header: 'تاریخ ایجاد', - type: 'date', - }, - ], -}; diff --git a/src/assets/customize.scss b/src/assets/customize.scss index 05cda42..9a2c342 100644 --- a/src/assets/customize.scss +++ b/src/assets/customize.scss @@ -9,3 +9,10 @@ .cardShadow { box-shadow: var(--p-card-shadow) !important; } + +.summaryList { + @apply max-h-125 flex; + > * { + @apply w-full; + } +} diff --git a/src/environments/environment.tis.ts b/src/environments/environment.tis.ts index 0ac90f5..8873f90 100644 --- a/src/environments/environment.tis.ts +++ b/src/environments/environment.tis.ts @@ -1,8 +1,8 @@ // TIS tenant environment configuration export const environment = { production: true, - apiBaseUrl: 'https://psp-api.shift-am.ir', - // apiBaseUrl: 'http://192.168.128.73:5002', + // apiBaseUrl: 'https://psp-api.shift-am.ir', + apiBaseUrl: 'http://192.168.128.73:5002', host: 'localhost', port: 5000, enableLogging: false,