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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user