update license structures and init to setup image uploader
This commit is contained in:
+40
-40
@@ -23,47 +23,47 @@ services:
|
||||
- psp_panel_network
|
||||
|
||||
# Staging service
|
||||
staging:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.staging
|
||||
container_name: psp_panel_staging
|
||||
ports:
|
||||
- "5050:5000"
|
||||
environment:
|
||||
- NODE_ENV=staging
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test:
|
||||
["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
profiles:
|
||||
- staging
|
||||
networks:
|
||||
- psp_panel_network
|
||||
# staging:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: Dockerfile.staging
|
||||
# container_name: psp_panel_staging
|
||||
# ports:
|
||||
# - "5050:5000"
|
||||
# environment:
|
||||
# - NODE_ENV=staging
|
||||
# restart: unless-stopped
|
||||
# healthcheck:
|
||||
# test:
|
||||
# ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
||||
# interval: 30s
|
||||
# timeout: 3s
|
||||
# retries: 3
|
||||
# start_period: 5s
|
||||
# profiles:
|
||||
# - staging
|
||||
# networks:
|
||||
# - psp_panel_network
|
||||
|
||||
# Development service with hot reload
|
||||
dev:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: psp_panel-dev
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
ports:
|
||||
- "4200:4200"
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
restart: unless-stopped
|
||||
profiles:
|
||||
- dev
|
||||
networks:
|
||||
- psp_panel_network
|
||||
# # Development service with hot reload
|
||||
# dev:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: Dockerfile.dev
|
||||
# container_name: psp_panel-dev
|
||||
# working_dir: /app
|
||||
# volumes:
|
||||
# - .:/app
|
||||
# - /app/node_modules
|
||||
# ports:
|
||||
# - "4200:4200"
|
||||
# environment:
|
||||
# - NODE_ENV=development
|
||||
# restart: unless-stopped
|
||||
# profiles:
|
||||
# - dev
|
||||
# networks:
|
||||
# - psp_panel_network
|
||||
|
||||
networks:
|
||||
psp_panel_network:
|
||||
|
||||
@@ -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
|
||||
<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
|
||||
<partner-charge-license-form-dialog
|
||||
[(visible)]="visibleChargeFormDialog"
|
||||
[partnerId]="partnerId()"
|
||||
(onSubmit)="getData()"
|
||||
/>
|
||||
</div>
|
||||
/>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -64,6 +64,15 @@
|
||||
<td>
|
||||
@if (col.type === "index") {
|
||||
{{ i * (currentPage || 1) + 1 }}
|
||||
} @else if (col.type === "thumbnail") {
|
||||
<div
|
||||
class="w-20 h-20 rounded-2xl overflow-hidden bg-surface-50 cursor-pointer"
|
||||
(click)="openThumbnailModal(item)"
|
||||
>
|
||||
@if (item[col.field]) {
|
||||
<img [src]="item[col.field]" class="w-full h-full object-cover" />
|
||||
}
|
||||
</div>
|
||||
} @else if (getTemplate(col)) {
|
||||
<ng-container
|
||||
[ngTemplateOutlet]="getTemplate(col)"
|
||||
@@ -72,7 +81,7 @@
|
||||
} @else if (col.canCopy) {
|
||||
<uikit-copy [text]="getCell(item, col)"></uikit-copy>
|
||||
} @else {
|
||||
<span>
|
||||
<span [class]="getPreviewClasses(item, col)">
|
||||
{{ getCell(item, col) }}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PaginatorComponent, UikitCopyComponent, UikitEmptyStateComponent } from '@/uikit';
|
||||
import { formatJalali, formatWithCurrency } from '@/utils';
|
||||
import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
Component,
|
||||
@@ -26,8 +26,18 @@ export interface IColumn<T = any> {
|
||||
width?: string;
|
||||
minWidth?: string;
|
||||
canCopy?: boolean;
|
||||
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id';
|
||||
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id' | 'thumbnail';
|
||||
nestedPath?: string;
|
||||
thumbnailOptions?: {
|
||||
editable: boolean;
|
||||
deletable: boolean;
|
||||
showPreview: boolean;
|
||||
};
|
||||
dateOption?: {
|
||||
expiredMode?: boolean;
|
||||
dateTime?: boolean;
|
||||
onlyTime?: boolean;
|
||||
};
|
||||
customDataModel?: TemplateRef<any> | ((item: T) => string | number | boolean);
|
||||
}
|
||||
|
||||
@@ -84,6 +94,7 @@ export class PageDataListComponent<I> {
|
||||
@Output() onDetails = new EventEmitter<I>();
|
||||
@Output() onAdd = new EventEmitter<void>();
|
||||
@Output() pageChange = new EventEmitter<any>();
|
||||
@Output() onThumbnailClick = new EventEmitter<I>();
|
||||
|
||||
filterDrawerVisible = signal<boolean>(false);
|
||||
|
||||
@@ -126,10 +137,36 @@ export class PageDataListComponent<I> {
|
||||
this.pageChange.emit($event);
|
||||
};
|
||||
|
||||
openThumbnailModal = (item: I) => {
|
||||
// this.
|
||||
};
|
||||
|
||||
get showPaginator() {
|
||||
return !!(this.totalRecords && this.perPage && this.totalRecords > this.perPage);
|
||||
}
|
||||
|
||||
getPreviewClasses(item: Record<string, any>, column: IColumn): any {
|
||||
if (!item || !column || column.customDataModel) return '';
|
||||
try {
|
||||
const { field } = column;
|
||||
|
||||
const data = item[String(field)];
|
||||
switch (column.type) {
|
||||
case 'date':
|
||||
if (column.dateOption?.expiredMode) {
|
||||
if (jalaliDiff(new Date(), data) > 0) {
|
||||
return 'text-error';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getCell(item: Record<string, any>, column: IColumn): any {
|
||||
if (!item || !column) return '';
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface onSelectArgs {
|
||||
data: FormData;
|
||||
file: File;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<p-fileupload [name]="name" [accept]="accept" [maxFileSize]="maxSize" (onSelect)="onSelectedFile($event)">
|
||||
<ng-template #header let-chooseCallback="chooseCallback">
|
||||
<div class="flex items-center justify-center flex-col cursor-pointer py-5 w-full" (click)="chooseCallback()">
|
||||
<i class="pi pi-cloud-upload border-2! rounded-full! p-8! text-4xl! text-muted-color!"></i>
|
||||
<p class="mt-6 mb-0">فایل مورد نظر خود را در اینجا رها کنید</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-fileupload>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { FileSelectEvent, FileUpload } from 'primeng/fileupload';
|
||||
import { onSelectArgs } from './model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shared-upload-file',
|
||||
templateUrl: './upload-file.component.html',
|
||||
imports: [FileUpload],
|
||||
})
|
||||
export class SharedUploadFileComponent {
|
||||
@Input() currentImage: Maybe<string> = null;
|
||||
@Input() loading: boolean = false;
|
||||
@Input() name: string = 'file';
|
||||
@Input() accept: string = 'image/*';
|
||||
@Input() maxSize: Maybe<number> = 5 * 1024;
|
||||
@Input() error: Maybe<string> = null;
|
||||
@Input() hint: Maybe<string> = null;
|
||||
|
||||
@Output() onSelect = new EventEmitter<onSelectArgs>();
|
||||
|
||||
onSelectedFile($event: FileSelectEvent) {
|
||||
const file = $event.files?.[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
const payload = new FormData();
|
||||
payload.append(this.name, file, file.name);
|
||||
this.onSelect.emit({ data: payload, file });
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import dayjs from 'dayjs';
|
||||
import flatpickr from 'flatpickr-wrap';
|
||||
import { BaseOptions } from 'flatpickr-wrap/dist/types/options';
|
||||
import { BaseOptions, DateOption } from 'flatpickr-wrap/dist/types/options';
|
||||
import { InputTextModule } from 'primeng/inputtext';
|
||||
import { UikitFieldComponent } from '../uikit-field.component';
|
||||
|
||||
@@ -32,6 +32,8 @@ export class UikitFlatpickrJalaliComponent implements OnInit {
|
||||
@Input() showLabel: boolean = true;
|
||||
@Input() showErrors: boolean = true;
|
||||
@Input() hint?: string;
|
||||
@Input() minDate?: DateOption;
|
||||
@Input() maxDate?: DateOption;
|
||||
|
||||
@Output() valueChange = new EventEmitter<string>();
|
||||
|
||||
@@ -43,6 +45,8 @@ export class UikitFlatpickrJalaliComponent implements OnInit {
|
||||
this.fpInstance = flatpickr(this.wrapperRef.nativeElement, {
|
||||
...this.options,
|
||||
locale: 'fa',
|
||||
minDate: this.minDate,
|
||||
maxDate: this.maxDate,
|
||||
altInputClass: 'p-inputtext w-full',
|
||||
dateFormat: 'Y-m-d',
|
||||
altFormat: 'Y-m-d',
|
||||
|
||||
Reference in New Issue
Block a user