feat: Refactor sale invoice store to use new response model and improve state management
fix: Update single component to correctly bind invoice data feat: Enhance partner info model with detailed license status refactor: Simplify account list component by removing unnecessary details fix: Correctly reference username in consumer account form feat: Add POS related fields to consumer account list chore: Update models to include charge account details for partners feat: Implement charge account dialog for partner consumers feat: Create API routes for accounts charge functionality feat: Add charge account service for handling requests feat: Introduce license info template component for dashboard refactor: Update dashboard view to display license information fix: Improve layout component to handle POS information more effectively chore: Clean up unused imports and components in various files feat: Add loading state handling in landing views feat: Implement charge account form dialog for partner consumers
This commit is contained in:
+15
-1
@@ -10,5 +10,19 @@ export interface IPartnerRawResponse {
|
||||
}
|
||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||
|
||||
export interface IPartnerInfoRawResponse extends ISummary {}
|
||||
export interface IPartnerInfoRawResponse {
|
||||
licenses_status: LicensesStatus;
|
||||
license_renews_status: LicensesStatus;
|
||||
account_quotas_status: LicensesStatus;
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
created_at: string;
|
||||
}
|
||||
export interface IPartnerInfoResponse extends IPartnerInfoRawResponse {}
|
||||
|
||||
interface LicensesStatus {
|
||||
total_purchased: number;
|
||||
total_activated: number;
|
||||
total_expired: number;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="حساب کاربریای یافت نشد"
|
||||
[items]="items()"
|
||||
[showDetails]="true"
|
||||
[loading]="loading()"
|
||||
(onDetails)="toSinglePage($event)"
|
||||
(onRefresh)="refresh()"
|
||||
/>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class ConsumerAccountFormComponent extends AbstractFormDialog<
|
||||
if (this.editMode) {
|
||||
return this.fb.group(
|
||||
{
|
||||
username: [this.initialValues?.username || '', [Validators.required]],
|
||||
username: [this.initialValues?.account.username || '', [Validators.required]],
|
||||
password: ['', [password()]],
|
||||
confirmPassword: [''],
|
||||
},
|
||||
@@ -49,7 +49,7 @@ export class ConsumerAccountFormComponent extends AbstractFormDialog<
|
||||
}
|
||||
return this.fb.group(
|
||||
{
|
||||
username: [this.initialValues?.username || '', [Validators.required]],
|
||||
username: [this.initialValues?.account.username || '', [Validators.required]],
|
||||
role: ['', [Validators.required]],
|
||||
password: ['', [Validators.required, password()]],
|
||||
confirmPassword: ['', [Validators.required]],
|
||||
|
||||
@@ -26,17 +26,27 @@ export class ConsumerAccountListComponent extends AbstractList<IConsumerAccountR
|
||||
nestedOption: { path: 'account.username' },
|
||||
},
|
||||
{ field: 'role', header: 'نوع حساب' },
|
||||
{
|
||||
field: 'pos',
|
||||
header: 'پایانهی مرتبط',
|
||||
customDataModel(item: IConsumerAccountResponse) {
|
||||
if (item.pos) {
|
||||
return `${item.pos.name} (${item.pos.complex.name} - ${item.pos.complex.business_activity.name})`;
|
||||
}
|
||||
return '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
header: 'وضعیت',
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'account.status' },
|
||||
},
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
type: 'date',
|
||||
},
|
||||
// {
|
||||
// field: 'created_at',
|
||||
// header: 'تاریخ ایجاد',
|
||||
// type: 'date',
|
||||
// },
|
||||
];
|
||||
private readonly service = inject(PartnerConsumerAccountsService);
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<p-dialog
|
||||
header="شارژ کاربر"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
[style]="{ width: '300px' }"
|
||||
[closable]="true"
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="تعداد شارژ کاربران" [control]="form.controls.quantity" type="number" [min]="1" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { IPartnerChargeAccountRequest } from '../../models';
|
||||
import { PartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-charge-account-form-dialog',
|
||||
templateUrl: './charge-account-form-dialog.component.html',
|
||||
imports: [Dialog, ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
|
||||
})
|
||||
export class PartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
IPartnerChargeAccountRequest,
|
||||
any
|
||||
> {
|
||||
@Input({ required: true }) consumerId!: string;
|
||||
@Input({ required: true }) businessId!: string;
|
||||
|
||||
private readonly service = inject(PartnerChargeAccountService);
|
||||
|
||||
form = this.fb.group({
|
||||
quantity: [0, [Validators.required, Validators.min(1)]],
|
||||
});
|
||||
|
||||
submitForm(payload: IPartnerChargeAccountRequest) {
|
||||
return this.service.charge(this.consumerId, this.businessId, payload);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
const baseUrl = (consumerId: string, businessId: string) =>
|
||||
`/api/v1/partner/consumers/${consumerId}/business-activities/${businessId}/accounts-charge`;
|
||||
|
||||
export const PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES = {
|
||||
single: (consumerId: string, businessId: string) => `${baseUrl(consumerId, businessId)}`,
|
||||
};
|
||||
@@ -1,8 +1,12 @@
|
||||
import { TAccountType } from '@/core/constants/accountTypes.const';
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface IConsumerAccountRawResponse {
|
||||
username: string;
|
||||
id: string;
|
||||
role: string;
|
||||
created_at: string;
|
||||
pos: Pos;
|
||||
account: Account;
|
||||
}
|
||||
export interface IConsumerAccountResponse extends IConsumerAccountRawResponse {}
|
||||
|
||||
@@ -11,3 +15,17 @@ export interface IConsumerAccountRequest {
|
||||
password?: string;
|
||||
type: TAccountType;
|
||||
}
|
||||
|
||||
interface Account {
|
||||
username: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface Pos extends ISummary {
|
||||
complex: Complex;
|
||||
}
|
||||
|
||||
interface Complex extends ISummary {
|
||||
branch_code: string;
|
||||
business_activity: ISummary;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface IPartnerChargeAccountRawResponse {
|
||||
id: string;
|
||||
created_at: string;
|
||||
// tracking_code: string;
|
||||
// activation_expires_at: string;
|
||||
// charged_license_count: number;
|
||||
// activated_license_count: number;
|
||||
// remained_license_count: number;
|
||||
}
|
||||
|
||||
export interface IPartnerChargeAccountResponse extends IPartnerChargeAccountRawResponse {}
|
||||
|
||||
export interface IPartnerChargeAccountRequest {
|
||||
quantity: number;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './accounts_io';
|
||||
export * from './businessActivities_io';
|
||||
export * from './chargeAccount_io';
|
||||
export * from './complexes_io';
|
||||
export * from './io';
|
||||
export * from './licenses_io';
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES } from '../constants/apiRoutes/accountsCharge';
|
||||
import { IPartnerChargeAccountRequest } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PartnerChargeAccountService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = PARTNER_BA_ACCOUNTS_CHARGE_API_ROUTES;
|
||||
|
||||
// getAll(consumerId: string, businessId: string): Observable<IPaginatedResponse<IPartnerChargeAccountRequest>> {
|
||||
// return this.http.get<IPaginatedResponse<IPartnerChargeAccountRequest>>(
|
||||
// this.apiRoutes.single(partnerId),
|
||||
// );
|
||||
// }
|
||||
|
||||
charge(
|
||||
consumerId: string,
|
||||
businessId: string,
|
||||
data: IPartnerChargeAccountRequest,
|
||||
): Observable<IPartnerChargeAccountRequest> {
|
||||
return this.http.post<IPartnerChargeAccountRequest>(
|
||||
this.apiRoutes.single(consumerId, businessId),
|
||||
data,
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -1,5 +1,8 @@
|
||||
<div class="flex flex-col gap-6">
|
||||
<app-card-data cardTitle="اطلاعات فعالیت اقتصادی" [editable]="true" [(editMode)]="editMode">
|
||||
<ng-template #moreActions>
|
||||
<button pButton outlined (click)="showAccountsChargeDialog()">افزایش محدودیت کاربر</button>
|
||||
</ng-template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="عنوان" [value]="businessActivity()?.name" />
|
||||
@@ -21,4 +24,11 @@
|
||||
[initialValues]="businessActivity() || undefined"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
<partner-charge-account-form-dialog
|
||||
[(visible)]="visibleAccountsChargeForm"
|
||||
[consumerId]="consumerId()"
|
||||
[businessId]="businessId()"
|
||||
(onSubmit)="getData()"
|
||||
>
|
||||
</partner-charge-account-form-dialog>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,9 @@ import pageParamsUtils from '@/utils/page-params.utils';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { ConsumerBusinessActivitiesFormComponent } from '../../components/businessActivities/form.component';
|
||||
import { PartnerChargeAccountFormDialogComponent } from '../../components/chargeAccount/charge-account-form-dialog.component';
|
||||
import { ConsumerComplexesComponent } from '../../components/complexes/list.component';
|
||||
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||
import { ConsumerStore } from '../../store/consumer.store';
|
||||
@@ -17,6 +19,8 @@ import { ConsumerStore } from '../../store/consumer.store';
|
||||
KeyValueComponent,
|
||||
ConsumerBusinessActivitiesFormComponent,
|
||||
ConsumerComplexesComponent,
|
||||
ButtonDirective,
|
||||
PartnerChargeAccountFormDialogComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerUserBusinessActivityComponent {
|
||||
@@ -30,6 +34,7 @@ export class PartnerUserBusinessActivityComponent {
|
||||
readonly consumerId = signal<string>(this.pageParams()['consumerId']!);
|
||||
readonly businessId = signal<string>(this.pageParams()['businessActivityId']!);
|
||||
editMode = signal<boolean>(false);
|
||||
visibleAccountsChargeForm = signal<boolean>(false);
|
||||
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly businessActivity = computed(() => this.store.entity());
|
||||
@@ -52,4 +57,8 @@ export class PartnerUserBusinessActivityComponent {
|
||||
...this.store.breadcrumbItems(),
|
||||
]);
|
||||
}
|
||||
|
||||
showAccountsChargeDialog() {
|
||||
this.visibleAccountsChargeForm.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { BreadcrumbService } from '@/core/services';
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { JalaliDateDirective } from '@/shared/directives';
|
||||
import { getLicenseStatus } from '@/utils';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Button } from 'primeng/button';
|
||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||
import { ConsumerBusinessActivitiesComponent } from '../components/businessActivities/list.component';
|
||||
import { ConsumerUserFormComponent } from '../components/form.component';
|
||||
import { ConsumerLicenseFormComponent } from '../components/licenses/form.component';
|
||||
import { ConsumerStore } from '../store/consumer.store';
|
||||
|
||||
@Component({
|
||||
@@ -20,9 +17,6 @@ import { ConsumerStore } from '../store/consumer.store';
|
||||
ConsumerUserFormComponent,
|
||||
ConsumerAccountListComponent,
|
||||
ConsumerBusinessActivitiesComponent,
|
||||
Button,
|
||||
JalaliDateDirective,
|
||||
ConsumerLicenseFormComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerComponent {
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<p-card class="border border-surface-border bg-surface-card rounded-2xl p-4 text-text-color">
|
||||
<div class="text-center w-full flex items-center justify-center gap-1">
|
||||
<span class="text-xl font-semibold">وضعیت {{ title }}</span>
|
||||
</div>
|
||||
<hr class="mb-6!" />
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">فروخته شده</span>
|
||||
<span class="text-lg font-semibold">{{ activated }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">منقضی شده</span>
|
||||
<span class="text-lg font-semibold">{{ expired }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 items-center justify-center">
|
||||
<span class="text-sm text-muted-color">قابل فروش</span>
|
||||
<span class="text-lg font-semibold">
|
||||
{{ remained }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</p-card>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Card } from 'primeng/card';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-license-info-template',
|
||||
templateUrl: './license-info-template.component.html',
|
||||
imports: [Card],
|
||||
})
|
||||
export class PartnerLicenseInfoTemplateComponent {
|
||||
@Input({ required: true }) title!: string;
|
||||
@Input({ required: true }) total!: number;
|
||||
@Input({ required: true }) activated!: number;
|
||||
@Input({ required: true }) expired!: number;
|
||||
@Input({ required: true }) remained!: number;
|
||||
constructor() {}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
|
||||
@@ -12,7 +11,6 @@ interface PartnerInfoState extends EntityState<IPartnerInfoResponse> {}
|
||||
})
|
||||
export class PartnerInfoStore extends EntityStore<IPartnerInfoResponse, PartnerInfoState> {
|
||||
private readonly service = inject(PartnerService);
|
||||
private readonly layoutService = inject(LayoutService);
|
||||
|
||||
constructor() {
|
||||
super(defaultBaseStateData);
|
||||
|
||||
@@ -1 +1,37 @@
|
||||
<div class="grid grid-cols-2 gap-10">به پنل مدیریتی شریک تجاری خوش آمدید.</div>
|
||||
<div class="grid grid-cols-3 w-full gap-4">
|
||||
<partner-license-info-template
|
||||
title="لایسنسها"
|
||||
[total]="entity()?.licenses_status?.total_purchased || 0"
|
||||
[expired]="entity()?.licenses_status?.total_expired || 0"
|
||||
[activated]="entity()?.licenses_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.licenses_status?.total_purchased || 0) -
|
||||
(entity()?.licenses_status?.total_activated || 0) -
|
||||
(entity()?.licenses_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
|
||||
<partner-license-info-template
|
||||
title="شارژ کاربران"
|
||||
[total]="entity()?.account_quotas_status?.total_purchased || 0"
|
||||
[expired]="entity()?.account_quotas_status?.total_expired || 0"
|
||||
[activated]="entity()?.account_quotas_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.account_quotas_status?.total_purchased || 0) -
|
||||
(entity()?.account_quotas_status?.total_activated || 0) -
|
||||
(entity()?.account_quotas_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
|
||||
<partner-license-info-template
|
||||
title="تمدید لایسنسها"
|
||||
[total]="entity()?.license_renews_status?.total_purchased || 0"
|
||||
[expired]="entity()?.license_renews_status?.total_expired || 0"
|
||||
[activated]="entity()?.license_renews_status?.total_activated || 0"
|
||||
[remained]="
|
||||
(entity()?.license_renews_status?.total_purchased || 0) -
|
||||
(entity()?.license_renews_status?.total_activated || 0) -
|
||||
(entity()?.license_renews_status?.total_expired || 0)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { PartnerLicenseInfoTemplateComponent } from '../components/licenseInfo/license-info-template.component';
|
||||
import { PartnerInfoStore } from '../store/main.store';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-dashboard',
|
||||
templateUrl: './index.component.html',
|
||||
imports: [PartnerLicenseInfoTemplateComponent],
|
||||
})
|
||||
export class DashboardComponent {
|
||||
private readonly store = inject(PartnerInfoStore);
|
||||
|
||||
Reference in New Issue
Block a user