feat: add refresh functionality to various components

- Implemented refresh event emission in multiple list components across partner and superAdmin modules.
- Updated consumers and customers list components to handle refresh actions.
- Enhanced dashboard component to fetch partner info on initialization.
- Introduced new API method in PartnerService to retrieve current partner data.
- Modified PartnerStore to utilize the new API method for fetching partner information.
- Updated UI elements to reflect changes in partner and license management, including new fields for license renewals.
- Added a new POS display component for better presentation of POS terminal information.
- Updated layout service and top bar to reflect new titles and improve user experience.
- Refactored existing components to ensure consistency and maintainability.
This commit is contained in:
2026-04-24 23:01:44 +03:30
parent 5bb5f10dbf
commit a816c05777
73 changed files with 559 additions and 97 deletions
+11 -11
View File
@@ -1,21 +1,21 @@
{
"name": "مدیریت کسب‌وکار",
"short_name": "مدیریت کسب‌وکار",
"background_color": "#ffffff",
"display": "standalone",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"purpose": "maskable",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
"src": "/web-app-manifest-192x192.png",
"type": "image/png"
},
{
"src": "/web-app-manifest-512x512.png",
"purpose": "maskable",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
"src": "/web-app-manifest-512x512.png",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"name": "مدیریت صورت‌حساب‌های مالیاتی",
"short_name": "مدیریت صورت‌حساب‌های مالیاتی",
"theme_color": "#ffffff"
}
+1
View File
@@ -0,0 +1 @@
export * from './pos-display';
+133
View File
@@ -0,0 +1,133 @@
# POS Display Component
A reusable component for displaying Point-of-Sale (POS) terminal information with configurable variants.
## Overview
The `PosDisplayComponent` displays POS entity information in a card-based layout with support for different visibility variants ('consumer', 'partner', 'full').
## Features
- **Variant Support**: Choose from 'consumer', 'partner', or 'full' display modes
- **Conditional Field Visibility**: Fields are dynamically shown/hidden based on variant
- **Edit Mode**: Toggle between view and edit modes
- **Responsive Grid**: Displays up to 3 columns with gap-4 spacing
- **More Actions**: Optional button for additional actions
## Usage
### Basic Usage
```typescript
import { PosDisplayComponent, IPosEntity } from '@/app/components';
@Component({
selector: 'app-my-component',
template: `
<app-pos-display
variant="consumer"
[pos]="posData"
[editMode]="isEditing"
(onMoreAction)="handleMoreAction()"
(editModeChange)="editModeChange($event)"
/>
`,
standalone: true,
imports: [PosDisplayComponent],
})
export class MyComponent {
posData = signal<IPosEntity>({
id: '123',
name: 'Terminal 1',
pos_type: 'PSP',
serial_number: 'SN123',
model: 'Model X',
status: 'active',
complex: { id: 'c1', name: 'Complex 1' },
device: { id: 'd1', name: 'Device A' },
provider: { id: 'p1', name: 'Provider A' },
});
isEditing = signal(false);
handleMoreAction(): void {
console.log('More action clicked');
}
editModeChange(editing: boolean): void {
this.isEditing.set(editing);
}
}
```
## Variants
### Consumer Variant
Displays: name, pos_type, serial_number, device, model, provider (6 fields)
### Partner Variant
Displays: name, pos_type, serial_number (3 fields)
### Full Variant
Displays: name, pos_type, serial_number, device, model, provider (6 fields - same as consumer)
## Inputs
| Input | Type | Default | Description |
|-------|------|---------|-------------|
| `variant` | 'consumer' \| 'partner' \| 'full' | 'full' | Display variant mode |
| `pos` | Signal<IPosEntity \| undefined> | undefined | POS entity data |
| `editMode` | Signal<boolean> | false | Edit mode state |
| `cardTitle` | string | 'اطلاعات پایانه‌ی فروش' | Card header title |
| `showMoreActions` | boolean | true | Show more actions button |
## Outputs
| Output | Payload | Description |
|--------|---------|-------------|
| `editModeChange` | boolean | Emitted when edit mode toggled |
| `onMoreAction` | void | Emitted when more actions button clicked |
| `onSubmit` | void | Emitted on form submission |
## Model (IPosEntity)
```typescript
interface IPosEntity {
id: string;
name: string;
serial_number: string;
model?: string;
status: string;
pos_type: string;
complex: ISummary;
device?: ISummary;
provider?: ISummary;
}
```
## Integration in Existing Component
To replace the inline display in your POS single view:
```typescript
// Before: Manual field rendering
<app-key-value label="عنوان" [value]="pos()?.name" />
<app-key-value label="نوع پایانه" [value]="pos()?.pos_type" />
// ... more fields
// After: Use the component
<app-pos-display
variant="full"
[pos]="pos"
[editMode]="editMode"
(onMoreAction)="toPosLanding()"
/>
```
## Files
- `pos-display.component.ts` - Component logic
- `pos-display.component.html` - Template
- `pos-display.component.scss` - Styles
- `models/posEntity.model.ts` - TypeScript interfaces and types
- `index.ts` - Barrel export
+2
View File
@@ -0,0 +1,2 @@
export * from './models/posEntity.model';
export * from './pos-display.component';
@@ -0,0 +1,27 @@
import ISummary from '@/core/models/summary';
export type PosVariant = 'consumer' | 'partner' | 'full';
export interface IPosEntity {
id: string;
name: string;
serial_number: string;
model?: string;
status: string;
pos_type: string;
complex: ISummary;
device?: ISummary;
provider?: ISummary;
}
export interface IPosDisplayConfig {
variant: PosVariant;
editable?: boolean;
showMoreActions?: boolean;
}
export const POS_VARIANT_FIELDS: Record<PosVariant, Array<keyof IPosEntity>> = {
consumer: ['name', 'pos_type', 'serial_number', 'device', 'model', 'provider'],
partner: ['name', 'pos_type', 'serial_number'],
full: ['name', 'pos_type', 'serial_number', 'device', 'model', 'provider'],
};
@@ -0,0 +1,17 @@
<app-card-data [cardTitle]="cardTitle" [editable]="true" [editMode]="isEditing()" (editModeChange)="toggleEditMode()">
<ng-template #moreActions>
@if (showMoreActions) {
<p-button type="button" variant="outlined" (onClick)="handleMoreAction()"> ورود به پایانه </p-button>
}
</ng-template>
<div class="flex flex-col gap-4">
<div class="grid grid-cols-3 gap-4 items-center">
@for (field of visibleFields(); track field) {
@if (isFieldVisible(field)) {
<app-key-value [label]="fieldLabels[field]" [value]="getFieldValue(field)" />
}
}
</div>
</div>
</app-card-data>
@@ -0,0 +1,78 @@
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
import { CommonModule } from '@angular/common';
import { Component, effect, EventEmitter, Input, Output, signal } from '@angular/core';
import { Button } from 'primeng/button';
import { IPosEntity, POS_VARIANT_FIELDS, PosVariant } from './models/posEntity.model';
@Component({
selector: 'app-pos-entity-display',
standalone: true,
imports: [CommonModule, AppCardComponent, Button, KeyValueComponent],
templateUrl: './pos-display.component.html',
})
export class PosDisplayComponent {
@Input() variant: PosVariant = 'full';
@Input() pos = signal<IPosEntity | undefined>(undefined);
@Input() editMode = signal<boolean>(false);
@Input() cardTitle = 'اطلاعات پایانه‌ی فروش';
@Input() showMoreActions = true;
@Output() editModeChange = new EventEmitter<boolean>();
@Output() onMoreAction = new EventEmitter<void>();
@Output() onSubmit = new EventEmitter<void>();
visibleFields = signal<Array<keyof IPosEntity>>([]);
isEditing = signal<boolean>(false);
constructor() {
effect(() => {
this.visibleFields.set(POS_VARIANT_FIELDS[this.variant] || POS_VARIANT_FIELDS.full);
});
effect(() => {
this.isEditing.set(this.editMode());
});
}
get fieldLabels(): Record<string, string> {
return {
name: 'عنوان',
pos_type: 'نوع پایانه',
serial_number: 'شماره سریال',
device: 'نوع دستگاه',
model: 'مدل دستگاه',
provider: 'ارایه‌دهنده',
};
}
isFieldVisible(field: keyof IPosEntity): boolean {
return this.visibleFields().includes(field);
}
getFieldValue(field: keyof IPosEntity): any {
const posData = this.pos();
if (!posData) return null;
if (field === 'device' && posData.device) {
return posData.device.name;
}
if (field === 'provider' && posData.provider) {
return posData.provider.name;
}
return posData[field];
}
toggleEditMode(): void {
const newMode = !this.isEditing();
this.isEditing.set(newMode);
this.editModeChange.emit(newMode);
}
handleMoreAction(): void {
this.onMoreAction.emit();
}
handleSubmit(): void {
this.onSubmit.emit();
}
}
@@ -58,6 +58,7 @@
[items]="invoice()?.items"
[loading]="loading"
pageTitle=""
(onRefresh)="refresh()"
/>
</app-card-data>
</div>
@@ -4,7 +4,7 @@ import {
PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { getGoodUnitTypeProperties } from '@/utils';
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Badge } from 'primeng/badge';
import { ButtonDirective } from 'primeng/button';
import { Divider } from 'primeng/divider';
@@ -30,6 +30,8 @@ export class ConsumerSaleInvoiceSharedComponent {
@Input({ required: true }) invoice!: any;
@Input() variant: TConsumerSaleInvoice = 'full';
@Output() onRefresh = new EventEmitter<void>();
printInvoice = () => {
window.print();
};
@@ -86,4 +88,8 @@ export class ConsumerSaleInvoiceSharedComponent {
];
expandedRows: { [key: string]: boolean } = {};
refresh() {
this.onRefresh.emit();
}
}
@@ -4,6 +4,7 @@
emptyPlaceholderTitle="حساب‌ کاربری‌ای یافت نشد"
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
/>
@if (selectedItemForEdit()) {
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<consumer-complex-form
@@ -12,6 +12,7 @@
[fullHeight]="fullHeight"
(onEdit)="onEditClick($event)"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
/>
<consumer-complex-good-form
[businessId]="businessId"
@@ -7,6 +7,7 @@
[showDetails]="true"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<consumer-businessActivity-form
@@ -11,6 +11,12 @@
<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_number" name="serial_number" />
<catalog-device-select [control]="form.controls.device_id" />
<catalog-provider-select [control]="form.controls.provider_id" />
}
@if (!editMode) {
<p-divider align="center"> اطلاعات ورود </p-divider>
<app-input label="نام کاربری" [control]="form.controls.username" name="username" [isLtrInput]="true" />
@@ -51,12 +57,6 @@
</uikit-field>
}
@if (form.controls.pos_type.value === "PSP") {
<app-input label="سریال دستگاه" [control]="form.controls.serial_number" name="serial_number" />
<catalog-device-select [control]="form.controls.device_id" />
<catalog-provider-select [control]="form.controls.provider_id" />
}
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
</form>
</p-dialog>
@@ -12,6 +12,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<consumer-pos-form
@@ -4,5 +4,6 @@
emptyPlaceholderTitle="تا به حال فاکتور فروشی توسط این پایانه ایجاد نشده است."
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
>
</app-page-data-list>
@@ -8,6 +8,7 @@
[showDetails]="true"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
@if (selectedItemForEdit()) {
@@ -6,4 +6,5 @@
[loading]="loading()"
[showDetails]="true"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
@@ -6,6 +6,7 @@
[showDetails]="true"
[loading]="loading()"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
<ng-template #moreActions>
<a routerLink pButton [routerLink]="invoicesPageRoute" outlined>تمامی فاکتورها</a>
@@ -8,6 +8,7 @@
[showEdit]="true"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
<ng-template #toPosLandingAction let-item>
<p-button type="button" variant="outlined" (onClick)="toPosLanding(item.id)"> ورود به پایانه </p-button>
@@ -6,4 +6,5 @@
[loading]="loading()"
[showDetails]="true"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
+1 -1
View File
@@ -39,7 +39,7 @@ export class ConsumerStore extends EntityStore<IConsumerInfoResponse, ConsumerSt
)
.subscribe((entity) => {
this.layoutService.setPanelInfo({
title: 'پنل مدیریت کسب و کار',
title: 'پنل مدیریت صورت‌حساب‌های مالیاتی',
});
this.patchState({ entity });
});
@@ -1,5 +1,6 @@
const baseUrl = '/api/v1/partner';
export const PARTNER_API_ROUTES = {
info: () => `${baseUrl}`,
me: () => `${baseUrl}`,
info: () => `${baseUrl}/info`,
};
+11 -2
View File
@@ -1,5 +1,14 @@
export interface IPartnerInfoRawResponse {
import ISummary from '@/core/models/summary';
export interface IPartnerRawResponse {
id: string;
name: string;
role: string;
partner: ISummary;
account: {
username: string;
};
}
export interface IPartnerResponse extends IPartnerRawResponse {}
export interface IPartnerInfoRawResponse extends ISummary {}
export interface IPartnerInfoResponse extends IPartnerInfoRawResponse {}
@@ -6,6 +6,7 @@
[showDetails]="true"
[loading]="loading()"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
@if (selectedItemForEdit()) {
@@ -1,15 +1,10 @@
<app-page-data-list
pageTitle="مدیریت حساب‌های کاربری"
[addNewCtaLabel]="'افزودن حساب کاربری جدید'"
pageTitle="حساب‌های کاربری"
[columns]="columns"
[showAdd]="true"
emptyPlaceholderTitle="حساب کاربری‌ای یافت نشد."
emptyPlaceholderDescription="برای افزودن حساب کاربری جدید، روی دکمهٔ بالا کلیک کنید."
[items]="items()"
[loading]="loading()"
[showDetails]="true"
[showAdd]="true"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
>
</app-page-data-list>
<partner-consumer-account-form
@@ -10,6 +10,17 @@
<app-input label="عنوان" [control]="form.controls.name" name="name" />
<app-input label="کد اقتصادی" [control]="form.controls.economic_code" name="economic_code" />
<catalog-guild-select label="صنف" [control]="form.controls.guild_id" name="guild_id" />
@if (!editMode) {
<p-divider align="center"> اطلاعات لایسنس </p-divider>
<uikit-datepicker
label="تاریخ شروع لایسنس"
[control]="form.controls.license_starts_at"
name="license_starts_at"
hint="مدت زمان لایسنس‌ها ۱ ساله هستند."
/>
}
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
</form>
</p-dialog>
@@ -1,11 +1,14 @@
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
import { MustMatch } from '@/core/validators';
import { AbstractFormDialog } from '@/shared/abstractClasses';
import { CatalogGuildSelectComponent } from '@/shared/catalog/guild/components/select.component';
import { InputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { UikitFlatpickrJalaliComponent } from '@/uikit';
import { Component, inject, Input } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { Divider } from 'primeng/divider';
import { IBusinessActivityRequest, IBusinessActivityResponse } from '../../models';
import { PartnerConsumerBusinessActivitiesService } from '../../services/businessActivities.service';
@@ -18,6 +21,8 @@ import { PartnerConsumerBusinessActivitiesService } from '../../services/busines
InputComponent,
FormFooterActionsComponent,
CatalogGuildSelectComponent,
Divider,
UikitFlatpickrJalaliComponent,
],
})
export class ConsumerBusinessActivitiesFormComponent extends AbstractFormDialog<
@@ -30,11 +35,28 @@ export class ConsumerBusinessActivitiesFormComponent extends AbstractFormDialog<
@Input() businessActivityId!: string;
initForm = () => {
return this.fb.group({
const form = this.fb.group({
name: [this.initialValues?.name || '', [Validators.required]],
economic_code: [this.initialValues?.economic_code || '', [Validators.required]],
guild_id: [this.initialValues?.guild?.id || '', [Validators.required]],
license_starts_at: [''],
});
if (this.editMode) {
// @ts-ignore
form.removeControl('license_starts_at');
} else {
form.addControl(
'license_starts_at',
this.fb.control<string>('', {
nonNullable: true,
validators: [Validators.required],
}),
);
form.addValidators([MustMatch('password', 'confirmPassword')]);
}
return form;
};
form = this.initForm();
@@ -48,10 +70,11 @@ export class ConsumerBusinessActivitiesFormComponent extends AbstractFormDialog<
}
submitForm() {
const formValue = this.form.value as IBusinessActivityRequest;
const formValue = this.form.value as IBusinessActivityRequest & { confirmPassword?: string };
const { confirmPassword, ...rest } = formValue;
if (this.editMode) {
return this.service.update(this.consumerId, this.businessActivityId, formValue);
return this.service.update(this.consumerId, this.businessActivityId, rest);
}
return this.service.create(this.consumerId, formValue);
return this.service.create(this.consumerId, rest);
}
}
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<partner-consumer-businessActivities-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<partner-consumer-complex-form
@@ -10,7 +10,14 @@
<app-input label="عنوان" [control]="form.controls.name" name="name" />
<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_number" name="serial_number" />
<catalog-device-select [control]="form.controls.device_id" />
<catalog-provider-select [control]="form.controls.provider_id" />
}
@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
@@ -18,7 +25,7 @@
name="password"
formControlName="password"
autocomplete="new-password"
styleClass="w-full"
inputStyleClass="w-full"
[toggleMask]="true"
[feedback]="false"
[invalid]="form.controls.password.touched && form.controls.password.invalid"
@@ -31,7 +38,7 @@
name="confirmPassword"
formControlName="confirmPassword"
autocomplete="new-password"
styleClass="w-full"
inputStyleClass="w-full"
[toggleMask]="true"
[feedback]="false"
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
@@ -39,11 +46,6 @@
</uikit-field>
}
@if (form.controls.pos_type.value === "PSP") {
<app-input label="سریال دستگاه" [control]="form.controls.serial_number" name="serial_number" />
<catalog-device-select [control]="form.controls.device_id" />
<catalog-provider-select [control]="form.controls.provider_id" />
}
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
</form>
</p-dialog>
@@ -10,6 +10,7 @@ import { UikitFieldComponent } from '@/uikit';
import { Component, 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 { IPosRequest, IPosResponse } from '../../models';
import { PartnerPosesService } from '../../services/poses.service';
@@ -27,6 +28,7 @@ import { PartnerPosesService } from '../../services/poses.service';
EnumSelectComponent,
UikitFieldComponent,
Password,
Divider,
],
})
export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IPosResponse> {
@@ -2,17 +2,16 @@
pageTitle="مدیریت پایانه‌های فروش"
[addNewCtaLabel]="'افزودن پایانه‌ی فروش جدید'"
[columns]="columns"
[showAdd]="true"
emptyPlaceholderTitle="پایانه‌ی فروشی یافت نشد."
emptyPlaceholderDescription="برای افزودن پایانه‌ی فروش جدید، روی دکمهٔ بالا کلیک کنید."
[items]="items()"
[loading]="loading()"
[showDetails]="true"
[showAdd]="true"
[showEdit]="true"
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<partner-consumer-pos-form
@@ -24,21 +24,27 @@ export class ConsumerPosesComponent extends AbstractList<IPosResponse> {
@Input() header: IColumn[] = [
{ field: 'id', header: 'شناسه', type: 'id' },
{ field: 'name', header: 'عنوان' },
{ field: 'serial_number', header: 'شماره سریال' },
{ field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
{ field: 'pos_type', header: 'نوع دستگاه' },
// { field: 'serial_number', header: 'شماره سریال' },
// { field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
{ field: 'pos_type', header: 'نوع پایانه' },
{
field: 'provider',
header: 'ارایه‌دهنده',
field: 'account',
header: 'کاربر',
type: 'nested',
nestedOption: { path: 'provider.name' },
},
{ field: 'status', header: 'وضعیت' },
{
field: 'created_at',
header: 'تاریخ ایجاد',
type: 'date',
nestedOption: { path: 'account.username' },
},
// {
// field: 'provider',
// header: 'ارایه‌دهنده',
// type: 'nested',
// nestedOption: { path: 'provider.name' },
// },
// { field: 'status', header: 'وضعیت' },
// {
// field: 'created_at',
// header: 'تاریخ ایجاد',
// type: 'date',
// },
];
private readonly service = inject(PartnerPosesService);
@@ -14,6 +14,8 @@ export interface IBusinessActivityRequest {
name: string;
economic_code: string;
guild_id: string;
username?: string;
password?: string;
}
interface LicenseInfo {
@@ -10,6 +10,9 @@ export interface IPosRawResponse {
complex: ISummary;
device?: ISummary;
provider?: ISummary;
account: {
username: string;
};
}
export interface IPosResponse extends IPosRawResponse {}
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onDetails)="toSinglePage($event)"
(onEdit)="onEditClick($event)"
(onRefresh)="refresh()"
/>
<partner-consumer-form
[(visible)]="visibleForm"
@@ -1,7 +1,6 @@
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import { formatJalali } from '@/utils';
import { Component, inject } from '@angular/core';
import { Router } from '@angular/router';
import { ConsumerUserFormComponent } from '../components/form.component';
@@ -23,17 +22,18 @@ export class ConsumersComponent extends AbstractList<IConsumerResponse> {
{ field: 'id', header: 'شناسه', type: 'id' },
{ field: 'fullname', header: 'نام' },
{ field: 'mobile_number', header: 'شماره موبایل' },
{ field: 'status', header: 'وضعیت' },
{
field: 'license_expires_at',
header: 'تاریخ انقضای لایسنس',
customDataModel(item) {
if (item.license_info) {
return formatJalali(item.license_info.expires_at);
}
return 'بدون لایسنس';
},
},
{ field: 'national_code', header: 'کد ملی' },
// { field: 'status', header: 'وضعیت' },
// {
// field: 'license_expires_at',
// header: 'تاریخ انقضای لایسنس',
// customDataModel(item) {
// if (item.license_info) {
// return formatJalali(item.license_info.expires_at);
// }
// return 'بدون لایسنس';
// },
// },
{
field: 'created_at',
header: 'تاریخ ایجاد',
@@ -8,4 +8,5 @@
[showDetails]="true"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
@@ -0,0 +1,42 @@
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
import { IPartnerInfoResponse } from '@/domains/partner/models';
import { PartnerService } from '@/domains/partner/services/main.service';
import { LayoutService } from '@/layout/service/layout.service';
import { inject, Injectable } from '@angular/core';
import { catchError, finalize } from 'rxjs';
interface PartnerInfoState extends EntityState<IPartnerInfoResponse> {}
@Injectable({
providedIn: 'root',
})
export class PartnerInfoStore extends EntityStore<IPartnerInfoResponse, PartnerInfoState> {
private readonly service = inject(PartnerService);
private readonly layoutService = inject(LayoutService);
constructor() {
super(defaultBaseStateData);
}
getData() {
this.patchState({ loading: true });
this.service
.getInfo()
.pipe(
finalize(() => {
this.patchState({ loading: false });
}),
catchError((error) => {
this.setError(error);
throw error;
}),
)
.subscribe((entity) => {
this.setEntity(entity);
});
}
override reset(): void {
this.setState({ ...defaultBaseStateData });
}
}
@@ -1,7 +1,18 @@
import { Component } from '@angular/core';
import { Component, computed, inject } from '@angular/core';
import { PartnerInfoStore } from '../store/main.store';
@Component({
selector: 'partner-dashboard',
templateUrl: './index.component.html',
})
export class DashboardComponent {}
export class DashboardComponent {
private readonly store = inject(PartnerInfoStore);
readonly loading = computed(() => this.store.loading());
readonly entity = computed(() => this.store.entity());
readonly error = computed(() => this.store.error());
ngOnInit() {
this.store.getData();
}
}
@@ -2,7 +2,12 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { PARTNER_API_ROUTES } from '../constants';
import { IPartnerInfoRawResponse, IPartnerInfoResponse } from '../models';
import {
IPartnerInfoRawResponse,
IPartnerInfoResponse,
IPartnerRawResponse,
IPartnerResponse,
} from '../models';
@Injectable({ providedIn: 'root' })
export class PartnerService {
@@ -10,6 +15,10 @@ export class PartnerService {
private apiRoutes = PARTNER_API_ROUTES;
getMe(): Observable<IPartnerResponse> {
return this.http.get<IPartnerRawResponse>(this.apiRoutes.me());
}
getInfo(): Observable<IPartnerInfoResponse> {
return this.http.get<IPartnerInfoRawResponse>(this.apiRoutes.info());
}
+5 -5
View File
@@ -2,15 +2,15 @@ import { EntityState, EntityStore } from '@/core/state';
import { LayoutService } from '@/layout/service/layout.service';
import { inject, Injectable } from '@angular/core';
import { catchError, finalize } from 'rxjs';
import { IPartnerInfoResponse } from '../models';
import { IPartnerResponse } from '../models';
import { PartnerService } from '../services/main.service';
interface PartnerState extends EntityState<IPartnerInfoResponse> {}
interface PartnerState extends EntityState<IPartnerResponse> {}
@Injectable({
providedIn: 'root',
})
export class PartnerStore extends EntityStore<IPartnerInfoResponse, PartnerState> {
export class PartnerStore extends EntityStore<IPartnerResponse, PartnerState> {
private readonly service = inject(PartnerService);
private readonly layoutService = inject(LayoutService);
@@ -27,7 +27,7 @@ export class PartnerStore extends EntityStore<IPartnerInfoResponse, PartnerState
getData() {
this.patchState({ loading: true });
this.service
.getInfo()
.getMe()
.pipe(
finalize(() => {
this.patchState({ loading: false });
@@ -39,7 +39,7 @@ export class PartnerStore extends EntityStore<IPartnerInfoResponse, PartnerState
)
.subscribe((entity) => {
this.layoutService.setPanelInfo({
title: `پنل مدیریتی ${entity.name}`,
title: `پنل مدیریتی ${entity.partner.name}`,
});
this.setEntity(entity);
});
@@ -10,6 +10,7 @@
[showDetails]="true"
[showAdd]="true"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-consumer-account-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-consumer-businessActivities-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-consumer-complex-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-consumer-pos-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onDetails)="toSinglePage($event)"
(onEdit)="onEditClick($event)"
(onRefresh)="refresh()"
/>
<superAdmin-consumer-form
[(visible)]="visibleForm"
@@ -11,6 +11,7 @@
[showEdit]="true"
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onRefresh)="refresh()"
/>
<deviceBrand-form
[(visible)]="visibleForm"
@@ -11,6 +11,7 @@
[showEdit]="true"
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onRefresh)="refresh()"
/>
<superAdmin-device-form
[(visible)]="visibleForm"
@@ -13,6 +13,7 @@
[fullHeight]="fullHeight"
(onEdit)="onEditClick($event)"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
/>
<admin-guild-good-categories-form
@@ -12,6 +12,7 @@
[fullHeight]="fullHeight"
(onEdit)="onEditClick($event)"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
/>
<admin-guild-good-form
[guildId]="guildId"
@@ -11,5 +11,6 @@
[showAdd]="true"
(onAdd)="openAddForm()"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
<admin-guild-form [(visible)]="visibleForm" (onSubmit)="refresh()" />
@@ -4,6 +4,7 @@
emptyPlaceholderTitle="لایسنسی یافت نشد"
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
>
<!-- <ng-template #role let-data>
<catalog-role-tag [role]="data.role" />
@@ -2,14 +2,12 @@
pageTitle="مدیریت حساب‌های کاربری"
[addNewCtaLabel]="'افزودن حساب کاربری جدید'"
[columns]="columns"
[showAdd]="true"
emptyPlaceholderTitle="حساب کاربری‌ای یافت نشد."
emptyPlaceholderDescription="برای افزودن حساب کاربری جدید، روی دکمهٔ بالا کلیک کنید."
[items]="items()"
[loading]="loading()"
[showDetails]="true"
[showAdd]="true"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-partner-account-form
@@ -4,5 +4,6 @@
emptyPlaceholderTitle="تا به حال شارژ کاربری انجام نشده‌ است"
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
>
</app-page-data-list>
@@ -4,6 +4,7 @@
emptyPlaceholderTitle="تا به حال شارژ لایسنسی انجام نشده‌ است"
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
>
<!-- <ng-template #role let-data>
<catalog-role-tag [role]="data.role" />
@@ -1,9 +1,10 @@
<app-page-data-list
pageTitle="لیست لایسنس‌های فروخته شده"
[columns]="columns"
emptyPlaceholderTitle="تا به حال توسط این شریک تجاری لایسنسی فروخته نشده‌ است"
emptyPlaceholderTitle="تا به حال لایسنسی فروخته نشده‌ است"
[items]="items()"
[loading]="loading()"
(onRefresh)="refresh()"
>
<!-- <ng-template #role let-data>
<catalog-role-tag [role]="data.role" />
@@ -2,13 +2,14 @@
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject, Input } from '@angular/core';
import { ButtonDirective } from 'primeng/button';
import { IPartnerActivatedLicenseResponse } from '../../models';
import { AdminPartnerActivatedLicensesService } from '../../services/licenses.service';
@Component({
selector: 'admin-partner-licenses',
templateUrl: './list.component.html',
imports: [PageDataListComponent],
imports: [PageDataListComponent, ButtonDirective],
})
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivatedLicenseResponse> {
@Input({ required: true }) partnerId!: string;
@@ -25,6 +26,12 @@ export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivate
return `${item.business_activity.consumer.first_name} ${item.business_activity.consumer.last_name} (${item.business_activity.name})`;
},
},
{
field: 'license',
header: 'تعداد کاربر قابل تعریف',
type: 'nested',
nestedOption: { path: 'license.accounts_limit' },
},
{ field: 'expires_at', header: 'تاریخ انقضا', type: 'date' },
];
}
@@ -14,6 +14,11 @@ export interface IPartnerRawResponse {
used: number;
expired: number;
};
license_renew_status: {
total: number;
used: number;
expired: number;
};
}
export interface IPartnerResponse extends IPartnerRawResponse {}
@@ -13,15 +13,24 @@
(onAdd)="openAddForm()"
(onDetails)="toSinglePage($event)"
(onEdit)="onEditClick($event)"
(onRefresh)="refresh()"
>
<ng-template #licensesStatus let-item>
<span class="font-bold">
{{ item.licenses_status.total }}
@if (item.licenses_status.used) {
<small class="small text-muted-color font-normal"> ({{ item.licenses_status.used }} عدد استفاده شده) </small>
} @else {
<small class="small text-muted-color font-normal"> (تمامی لایسنس‌ها فعال می‌باشند) </small>
}
<small class="small text-muted-color font-normal"> ({{ item.licenses_status.used }} عدد استفاده شده) </small>
</span>
</ng-template>
<ng-template #accountQuotaStatus let-item>
<span class="font-bold">
{{ item.account_quota_status.total }}
<small class="small text-muted-color font-normal"> ({{ item.account_quota_status.used }} عدد استفاده شده) </small>
</span>
</ng-template>
<ng-template #licensesRenewStatus let-item>
<span class="font-bold">
{{ item.license_renew_status.total }}
<small class="small text-muted-color font-normal"> ({{ item.license_renew_status.used }} عدد استفاده شده) </small>
</span>
</ng-template>
</app-page-data-list>
@@ -18,18 +18,25 @@ export class PartnersComponent extends AbstractList<IPartnerResponse> {
private readonly router = inject(Router);
@ViewChild('licensesStatus', { static: true }) licensesStatus!: TemplateRef<any>;
@ViewChild('accountQuotaStatus', { static: true }) accountQuotaStatus!: TemplateRef<any>;
@ViewChild('licensesRenewStatus', { static: true }) licensesRenewStatus!: TemplateRef<any>;
override setColumns(): void {
this.columns = [
{ field: 'name', header: 'نام' },
{ field: 'code', header: 'کد' },
{ field: 'licenses', header: 'وضعیت لایسنس‌ها', customDataModel: this.licensesStatus },
{ field: 'status', header: 'وضعیت' },
{ field: 'licenses', header: 'تعداد لایسنس‌ها', customDataModel: this.licensesStatus },
{
field: 'created_at',
header: اریخ ایجاد',
type: 'date',
field: 'account_quota',
header: عداد کاربرهای خریداری شده',
customDataModel: this.accountQuotaStatus,
},
{
field: 'license_renew',
header: 'تعداد لایسنس‌های تمدیدی',
customDataModel: this.licensesRenewStatus,
},
{ field: 'status', header: 'وضعیت' },
];
}
@@ -32,6 +32,18 @@
(partner()?.account_quota_status?.expired || 0)
"
/>
<p-divider align="center" class="col-span-3">اطلاعات تمدید لایسنس‌ها</p-divider>
<app-key-value label="تعداد کاربران خریداری شده" [value]="partner()?.license_renew_status?.total" />
<app-key-value label="تعداد کاربران منقضی شده" [value]="partner()?.license_renew_status?.expired" />
<app-key-value label="تعداد کاربران فروخته شده" [value]="partner()?.license_renew_status?.used" />
<app-key-value
label="تعداد کاربران باقی‌مانده"
[value]="
(partner()?.license_renew_status?.total || 0) -
(partner()?.license_renew_status?.used || 0) -
(partner()?.license_renew_status?.expired || 0)
"
/>
</div>
</div>
</app-card-data>
@@ -10,6 +10,7 @@
[showDetails]="true"
[showAdd]="true"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
/>
<provider-form
[(visible)]="visibleForm"
@@ -10,6 +10,7 @@
[showDetails]="true"
[showAdd]="true"
(onAdd)="openAddForm()"
(onRefresh)="refresh()"
>
</app-page-data-list>
<superAdmin-user-account-form
@@ -13,6 +13,7 @@
(onAdd)="openAddForm()"
(onEdit)="onEditClick($event)"
(onDetails)="toSinglePage($event)"
(onRefresh)="refresh()"
/>
<superAdmin-user-form
[(visible)]="visibleForm"
@@ -28,7 +28,9 @@ export class AppTopbar {
}
username = computed(() => this.authService.currentAccount()?.username || 'کاربر ناشناس');
panelTitle = computed(() => this.layoutService.panelInfo()?.title || 'پنل مدیریت کسب‌وکار');
panelTitle = computed(
() => this.layoutService.panelInfo()?.title || 'پنل مدیریت صورت‌حساب‌های مالیاتی',
);
logout = () => {
this.authService.logout();
+1 -1
View File
@@ -64,7 +64,7 @@ export class LayoutService {
public menuItems = signal<MenuItem[]>([]);
public panelInfo = signal<IPanelInfo>({
title: 'پنل مدیریت کسب‌و‌کار',
title: 'پنل مدیریت صورت‌حساب‌های مالیاتی',
});
menuSource$ = this.menuSource.asObservable();
@@ -7,8 +7,8 @@
class="flex flex-col items-center justify-center px-12 py-10 h-auto bg-surface-card border border-surface-border rounded-lg shadow w-full max-w-md"
>
<div class="flex flex-col gap-4 text-center mb-10 items-center justify-center">
<img [src]="logo" alt="مدیریت کسب‌وکار" class="w-20 h-auto" />
<span class="text-lg font-bold"> به پنل مدیریت کسب‌وکار خوش آمدید. </span>
<img [src]="logo" alt="مدیریت صورت‌حساب‌های مالیاتی" class="w-20 h-auto" />
<span class="text-lg font-bold"> به پنل مدیریت صورت‌حساب‌های مالیاتی خوش آمدید. </span>
</div>
<!-- @if (activeStep() === "login") { -->
@@ -2,7 +2,7 @@
<div class="flex flex-col items-center justify-center">
<div class="mb-10 flex flex-col gap-5 items-center">
<img [src]="logo" width="80" />
<span class="text-2xl font-semibold text-surface-900 dark:text-surface-0">مدیریت کسب‌وکار</span>
<span class="text-2xl font-semibold text-surface-900 dark:text-surface-0">مدیریت صورت‌حساب‌های مالیاتی</span>
</div>
<div
style="
@@ -13,12 +13,12 @@
class="grow flex! flex-col overflow-hidden"
[tableStyleClass]="!items.length && !loading ? 'h-full' : ''"
>
@if (pageTitle || showAdd || filter || caption) {
@if (pageTitle || showAdd || filter || caption || showRefresh || moreActions) {
<ng-template pTemplate="caption">
<ng-container [ngTemplateOutlet]="caption">
<div class="flex justify-between items-center gap-4">
<h5 class="font-bold">{{ pageTitle }}</h5>
@if (showAdd || filter || moreActions) {
@if (showAdd || filter || showRefresh || moreActions) {
<div class="flex items-center gap-2">
<ng-container [ngTemplateOutlet]="moreActions" />
@if (filter) {
@@ -31,6 +31,9 @@
(click)="openFilter()"
></p-button>
}
@if (showRefresh) {
<p-button icon="pi pi-refresh" outlined (click)="refresh()"></p-button>
}
@if (showAdd) {
<p-button label="{{ addNewCtaLabel }}" icon="pi pi-plus" (click)="openAddForm()"></p-button>
}
@@ -89,6 +89,7 @@ export class PageDataListComponent<I> {
@Input() showDelete: boolean = false;
@Input() showDetails: boolean = false;
@Input() showAdd: boolean = false;
@Input() showRefresh: boolean = true;
@Input() isFiltered: boolean = false;
@Input() fullHeight?: boolean = false;
@Input() height: string = '';
@@ -108,6 +109,7 @@ export class PageDataListComponent<I> {
@Output() onAdd = new EventEmitter<void>();
@Output() pageChange = new EventEmitter<any>();
@Output() onThumbnailClick = new EventEmitter<I>();
@Output() onRefresh = new EventEmitter();
filterDrawerVisible = signal<boolean>(false);
expandedRows: { [key: string]: boolean } = {};
@@ -258,4 +260,8 @@ export class PageDataListComponent<I> {
if (this.showDetails) totalCount += 1;
return totalCount;
});
refresh() {
this.onRefresh.emit();
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8" />
<title>pos</title>
<title>پنل مدیریت صورت‌حساب‌های مالیاتی</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />