update license structures and init to setup image uploader
This commit is contained in:
@@ -48,8 +48,8 @@ export class ConsumerUserFormComponent extends AbstractFormDialog<
|
||||
password: [''],
|
||||
confirmPassword: [''],
|
||||
license: this.fb.group({
|
||||
starts_at: [this.initialValues?.license?.starts_at || ''],
|
||||
partner_id: [this.initialValues?.license?.partner?.id || ''],
|
||||
starts_at: [this.initialValues?.license_info?.starts_at || ''],
|
||||
partner_id: [this.initialValues?.license_info?.partner?.id || ''],
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -95,8 +95,8 @@ export class ConsumerUserFormComponent extends AbstractFormDialog<
|
||||
this.form.patchValue({
|
||||
...(this.initialValues ?? {}),
|
||||
license: {
|
||||
...(this.initialValues?.license ?? {}),
|
||||
partner_id: this.initialValues?.license?.partner?.id || '',
|
||||
...(this.initialValues?.license_info ?? {}),
|
||||
partner_id: this.initialValues?.license_info?.partner?.id || '',
|
||||
},
|
||||
});
|
||||
if (this.editMode && !this.consumerId) {
|
||||
|
||||
+10
-3
@@ -1,4 +1,4 @@
|
||||
import { ILicenseRawResponse, ILicenseRequest } from './licenses_io';
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface IConsumerRawResponse {
|
||||
id: string;
|
||||
@@ -6,8 +6,9 @@ export interface IConsumerRawResponse {
|
||||
last_name: string;
|
||||
mobile_number: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
fullname: string;
|
||||
license: ILicenseRawResponse;
|
||||
license_info: ILicenseInfo;
|
||||
}
|
||||
export interface IConsumerResponse extends IConsumerRawResponse {}
|
||||
|
||||
@@ -17,5 +18,11 @@ export interface IConsumerRequest {
|
||||
mobile_number: string;
|
||||
username: string;
|
||||
password: string;
|
||||
license?: ILicenseRequest;
|
||||
}
|
||||
|
||||
interface ILicenseInfo {
|
||||
id: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
partner: ISummary;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export interface ILicenseRawResponse {
|
||||
id: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
status: TLicenseStatus;
|
||||
// status: TLicenseStatus;
|
||||
partner?: ISummary;
|
||||
}
|
||||
export interface ILicenseResponse extends ILicenseRawResponse {}
|
||||
@@ -12,6 +12,6 @@ export interface ILicenseResponse extends ILicenseRawResponse {}
|
||||
export interface ILicenseRequest {
|
||||
starts_at: string;
|
||||
expires_at?: string;
|
||||
status: TLicenseStatus;
|
||||
// status: TLicenseStatus;
|
||||
partner_id: string;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ export class ConsumersComponent extends AbstractList<IConsumerResponse> {
|
||||
field: 'license_expires_at',
|
||||
header: 'تاریخ انقضای لایسنس',
|
||||
customDataModel(item) {
|
||||
if (item.license) {
|
||||
return formatJalali(item.license.expires_at);
|
||||
if (item.license_info) {
|
||||
return formatJalali(item.license_info.expires_at);
|
||||
}
|
||||
return 'بدون لایسنس';
|
||||
},
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<superAdmin-consumer-license-form
|
||||
[(visible)]="visibleLicenseForm"
|
||||
[editMode]="!!licenseStatus()"
|
||||
[editMode]="!!license()?.id"
|
||||
[consumerId]="consumerId()"
|
||||
[licenseId]="license()?.id"
|
||||
[initialValues]="license() || undefined"
|
||||
|
||||
@@ -37,12 +37,16 @@ export class ConsumerComponent {
|
||||
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly consumer = computed(() => this.store.entity());
|
||||
readonly license = computed(() => this.store.entity()?.license);
|
||||
readonly license = computed(() => this.store.entity()?.license_info);
|
||||
readonly licenseStatus = computed(() => {
|
||||
if (!this.store.entity()?.license?.expires_at) {
|
||||
console.log(this.store.entity()?.license_info?.expires_at);
|
||||
|
||||
if (!this.store.entity()?.license_info?.expires_at) {
|
||||
return null;
|
||||
}
|
||||
if (new Date().getTime() > new Date(this.store.entity()?.license?.expires_at || '').getTime()) {
|
||||
if (
|
||||
new Date().getTime() > new Date(this.store.entity()?.license_info?.expires_at || '').getTime()
|
||||
) {
|
||||
return licenseStatus.EXPIRED;
|
||||
}
|
||||
return licenseStatus.ACTIVE;
|
||||
|
||||
@@ -18,7 +18,7 @@ export class GuildGoodsListComponent extends AbstractList<IGuildGoodsResponse> {
|
||||
@Input() guildId!: string;
|
||||
@Input() fullHeight?: boolean;
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'image_url', header: 'تصویر', type: 'thumbnail' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'sku', header: 'شناسهی عمومی' },
|
||||
{ field: 'category', header: 'دستهبندی', type: 'nested', nestedPath: 'category.name' },
|
||||
|
||||
+7
-1
@@ -7,7 +7,13 @@
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="تعداد شارژ" [control]="form.controls.count" type="number" />
|
||||
<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>
|
||||
|
||||
+20
-9
@@ -1,30 +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 { ILicenseChargeRequest, ILicenseChargeResponse } from '../models';
|
||||
import { PartnersService } from '../services/main.service';
|
||||
import { IPartnerChargeLicenseTransactionRequest } from '../models/chargeLicenseTransactions_io';
|
||||
import { AdminPartnerChargeLicenseTransactionsService } from '../services/chargeLicenseTransactions.service';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-charge-license-form-dialog',
|
||||
templateUrl: './charge-license-form-dialog.component.html',
|
||||
imports: [Dialog, ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
|
||||
imports: [
|
||||
Dialog,
|
||||
ReactiveFormsModule,
|
||||
InputComponent,
|
||||
FormFooterActionsComponent,
|
||||
UikitFlatpickrJalaliComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerChargeLicenseFormDialogComponent extends AbstractFormDialog<
|
||||
ILicenseChargeRequest,
|
||||
ILicenseChargeResponse
|
||||
IPartnerChargeLicenseTransactionRequest,
|
||||
any
|
||||
> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(PartnersService);
|
||||
private readonly service = inject(AdminPartnerChargeLicenseTransactionsService);
|
||||
|
||||
form = this.fb.group({
|
||||
count: [0, [Validators.min(0)]],
|
||||
quantity: [0, [Validators.required, Validators.min(1)]],
|
||||
activated_expires_at: ['', [Validators.required]],
|
||||
});
|
||||
|
||||
submitForm(payload: ILicenseChargeRequest) {
|
||||
return this.service.licenseCharge(this.partnerId, payload);
|
||||
minDate = nowJalali();
|
||||
|
||||
submitForm(payload: IPartnerChargeLicenseTransactionRequest) {
|
||||
return this.service.charge(this.partnerId, payload);
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<app-page-data-list
|
||||
pageTitle="گزارش شارژهای ثبت شدهی لایسنسها"
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="تا به حال شارژ لایسنسی انجام نشده است"
|
||||
[items]="items()"
|
||||
[loading]="loading()"
|
||||
>
|
||||
<!-- <ng-template #role let-data>
|
||||
<catalog-role-tag [role]="data.role" />
|
||||
</ng-template> -->
|
||||
</app-page-data-list>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||
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 { IPartnerChargeLicenseTransactionRawResponse } from '../../models';
|
||||
import { AdminPartnerChargeLicenseTransactionsService } from '../../services/chargeLicenseTransactions.service';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-partner-chargeLicenseTransaction-list',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class AdminPartnerChargeLicenseTransactionListComponent extends AbstractList<IPartnerChargeLicenseTransactionRawResponse> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(AdminPartnerChargeLicenseTransactionsService);
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'charged_license_count', header: 'تعداد لایسنس خریداری شده' },
|
||||
{ field: 'remained_license_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);
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,6 @@
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="کد" [control]="form.controls.code" name="code" />
|
||||
<app-input
|
||||
label="تعداد لایسنسهای رزرو"
|
||||
[control]="form.controls.license_quota"
|
||||
name="license_quota"
|
||||
type="number"
|
||||
[min]="0"
|
||||
/>
|
||||
@if (!editMode) {
|
||||
<p-divider align="center"> اطلاعات ورود </p-divider>
|
||||
<!-- @ts-ignore -->
|
||||
|
||||
@@ -32,7 +32,6 @@ export class GuildFormComponent extends AbstractFormDialog<IPartnerRequest, IPar
|
||||
const form = this.fb.group({
|
||||
name: [this.initialValues?.name, [Validators.required]],
|
||||
code: [this.initialValues?.code, [Validators.required]],
|
||||
license_quota: [this.initialValues?.license_quota || 0, [Validators.required]],
|
||||
username: [''],
|
||||
password: [''],
|
||||
confirmPassword: [''],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<app-page-data-list
|
||||
[pageTitle]="'لیست لایسنسها'"
|
||||
pageTitle="لیست لایسنسهای فروخته شده"
|
||||
[columns]="columns"
|
||||
emptyPlaceholderTitle="لایسنسی یافت نشد"
|
||||
emptyPlaceholderTitle="تا به حال توسط این شریک تجاری لایسنسی فروخته نشده است"
|
||||
[items]="items()"
|
||||
[loading]="loading()"
|
||||
>
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
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 { IPartnerLicenseResponse } from '../../models';
|
||||
import { AdminPartnerLicensesService } from '../../services/licenses.service';
|
||||
import { IPartnerActivatedLicenseResponse } from '../../models';
|
||||
import { AdminPartnerActivatedLicensesService } from '../../services/licenses.service';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-partner-licenses',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent],
|
||||
})
|
||||
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerLicenseResponse> {
|
||||
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivatedLicenseResponse> {
|
||||
@Input({ required: true }) partnerId!: string;
|
||||
|
||||
private readonly service = inject(AdminPartnerLicensesService);
|
||||
private readonly service = inject(AdminPartnerActivatedLicensesService);
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
const baseUrl = (partnerId: string) => `/api/v1/admin/partners/${partnerId}/licenses`;
|
||||
const baseUrl = (partnerId: string) => `/api/v1/admin/partners/${partnerId}/activated-licenses`;
|
||||
|
||||
export const PARTNER_LICENSES_API_ROUTES = {
|
||||
export const PARTNER_ACTIVATED_LICENSES_API_ROUTES = {
|
||||
list: (partnerId: string) => `${baseUrl(partnerId)}`,
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
const baseUrl = (partnerId: string) =>
|
||||
`/api/v1/admin/partners/${partnerId}/charge-license-transactions`;
|
||||
|
||||
export const PARTNER_CHARGE_LICENSE_TRANSACTIONS_API_ROUTES = {
|
||||
list: (partnerId: string) => `${baseUrl(partnerId)}`,
|
||||
};
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from './accounts';
|
||||
export * from './activatedLicenses';
|
||||
export * from './chargeLicenseTransactions';
|
||||
|
||||
const baseUrl = '/api/v1/admin/partners';
|
||||
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
export interface IPartnerLicenseRawResponse {
|
||||
export interface IPartnerActivatedLicenseRawResponse {
|
||||
id: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
status: TLicenseStatus;
|
||||
consumer: {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
mobile_number: string;
|
||||
};
|
||||
}
|
||||
export interface IPartnerLicenseResponse extends IPartnerLicenseRawResponse {}
|
||||
export interface IPartnerActivatedLicenseResponse extends IPartnerActivatedLicenseRawResponse {}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
export interface IPartnerChargeLicenseTransactionRawResponse {
|
||||
id: string;
|
||||
created_at: string;
|
||||
activation_expires_at: string;
|
||||
charged_license_count: number;
|
||||
remained_license_count: number;
|
||||
}
|
||||
export interface IPartnerChargeLicenseTransactionResponse extends IPartnerChargeLicenseTransactionRawResponse {}
|
||||
|
||||
export interface IPartnerChargeLicenseTransactionRequest {
|
||||
quantity: number;
|
||||
activated_expires_at: string;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './accounts_io';
|
||||
export * from './activatedLicenses_io';
|
||||
export * from './chargeLicenseTransactions_io';
|
||||
export * from './io';
|
||||
export * from './licenses_io';
|
||||
|
||||
+7
-10
@@ -2,8 +2,13 @@ export interface IPartnerRawResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
remained_license: number;
|
||||
license_quota: number;
|
||||
status: string;
|
||||
created_at: string;
|
||||
licenses_status: {
|
||||
total: number;
|
||||
used: number;
|
||||
expired: number;
|
||||
};
|
||||
}
|
||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||
|
||||
@@ -12,11 +17,3 @@ export interface IPartnerRequest {
|
||||
code: string;
|
||||
license_quota: number;
|
||||
}
|
||||
|
||||
//charge license
|
||||
export interface ILicenseChargeRawResponse {}
|
||||
export interface ILicenseChargeResponse extends ILicenseChargeRawResponse {}
|
||||
|
||||
export interface ILicenseChargeRequest {
|
||||
count: number;
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
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_LICENSE_TRANSACTIONS_API_ROUTES } from '../constants';
|
||||
import {
|
||||
IPartnerChargeLicenseTransactionRawResponse,
|
||||
IPartnerChargeLicenseTransactionRequest,
|
||||
IPartnerChargeLicenseTransactionResponse,
|
||||
} from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AdminPartnerChargeLicenseTransactionsService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = PARTNER_CHARGE_LICENSE_TRANSACTIONS_API_ROUTES;
|
||||
|
||||
getAll(
|
||||
partnerId: string,
|
||||
): Observable<IPaginatedResponse<IPartnerChargeLicenseTransactionRawResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPartnerChargeLicenseTransactionResponse>>(
|
||||
this.apiRoutes.list(partnerId),
|
||||
);
|
||||
}
|
||||
|
||||
charge(
|
||||
partnerId: string,
|
||||
data: IPartnerChargeLicenseTransactionRequest,
|
||||
): Observable<IPartnerChargeLicenseTransactionRawResponse> {
|
||||
return this.http.post<IPartnerChargeLicenseTransactionResponse>(
|
||||
this.apiRoutes.list(partnerId),
|
||||
data,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,17 @@ import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNER_LICENSES_API_ROUTES } from '../constants/apiRoutes/licenses';
|
||||
import { IPartnerLicenseRawResponse, IPartnerLicenseResponse } from '../models';
|
||||
import { PARTNER_ACTIVATED_LICENSES_API_ROUTES } from '../constants/apiRoutes/activatedLicenses';
|
||||
import { IPartnerActivatedLicenseRawResponse, IPartnerActivatedLicenseResponse } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AdminPartnerLicensesService {
|
||||
export class AdminPartnerActivatedLicensesService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = PARTNER_LICENSES_API_ROUTES;
|
||||
private apiRoutes = PARTNER_ACTIVATED_LICENSES_API_ROUTES;
|
||||
|
||||
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerLicenseResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPartnerLicenseRawResponse>>(
|
||||
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerActivatedLicenseResponse>> {
|
||||
return this.http.get<IPaginatedResponse<IPartnerActivatedLicenseRawResponse>>(
|
||||
this.apiRoutes.list(partnerId),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PARTNERS_API_ROUTES } from '../constants';
|
||||
import {
|
||||
ILicenseChargeRawResponse,
|
||||
ILicenseChargeRequest,
|
||||
ILicenseChargeResponse,
|
||||
IPartnerRawResponse,
|
||||
IPartnerRequest,
|
||||
IPartnerResponse,
|
||||
} from '../models';
|
||||
import { IPartnerRawResponse, IPartnerRequest, IPartnerResponse } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PartnersService {
|
||||
@@ -32,11 +25,4 @@ export class PartnersService {
|
||||
update(partnerId: string, userData: IPartnerRequest): Observable<IPartnerResponse> {
|
||||
return this.http.patch<IPartnerResponse>(this.apiRoutes.single(partnerId), userData);
|
||||
}
|
||||
|
||||
licenseCharge(
|
||||
partnerId: string,
|
||||
data: ILicenseChargeRequest,
|
||||
): Observable<ILicenseChargeResponse> {
|
||||
return this.http.post<ILicenseChargeRawResponse>(this.apiRoutes.licenseCharge(partnerId), data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,18 @@
|
||||
(onAdd)="openAddForm()"
|
||||
(onDetails)="toSinglePage($event)"
|
||||
(onEdit)="onEditClick($event)"
|
||||
/>
|
||||
>
|
||||
<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>
|
||||
}
|
||||
</span>
|
||||
</ng-template>
|
||||
</app-page-data-list>
|
||||
<partner-form
|
||||
[(visible)]="visibleForm"
|
||||
[editMode]="editMode()"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Component, inject, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { GuildFormComponent } from '../components/form.component';
|
||||
import { superAdminPartnersNamedRoutes } from '../constants';
|
||||
@@ -17,12 +17,14 @@ export class PartnersComponent extends AbstractList<IPartnerResponse> {
|
||||
private readonly service = inject(PartnersService);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
@ViewChild('licensesStatus', { static: true }) licensesStatus!: TemplateRef<any>;
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'نام' },
|
||||
{ field: 'code', header: 'کد' },
|
||||
{ field: 'license_quota', header: 'تعداد لایسنس خریداری شده' },
|
||||
{ field: 'licenses', header: 'وضعیت لایسنسها', customDataModel: this.licensesStatus },
|
||||
{ field: 'status', header: 'وضعیت' },
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
|
||||
@@ -7,27 +7,44 @@
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="عنوان شریک تجاری" [value]="partner()?.name" />
|
||||
<app-key-value label="کد شریک تجاری" [value]="partner()?.code" />
|
||||
<app-key-value label="تعداد لایسنسهای خریداری شده" [value]="partner()?.license_quota + ''" />
|
||||
<app-key-value label="تعداد لایسنسهای باقیمانده" [value]="partner()?.remained_license + ''" />
|
||||
<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" />
|
||||
<app-key-value
|
||||
label="تعداد لایسنسهای باقیمانده"
|
||||
[value]="
|
||||
(partner()?.licenses_status?.total || 0) -
|
||||
(partner()?.licenses_status?.used || 0) -
|
||||
(partner()?.licenses_status?.expired || 0)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</app-card-data>
|
||||
|
||||
<admin-partner-licenses [partnerId]="partnerId()" />
|
||||
<div class="max-h-[500px] flex">
|
||||
<admin-partner-licenses [partnerId]="partnerId()" class="w-full" />
|
||||
</div>
|
||||
|
||||
<superAdmin-partner-account-list [partnerId]="partnerId()" />
|
||||
<div class="max-h-[500px] flex">
|
||||
<admin-partner-chargeLicenseTransaction-list [partnerId]="partnerId()" class="w-full" />
|
||||
</div>
|
||||
|
||||
<partner-form
|
||||
[(visible)]="editMode"
|
||||
[editMode]="true"
|
||||
[partnerId]="partnerId()"
|
||||
[initialValues]="partner() || undefined"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
|
||||
<partner-charge-license-form-dialog
|
||||
[(visible)]="visibleChargeFormDialog"
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
<div class="max-h-[500px] flex">
|
||||
<superAdmin-partner-account-list [partnerId]="partnerId()" class="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<partner-form
|
||||
[(visible)]="editMode"
|
||||
[editMode]="true"
|
||||
[partnerId]="partnerId()"
|
||||
[initialValues]="partner() || undefined"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
|
||||
<partner-charge-license-form-dialog
|
||||
[(visible)]="visibleChargeFormDialog"
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { Button } from 'primeng/button';
|
||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||
import { PartnerChargeLicenseFormDialogComponent } from '../components/charge-license-form-dialog.component';
|
||||
import { AdminPartnerChargeLicenseTransactionListComponent } from '../components/chargeLicenseTransactions/list.component';
|
||||
import { GuildFormComponent } from '../components/form.component';
|
||||
import { AdminPartnerLicensesComponent } from '../components/licenses/list.component';
|
||||
import { superAdminPartnersNamedRoutes } from '../constants';
|
||||
@@ -21,6 +22,7 @@ import { PartnerStore } from '../store/partner.store';
|
||||
Button,
|
||||
PartnerChargeLicenseFormDialogComponent,
|
||||
AdminPartnerLicensesComponent,
|
||||
AdminPartnerChargeLicenseTransactionListComponent,
|
||||
],
|
||||
})
|
||||
export class PartnerComponent {
|
||||
|
||||
Reference in New Issue
Block a user