feat(consumers): implement consumer and POS stores with breadcrumb management
- Added ConsumerStore and PosStore to manage state and data fetching for consumers and POS entities. - Implemented breadcrumb functionality in both stores to enhance navigation. - Created views for consumer accounts, business activities, complexes, and poses with respective components. - Developed single view components for detailed display and editing of consumer and POS data. - Introduced charge account management components in the super admin module, including forms and lists for charge transactions. - Established API routes and services for handling charge account transactions.
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
<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" />
|
||||
<uikit-datepicker
|
||||
label="انقضای فروش"
|
||||
[control]="form.controls.activated_expires_at"
|
||||
name="activated_expires_at"
|
||||
[minDate]="minDate"
|
||||
/>
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { UikitFlatpickrJalaliComponent } from '@/uikit';
|
||||
import { nowJalali } from '@/utils';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { IPartnerChargeAccountRequest } from '../../models/chargeAccount_io';
|
||||
import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-charge-account-form-dialog',
|
||||
templateUrl: './charge-account-form-dialog.component.html',
|
||||
imports: [
|
||||
Dialog,
|
||||
ReactiveFormsModule,
|
||||
InputComponent,
|
||||
FormFooterActionsComponent,
|
||||
UikitFlatpickrJalaliComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerChargeAccountFormDialogComponent extends AbstractFormDialog<
|
||||
IPartnerChargeAccountRequest,
|
||||
any
|
||||
> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(AdminPartnerChargeAccountService);
|
||||
|
||||
form = this.fb.group({
|
||||
quantity: [0, [Validators.required, Validators.min(1)]],
|
||||
activated_expires_at: ['', [Validators.required]],
|
||||
});
|
||||
|
||||
minDate = nowJalali();
|
||||
|
||||
submitForm(payload: IPartnerChargeAccountRequest) {
|
||||
return this.service.charge(this.partnerId, payload);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<app-page-data-list
|
||||
pageTitle="گزارش شارژهای ثبت شدهی کاربر"
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="تا به حال شارژ کاربری انجام نشده است"
|
||||
[items]="items()"
|
||||
[loading]="loading()"
|
||||
>
|
||||
</app-page-data-list>
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
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 { IPartnerChargeAccountRawResponse } from '../../models';
|
||||
import { AdminPartnerChargeAccountService } from '../../services/chargeAccount.service';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-partner-chargeAccount-list',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class AdminPartnerChargeAccountListComponent extends AbstractList<IPartnerChargeAccountRawResponse> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(AdminPartnerChargeAccountService);
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'tracking_code', header: 'کد پیگیری' },
|
||||
{ field: 'charged_license_count', header: 'تعداد شارژ کاربر' },
|
||||
{ field: 'remained_license_count', header: 'شارژ باقی مانده' },
|
||||
{
|
||||
field: 'activation_count',
|
||||
header: 'مقدار مصرف شده',
|
||||
},
|
||||
{
|
||||
field: 'activation_expires_at',
|
||||
header: 'تاریخ انقضا',
|
||||
type: 'date',
|
||||
dateOption: {
|
||||
expiredMode: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
type: 'date',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
override getDataRequest() {
|
||||
return this.service.getAll(this.partnerId);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ export class AdminPartnerChargeLicenseTransactionListComponent extends AbstractL
|
||||
{ field: 'charged_license_count', header: 'لایسنسهای خریداری شده' },
|
||||
{ field: 'remained_license_count', header: 'لایسنسهای باقیمانده' },
|
||||
{
|
||||
field: 'activated_license_count',
|
||||
field: 'activation_count',
|
||||
header: 'لایسنسهای فروخته شده',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@ export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivate
|
||||
{
|
||||
field: 'consumer',
|
||||
header: 'مشتری',
|
||||
customDataModel(item) {
|
||||
return `${item.consumer.first_name} ${item.consumer.last_name}`;
|
||||
customDataModel(item: IPartnerActivatedLicenseResponse) {
|
||||
return `${item.business_activity.consumer.first_name} ${item.business_activity.consumer.last_name} (${item.business_activity.name})`;
|
||||
},
|
||||
},
|
||||
{ field: 'expires_at', header: 'تاریخ انقضا', type: 'date' },
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
const baseUrl = (partnerId: string) =>
|
||||
`/api/v1/admin/partners/${partnerId}/charge-account-transactions`;
|
||||
|
||||
export const PARTNER_CHARGE_ACCOUNT_API_ROUTES = {
|
||||
single: (partnerId: string) => `${baseUrl(partnerId)}`,
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './accounts';
|
||||
export * from './activatedLicenses';
|
||||
export * from './chargeAccount';
|
||||
export * from './chargeLicenseTransactions';
|
||||
|
||||
const baseUrl = '/api/v1/admin/partners';
|
||||
@@ -7,5 +8,6 @@ const baseUrl = '/api/v1/admin/partners';
|
||||
export const PARTNERS_API_ROUTES = {
|
||||
list: () => `${baseUrl}`,
|
||||
single: (id: string) => `${baseUrl}/${id}`,
|
||||
accountCharge: (id: string) => `${baseUrl}/${id}/charge-account-transactions`,
|
||||
licenseCharge: (id: string) => `${baseUrl}/${id}/charge-license`,
|
||||
};
|
||||
|
||||
+13
-5
@@ -1,11 +1,19 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface IPartnerActivatedLicenseRawResponse {
|
||||
id: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
consumer: {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
mobile_number: string;
|
||||
};
|
||||
business_activity: BusinessActivity;
|
||||
}
|
||||
export interface IPartnerActivatedLicenseResponse extends IPartnerActivatedLicenseRawResponse {}
|
||||
|
||||
interface BusinessActivity extends ISummary {
|
||||
consumer: Consumer;
|
||||
}
|
||||
|
||||
interface Consumer {
|
||||
id: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
activated_expires_at: string;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './accounts_io';
|
||||
export * from './activatedLicenses_io';
|
||||
export * from './chargeAccount_io';
|
||||
export * from './chargeLicenseTransactions_io';
|
||||
export * from './io';
|
||||
|
||||
@@ -9,6 +9,11 @@ export interface IPartnerRawResponse {
|
||||
used: number;
|
||||
expired: number;
|
||||
};
|
||||
account_quota_status: {
|
||||
total: number;
|
||||
used: number;
|
||||
expired: number;
|
||||
};
|
||||
}
|
||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNER_CHARGE_ACCOUNT_API_ROUTES } from '../constants';
|
||||
import {
|
||||
IPartnerChargeAccountRawResponse,
|
||||
IPartnerChargeAccountRequest,
|
||||
IPartnerChargeAccountResponse,
|
||||
} from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AdminPartnerChargeAccountService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = PARTNER_CHARGE_ACCOUNT_API_ROUTES;
|
||||
|
||||
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerChargeAccountRawResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPartnerChargeAccountResponse>>(
|
||||
this.apiRoutes.single(partnerId),
|
||||
);
|
||||
}
|
||||
|
||||
charge(
|
||||
partnerId: string,
|
||||
data: IPartnerChargeAccountRequest,
|
||||
): Observable<IPartnerChargeAccountRawResponse> {
|
||||
return this.http.post<IPartnerChargeAccountResponse>(this.apiRoutes.single(partnerId), data);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<div class="flex flex-col gap-6">
|
||||
<app-card-data cardTitle="اطلاعات شریک تجاری" [editable]="true" [(editMode)]="editMode">
|
||||
<ng-template #moreActions>
|
||||
<p-button outlined size="small" (onClick)="openChargeAccountDialog()"> شارژ کاربر </p-button>
|
||||
<p-button outlined size="small" (onClick)="openChargeDialog()"> شارژ لایسنس </p-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]="partner()?.name" />
|
||||
<app-key-value label="کد شریک تجاری" [value]="partner()?.code" />
|
||||
<p-divider align="center" class="col-span-3">اطلاعات لایسنسها</p-divider>
|
||||
<app-key-value label="تعداد لایسنسهای خریداری شده" [value]="partner()?.licenses_status?.total" />
|
||||
<app-key-value label="تعداد لایسنسهای منقضی شده" [value]="partner()?.licenses_status?.expired" />
|
||||
<app-key-value label="تعداد لایسنسهای فروخته شده" [value]="partner()?.licenses_status?.used" />
|
||||
@@ -18,6 +20,18 @@
|
||||
(partner()?.licenses_status?.expired || 0)
|
||||
"
|
||||
/>
|
||||
<p-divider align="center" class="col-span-3">اطلاعات شارژ کاربران</p-divider>
|
||||
<app-key-value label="تعداد کاربران خریداری شده" [value]="partner()?.account_quota_status?.total" />
|
||||
<app-key-value label="تعداد کاربران منقضی شده" [value]="partner()?.account_quota_status?.expired" />
|
||||
<app-key-value label="تعداد کاربران فروخته شده" [value]="partner()?.account_quota_status?.used" />
|
||||
<app-key-value
|
||||
label="تعداد کاربران باقیمانده"
|
||||
[value]="
|
||||
(partner()?.account_quota_status?.total || 0) -
|
||||
(partner()?.account_quota_status?.used || 0) -
|
||||
(partner()?.account_quota_status?.expired || 0)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</app-card-data>
|
||||
@@ -30,6 +44,10 @@
|
||||
<admin-partner-chargeLicenseTransaction-list [partnerId]="partnerId()" class="w-full" />
|
||||
</div>
|
||||
|
||||
<div class="max-h-125 flex">
|
||||
<admin-partner-chargeAccount-list [partnerId]="partnerId()" class="w-full"></admin-partner-chargeAccount-list>
|
||||
</div>
|
||||
|
||||
<div class="max-h-125 flex">
|
||||
<superAdmin-partner-account-list [partnerId]="partnerId()" class="w-full" />
|
||||
</div>
|
||||
@@ -48,3 +66,9 @@
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
|
||||
<partner-charge-account-form-dialog
|
||||
[(visible)]="visibleChargeAccountFormDialog"
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
></partner-charge-account-form-dialog>
|
||||
|
||||
@@ -3,8 +3,11 @@ import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Button } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||
import { PartnerChargeLicenseFormDialogComponent } from '../components/charge-license-form-dialog.component';
|
||||
import { PartnerChargeAccountFormDialogComponent } from '../components/chargeAccount/charge-account-form-dialog.component';
|
||||
import { AdminPartnerChargeAccountListComponent } from '../components/chargeAccount/list.component';
|
||||
import { AdminPartnerChargeLicenseTransactionListComponent } from '../components/chargeLicenseTransactions/list.component';
|
||||
import { GuildFormComponent } from '../components/form.component';
|
||||
import { AdminPartnerLicensesComponent } from '../components/licenses/list.component';
|
||||
@@ -20,9 +23,12 @@ import { PartnerStore } from '../store/partner.store';
|
||||
GuildFormComponent,
|
||||
ConsumerAccountListComponent,
|
||||
Button,
|
||||
AdminPartnerChargeAccountListComponent,
|
||||
PartnerChargeAccountFormDialogComponent,
|
||||
PartnerChargeLicenseFormDialogComponent,
|
||||
AdminPartnerLicensesComponent,
|
||||
AdminPartnerChargeLicenseTransactionListComponent,
|
||||
Divider,
|
||||
],
|
||||
})
|
||||
export class PartnerComponent {
|
||||
@@ -36,6 +42,7 @@ export class PartnerComponent {
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly partner = computed(() => this.store.entity());
|
||||
visibleChargeFormDialog = signal(false);
|
||||
visibleChargeAccountFormDialog = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
@@ -64,4 +71,8 @@ export class PartnerComponent {
|
||||
openChargeDialog() {
|
||||
this.visibleChargeFormDialog.set(true);
|
||||
}
|
||||
|
||||
openChargeAccountDialog() {
|
||||
this.visibleChargeAccountFormDialog.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user