update license structures and init to setup image uploader
This commit is contained in:
+40
-40
@@ -23,47 +23,47 @@ services:
|
|||||||
- psp_panel_network
|
- psp_panel_network
|
||||||
|
|
||||||
# Staging service
|
# Staging service
|
||||||
staging:
|
# staging:
|
||||||
build:
|
# build:
|
||||||
context: .
|
# context: .
|
||||||
dockerfile: Dockerfile.staging
|
# dockerfile: Dockerfile.staging
|
||||||
container_name: psp_panel_staging
|
# container_name: psp_panel_staging
|
||||||
ports:
|
# ports:
|
||||||
- "5050:5000"
|
# - "5050:5000"
|
||||||
environment:
|
# environment:
|
||||||
- NODE_ENV=staging
|
# - NODE_ENV=staging
|
||||||
restart: unless-stopped
|
# restart: unless-stopped
|
||||||
healthcheck:
|
# healthcheck:
|
||||||
test:
|
# test:
|
||||||
["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
# ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
||||||
interval: 30s
|
# interval: 30s
|
||||||
timeout: 3s
|
# timeout: 3s
|
||||||
retries: 3
|
# retries: 3
|
||||||
start_period: 5s
|
# start_period: 5s
|
||||||
profiles:
|
# profiles:
|
||||||
- staging
|
# - staging
|
||||||
networks:
|
# networks:
|
||||||
- psp_panel_network
|
# - psp_panel_network
|
||||||
|
|
||||||
# Development service with hot reload
|
# # Development service with hot reload
|
||||||
dev:
|
# dev:
|
||||||
build:
|
# build:
|
||||||
context: .
|
# context: .
|
||||||
dockerfile: Dockerfile.dev
|
# dockerfile: Dockerfile.dev
|
||||||
container_name: psp_panel-dev
|
# container_name: psp_panel-dev
|
||||||
working_dir: /app
|
# working_dir: /app
|
||||||
volumes:
|
# volumes:
|
||||||
- .:/app
|
# - .:/app
|
||||||
- /app/node_modules
|
# - /app/node_modules
|
||||||
ports:
|
# ports:
|
||||||
- "4200:4200"
|
# - "4200:4200"
|
||||||
environment:
|
# environment:
|
||||||
- NODE_ENV=development
|
# - NODE_ENV=development
|
||||||
restart: unless-stopped
|
# restart: unless-stopped
|
||||||
profiles:
|
# profiles:
|
||||||
- dev
|
# - dev
|
||||||
networks:
|
# networks:
|
||||||
- psp_panel_network
|
# - psp_panel_network
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
psp_panel_network:
|
psp_panel_network:
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export class ConsumerUserFormComponent extends AbstractFormDialog<
|
|||||||
password: [''],
|
password: [''],
|
||||||
confirmPassword: [''],
|
confirmPassword: [''],
|
||||||
license: this.fb.group({
|
license: this.fb.group({
|
||||||
starts_at: [this.initialValues?.license?.starts_at || ''],
|
starts_at: [this.initialValues?.license_info?.starts_at || ''],
|
||||||
partner_id: [this.initialValues?.license?.partner?.id || ''],
|
partner_id: [this.initialValues?.license_info?.partner?.id || ''],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ export class ConsumerUserFormComponent extends AbstractFormDialog<
|
|||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
...(this.initialValues ?? {}),
|
...(this.initialValues ?? {}),
|
||||||
license: {
|
license: {
|
||||||
...(this.initialValues?.license ?? {}),
|
...(this.initialValues?.license_info ?? {}),
|
||||||
partner_id: this.initialValues?.license?.partner?.id || '',
|
partner_id: this.initialValues?.license_info?.partner?.id || '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (this.editMode && !this.consumerId) {
|
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 {
|
export interface IConsumerRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -6,8 +6,9 @@ export interface IConsumerRawResponse {
|
|||||||
last_name: string;
|
last_name: string;
|
||||||
mobile_number: string;
|
mobile_number: string;
|
||||||
status: string;
|
status: string;
|
||||||
|
created_at: string;
|
||||||
fullname: string;
|
fullname: string;
|
||||||
license: ILicenseRawResponse;
|
license_info: ILicenseInfo;
|
||||||
}
|
}
|
||||||
export interface IConsumerResponse extends IConsumerRawResponse {}
|
export interface IConsumerResponse extends IConsumerRawResponse {}
|
||||||
|
|
||||||
@@ -17,5 +18,11 @@ export interface IConsumerRequest {
|
|||||||
mobile_number: string;
|
mobile_number: string;
|
||||||
username: string;
|
username: string;
|
||||||
password: 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;
|
id: string;
|
||||||
starts_at: string;
|
starts_at: string;
|
||||||
expires_at: string;
|
expires_at: string;
|
||||||
status: TLicenseStatus;
|
// status: TLicenseStatus;
|
||||||
partner?: ISummary;
|
partner?: ISummary;
|
||||||
}
|
}
|
||||||
export interface ILicenseResponse extends ILicenseRawResponse {}
|
export interface ILicenseResponse extends ILicenseRawResponse {}
|
||||||
@@ -12,6 +12,6 @@ export interface ILicenseResponse extends ILicenseRawResponse {}
|
|||||||
export interface ILicenseRequest {
|
export interface ILicenseRequest {
|
||||||
starts_at: string;
|
starts_at: string;
|
||||||
expires_at?: string;
|
expires_at?: string;
|
||||||
status: TLicenseStatus;
|
// status: TLicenseStatus;
|
||||||
partner_id: string;
|
partner_id: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ export class ConsumersComponent extends AbstractList<IConsumerResponse> {
|
|||||||
field: 'license_expires_at',
|
field: 'license_expires_at',
|
||||||
header: 'تاریخ انقضای لایسنس',
|
header: 'تاریخ انقضای لایسنس',
|
||||||
customDataModel(item) {
|
customDataModel(item) {
|
||||||
if (item.license) {
|
if (item.license_info) {
|
||||||
return formatJalali(item.license.expires_at);
|
return formatJalali(item.license_info.expires_at);
|
||||||
}
|
}
|
||||||
return 'بدون لایسنس';
|
return 'بدون لایسنس';
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
<superAdmin-consumer-license-form
|
<superAdmin-consumer-license-form
|
||||||
[(visible)]="visibleLicenseForm"
|
[(visible)]="visibleLicenseForm"
|
||||||
[editMode]="!!licenseStatus()"
|
[editMode]="!!license()?.id"
|
||||||
[consumerId]="consumerId()"
|
[consumerId]="consumerId()"
|
||||||
[licenseId]="license()?.id"
|
[licenseId]="license()?.id"
|
||||||
[initialValues]="license() || undefined"
|
[initialValues]="license() || undefined"
|
||||||
|
|||||||
@@ -37,12 +37,16 @@ export class ConsumerComponent {
|
|||||||
|
|
||||||
readonly loading = computed(() => this.store.loading());
|
readonly loading = computed(() => this.store.loading());
|
||||||
readonly consumer = computed(() => this.store.entity());
|
readonly consumer = computed(() => this.store.entity());
|
||||||
readonly license = computed(() => this.store.entity()?.license);
|
readonly license = computed(() => this.store.entity()?.license_info);
|
||||||
readonly licenseStatus = computed(() => {
|
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;
|
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.EXPIRED;
|
||||||
}
|
}
|
||||||
return licenseStatus.ACTIVE;
|
return licenseStatus.ACTIVE;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class GuildGoodsListComponent extends AbstractList<IGuildGoodsResponse> {
|
|||||||
@Input() guildId!: string;
|
@Input() guildId!: string;
|
||||||
@Input() fullHeight?: boolean;
|
@Input() fullHeight?: boolean;
|
||||||
@Input() header: IColumn[] = [
|
@Input() header: IColumn[] = [
|
||||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
{ field: 'image_url', header: 'تصویر', type: 'thumbnail' },
|
||||||
{ field: 'name', header: 'عنوان' },
|
{ field: 'name', header: 'عنوان' },
|
||||||
{ field: 'sku', header: 'شناسهی عمومی' },
|
{ field: 'sku', header: 'شناسهی عمومی' },
|
||||||
{ field: 'category', header: 'دستهبندی', type: 'nested', nestedPath: 'category.name' },
|
{ field: 'category', header: 'دستهبندی', type: 'nested', nestedPath: 'category.name' },
|
||||||
|
|||||||
+7
-1
@@ -7,7 +7,13 @@
|
|||||||
(onHide)="close()"
|
(onHide)="close()"
|
||||||
>
|
>
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
<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()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|||||||
+20
-9
@@ -1,30 +1,41 @@
|
|||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import { InputComponent } from '@/shared/components';
|
import { InputComponent } from '@/shared/components';
|
||||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
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 { Component, inject, Input } from '@angular/core';
|
||||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { Dialog } from 'primeng/dialog';
|
import { Dialog } from 'primeng/dialog';
|
||||||
import { ILicenseChargeRequest, ILicenseChargeResponse } from '../models';
|
import { IPartnerChargeLicenseTransactionRequest } from '../models/chargeLicenseTransactions_io';
|
||||||
import { PartnersService } from '../services/main.service';
|
import { AdminPartnerChargeLicenseTransactionsService } from '../services/chargeLicenseTransactions.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'partner-charge-license-form-dialog',
|
selector: 'partner-charge-license-form-dialog',
|
||||||
templateUrl: './charge-license-form-dialog.component.html',
|
templateUrl: './charge-license-form-dialog.component.html',
|
||||||
imports: [Dialog, ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
|
imports: [
|
||||||
|
Dialog,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
UikitFlatpickrJalaliComponent,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class PartnerChargeLicenseFormDialogComponent extends AbstractFormDialog<
|
export class PartnerChargeLicenseFormDialogComponent extends AbstractFormDialog<
|
||||||
ILicenseChargeRequest,
|
IPartnerChargeLicenseTransactionRequest,
|
||||||
ILicenseChargeResponse
|
any
|
||||||
> {
|
> {
|
||||||
@Input({ required: true }) partnerId!: string;
|
@Input({ required: true }) partnerId!: string;
|
||||||
|
|
||||||
private readonly service = inject(PartnersService);
|
private readonly service = inject(AdminPartnerChargeLicenseTransactionsService);
|
||||||
|
|
||||||
form = this.fb.group({
|
form = this.fb.group({
|
||||||
count: [0, [Validators.min(0)]],
|
quantity: [0, [Validators.required, Validators.min(1)]],
|
||||||
|
activated_expires_at: ['', [Validators.required]],
|
||||||
});
|
});
|
||||||
|
|
||||||
submitForm(payload: ILicenseChargeRequest) {
|
minDate = nowJalali();
|
||||||
return this.service.licenseCharge(this.partnerId, payload);
|
|
||||||
|
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">
|
<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.name" name="name" />
|
||||||
<app-input label="کد" [control]="form.controls.code" name="code" />
|
<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) {
|
@if (!editMode) {
|
||||||
<p-divider align="center"> اطلاعات ورود </p-divider>
|
<p-divider align="center"> اطلاعات ورود </p-divider>
|
||||||
<!-- @ts-ignore -->
|
<!-- @ts-ignore -->
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export class GuildFormComponent extends AbstractFormDialog<IPartnerRequest, IPar
|
|||||||
const form = this.fb.group({
|
const form = this.fb.group({
|
||||||
name: [this.initialValues?.name, [Validators.required]],
|
name: [this.initialValues?.name, [Validators.required]],
|
||||||
code: [this.initialValues?.code, [Validators.required]],
|
code: [this.initialValues?.code, [Validators.required]],
|
||||||
license_quota: [this.initialValues?.license_quota || 0, [Validators.required]],
|
|
||||||
username: [''],
|
username: [''],
|
||||||
password: [''],
|
password: [''],
|
||||||
confirmPassword: [''],
|
confirmPassword: [''],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<app-page-data-list
|
<app-page-data-list
|
||||||
[pageTitle]="'لیست لایسنسها'"
|
pageTitle="لیست لایسنسهای فروخته شده"
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
emptyPlaceholderTitle="لایسنسی یافت نشد"
|
emptyPlaceholderTitle="تا به حال توسط این شریک تجاری لایسنسی فروخته نشده است"
|
||||||
[items]="items()"
|
[items]="items()"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
import { Component, inject, Input } from '@angular/core';
|
import { Component, inject, Input } from '@angular/core';
|
||||||
import { IPartnerLicenseResponse } from '../../models';
|
import { IPartnerActivatedLicenseResponse } from '../../models';
|
||||||
import { AdminPartnerLicensesService } from '../../services/licenses.service';
|
import { AdminPartnerActivatedLicensesService } from '../../services/licenses.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'admin-partner-licenses',
|
selector: 'admin-partner-licenses',
|
||||||
templateUrl: './list.component.html',
|
templateUrl: './list.component.html',
|
||||||
imports: [PageDataListComponent],
|
imports: [PageDataListComponent],
|
||||||
})
|
})
|
||||||
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerLicenseResponse> {
|
export class AdminPartnerLicensesComponent extends AbstractList<IPartnerActivatedLicenseResponse> {
|
||||||
@Input({ required: true }) partnerId!: string;
|
@Input({ required: true }) partnerId!: string;
|
||||||
|
|
||||||
private readonly service = inject(AdminPartnerLicensesService);
|
private readonly service = inject(AdminPartnerActivatedLicensesService);
|
||||||
|
|
||||||
override setColumns(): void {
|
override setColumns(): void {
|
||||||
this.columns = [
|
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)}`,
|
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 './accounts';
|
||||||
|
export * from './activatedLicenses';
|
||||||
|
export * from './chargeLicenseTransactions';
|
||||||
|
|
||||||
const baseUrl = '/api/v1/admin/partners';
|
const baseUrl = '/api/v1/admin/partners';
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -1,12 +1,11 @@
|
|||||||
export interface IPartnerLicenseRawResponse {
|
export interface IPartnerActivatedLicenseRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
starts_at: string;
|
starts_at: string;
|
||||||
expires_at: string;
|
expires_at: string;
|
||||||
status: TLicenseStatus;
|
|
||||||
consumer: {
|
consumer: {
|
||||||
first_name: string;
|
first_name: string;
|
||||||
last_name: string;
|
last_name: string;
|
||||||
mobile_number: 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 './accounts_io';
|
||||||
|
export * from './activatedLicenses_io';
|
||||||
|
export * from './chargeLicenseTransactions_io';
|
||||||
export * from './io';
|
export * from './io';
|
||||||
export * from './licenses_io';
|
|
||||||
|
|||||||
+7
-10
@@ -2,8 +2,13 @@ export interface IPartnerRawResponse {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
code: string;
|
code: string;
|
||||||
remained_license: number;
|
status: string;
|
||||||
license_quota: number;
|
created_at: string;
|
||||||
|
licenses_status: {
|
||||||
|
total: number;
|
||||||
|
used: number;
|
||||||
|
expired: number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||||
|
|
||||||
@@ -12,11 +17,3 @@ export interface IPartnerRequest {
|
|||||||
code: string;
|
code: string;
|
||||||
license_quota: number;
|
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 { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PARTNER_LICENSES_API_ROUTES } from '../constants/apiRoutes/licenses';
|
import { PARTNER_ACTIVATED_LICENSES_API_ROUTES } from '../constants/apiRoutes/activatedLicenses';
|
||||||
import { IPartnerLicenseRawResponse, IPartnerLicenseResponse } from '../models';
|
import { IPartnerActivatedLicenseRawResponse, IPartnerActivatedLicenseResponse } from '../models';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AdminPartnerLicensesService {
|
export class AdminPartnerActivatedLicensesService {
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
private apiRoutes = PARTNER_LICENSES_API_ROUTES;
|
private apiRoutes = PARTNER_ACTIVATED_LICENSES_API_ROUTES;
|
||||||
|
|
||||||
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerLicenseResponse>> {
|
getAll(partnerId: string): Observable<IPaginatedResponse<IPartnerActivatedLicenseResponse>> {
|
||||||
return this.http.get<IPaginatedResponse<IPartnerLicenseRawResponse>>(
|
return this.http.get<IPaginatedResponse<IPartnerActivatedLicenseRawResponse>>(
|
||||||
this.apiRoutes.list(partnerId),
|
this.apiRoutes.list(partnerId),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PARTNERS_API_ROUTES } from '../constants';
|
import { PARTNERS_API_ROUTES } from '../constants';
|
||||||
import {
|
import { IPartnerRawResponse, IPartnerRequest, IPartnerResponse } from '../models';
|
||||||
ILicenseChargeRawResponse,
|
|
||||||
ILicenseChargeRequest,
|
|
||||||
ILicenseChargeResponse,
|
|
||||||
IPartnerRawResponse,
|
|
||||||
IPartnerRequest,
|
|
||||||
IPartnerResponse,
|
|
||||||
} from '../models';
|
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class PartnersService {
|
export class PartnersService {
|
||||||
@@ -32,11 +25,4 @@ export class PartnersService {
|
|||||||
update(partnerId: string, userData: IPartnerRequest): Observable<IPartnerResponse> {
|
update(partnerId: string, userData: IPartnerRequest): Observable<IPartnerResponse> {
|
||||||
return this.http.patch<IPartnerResponse>(this.apiRoutes.single(partnerId), userData);
|
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()"
|
(onAdd)="openAddForm()"
|
||||||
(onDetails)="toSinglePage($event)"
|
(onDetails)="toSinglePage($event)"
|
||||||
(onEdit)="onEditClick($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
|
<partner-form
|
||||||
[(visible)]="visibleForm"
|
[(visible)]="visibleForm"
|
||||||
[editMode]="editMode()"
|
[editMode]="editMode()"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
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 { Router } from '@angular/router';
|
||||||
import { GuildFormComponent } from '../components/form.component';
|
import { GuildFormComponent } from '../components/form.component';
|
||||||
import { superAdminPartnersNamedRoutes } from '../constants';
|
import { superAdminPartnersNamedRoutes } from '../constants';
|
||||||
@@ -17,12 +17,14 @@ export class PartnersComponent extends AbstractList<IPartnerResponse> {
|
|||||||
private readonly service = inject(PartnersService);
|
private readonly service = inject(PartnersService);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
@ViewChild('licensesStatus', { static: true }) licensesStatus!: TemplateRef<any>;
|
||||||
|
|
||||||
override setColumns(): void {
|
override setColumns(): void {
|
||||||
this.columns = [
|
this.columns = [
|
||||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
|
||||||
{ field: 'name', header: 'نام' },
|
{ field: 'name', header: 'نام' },
|
||||||
{ field: 'code', header: 'کد' },
|
{ field: 'code', header: 'کد' },
|
||||||
{ field: 'license_quota', header: 'تعداد لایسنس خریداری شده' },
|
{ field: 'licenses', header: 'وضعیت لایسنسها', customDataModel: this.licensesStatus },
|
||||||
|
{ field: 'status', header: 'وضعیت' },
|
||||||
{
|
{
|
||||||
field: 'created_at',
|
field: 'created_at',
|
||||||
header: 'تاریخ ایجاد',
|
header: 'تاریخ ایجاد',
|
||||||
|
|||||||
@@ -7,27 +7,44 @@
|
|||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
<app-key-value label="عنوان شریک تجاری" [value]="partner()?.name" />
|
<app-key-value label="عنوان شریک تجاری" [value]="partner()?.name" />
|
||||||
<app-key-value label="کد شریک تجاری" [value]="partner()?.code" />
|
<app-key-value label="کد شریک تجاری" [value]="partner()?.code" />
|
||||||
<app-key-value label="تعداد لایسنسهای خریداری شده" [value]="partner()?.license_quota + ''" />
|
<app-key-value label="تعداد لایسنسهای خریداری شده" [value]="partner()?.licenses_status?.total" />
|
||||||
<app-key-value label="تعداد لایسنسهای باقیمانده" [value]="partner()?.remained_license + ''" />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</app-card-data>
|
</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"
|
[(visible)]="editMode"
|
||||||
[editMode]="true"
|
[editMode]="true"
|
||||||
[partnerId]="partnerId()"
|
[partnerId]="partnerId()"
|
||||||
[initialValues]="partner() || undefined"
|
[initialValues]="partner() || undefined"
|
||||||
(onSubmit)="getData()"
|
(onSubmit)="getData()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<partner-charge-license-form-dialog
|
<partner-charge-license-form-dialog
|
||||||
[(visible)]="visibleChargeFormDialog"
|
[(visible)]="visibleChargeFormDialog"
|
||||||
[partnerId]="partnerId()"
|
[partnerId]="partnerId()"
|
||||||
(onSubmit)="getData()"
|
(onSubmit)="getData()"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { Button } from 'primeng/button';
|
import { Button } from 'primeng/button';
|
||||||
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||||
import { PartnerChargeLicenseFormDialogComponent } from '../components/charge-license-form-dialog.component';
|
import { PartnerChargeLicenseFormDialogComponent } from '../components/charge-license-form-dialog.component';
|
||||||
|
import { AdminPartnerChargeLicenseTransactionListComponent } from '../components/chargeLicenseTransactions/list.component';
|
||||||
import { GuildFormComponent } from '../components/form.component';
|
import { GuildFormComponent } from '../components/form.component';
|
||||||
import { AdminPartnerLicensesComponent } from '../components/licenses/list.component';
|
import { AdminPartnerLicensesComponent } from '../components/licenses/list.component';
|
||||||
import { superAdminPartnersNamedRoutes } from '../constants';
|
import { superAdminPartnersNamedRoutes } from '../constants';
|
||||||
@@ -21,6 +22,7 @@ import { PartnerStore } from '../store/partner.store';
|
|||||||
Button,
|
Button,
|
||||||
PartnerChargeLicenseFormDialogComponent,
|
PartnerChargeLicenseFormDialogComponent,
|
||||||
AdminPartnerLicensesComponent,
|
AdminPartnerLicensesComponent,
|
||||||
|
AdminPartnerChargeLicenseTransactionListComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class PartnerComponent {
|
export class PartnerComponent {
|
||||||
|
|||||||
@@ -64,6 +64,15 @@
|
|||||||
<td>
|
<td>
|
||||||
@if (col.type === "index") {
|
@if (col.type === "index") {
|
||||||
{{ i * (currentPage || 1) + 1 }}
|
{{ 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)) {
|
} @else if (getTemplate(col)) {
|
||||||
<ng-container
|
<ng-container
|
||||||
[ngTemplateOutlet]="getTemplate(col)"
|
[ngTemplateOutlet]="getTemplate(col)"
|
||||||
@@ -72,7 +81,7 @@
|
|||||||
} @else if (col.canCopy) {
|
} @else if (col.canCopy) {
|
||||||
<uikit-copy [text]="getCell(item, col)"></uikit-copy>
|
<uikit-copy [text]="getCell(item, col)"></uikit-copy>
|
||||||
} @else {
|
} @else {
|
||||||
<span>
|
<span [class]="getPreviewClasses(item, col)">
|
||||||
{{ getCell(item, col) }}
|
{{ getCell(item, col) }}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { PaginatorComponent, UikitCopyComponent, UikitEmptyStateComponent } from '@/uikit';
|
import { PaginatorComponent, UikitCopyComponent, UikitEmptyStateComponent } from '@/uikit';
|
||||||
import { formatJalali, formatWithCurrency } from '@/utils';
|
import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
@@ -26,8 +26,18 @@ export interface IColumn<T = any> {
|
|||||||
width?: string;
|
width?: string;
|
||||||
minWidth?: string;
|
minWidth?: string;
|
||||||
canCopy?: boolean;
|
canCopy?: boolean;
|
||||||
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id';
|
type?: 'text' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id' | 'thumbnail';
|
||||||
nestedPath?: string;
|
nestedPath?: string;
|
||||||
|
thumbnailOptions?: {
|
||||||
|
editable: boolean;
|
||||||
|
deletable: boolean;
|
||||||
|
showPreview: boolean;
|
||||||
|
};
|
||||||
|
dateOption?: {
|
||||||
|
expiredMode?: boolean;
|
||||||
|
dateTime?: boolean;
|
||||||
|
onlyTime?: boolean;
|
||||||
|
};
|
||||||
customDataModel?: TemplateRef<any> | ((item: T) => string | number | boolean);
|
customDataModel?: TemplateRef<any> | ((item: T) => string | number | boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +94,7 @@ export class PageDataListComponent<I> {
|
|||||||
@Output() onDetails = new EventEmitter<I>();
|
@Output() onDetails = new EventEmitter<I>();
|
||||||
@Output() onAdd = new EventEmitter<void>();
|
@Output() onAdd = new EventEmitter<void>();
|
||||||
@Output() pageChange = new EventEmitter<any>();
|
@Output() pageChange = new EventEmitter<any>();
|
||||||
|
@Output() onThumbnailClick = new EventEmitter<I>();
|
||||||
|
|
||||||
filterDrawerVisible = signal<boolean>(false);
|
filterDrawerVisible = signal<boolean>(false);
|
||||||
|
|
||||||
@@ -126,10 +137,36 @@ export class PageDataListComponent<I> {
|
|||||||
this.pageChange.emit($event);
|
this.pageChange.emit($event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
openThumbnailModal = (item: I) => {
|
||||||
|
// this.
|
||||||
|
};
|
||||||
|
|
||||||
get showPaginator() {
|
get showPaginator() {
|
||||||
return !!(this.totalRecords && this.perPage && this.totalRecords > this.perPage);
|
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 {
|
getCell(item: Record<string, any>, column: IColumn): any {
|
||||||
if (!item || !column) return '';
|
if (!item || !column) return '';
|
||||||
try {
|
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 { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import flatpickr from 'flatpickr-wrap';
|
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 { InputTextModule } from 'primeng/inputtext';
|
||||||
import { UikitFieldComponent } from '../uikit-field.component';
|
import { UikitFieldComponent } from '../uikit-field.component';
|
||||||
|
|
||||||
@@ -32,6 +32,8 @@ export class UikitFlatpickrJalaliComponent implements OnInit {
|
|||||||
@Input() showLabel: boolean = true;
|
@Input() showLabel: boolean = true;
|
||||||
@Input() showErrors: boolean = true;
|
@Input() showErrors: boolean = true;
|
||||||
@Input() hint?: string;
|
@Input() hint?: string;
|
||||||
|
@Input() minDate?: DateOption;
|
||||||
|
@Input() maxDate?: DateOption;
|
||||||
|
|
||||||
@Output() valueChange = new EventEmitter<string>();
|
@Output() valueChange = new EventEmitter<string>();
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ export class UikitFlatpickrJalaliComponent implements OnInit {
|
|||||||
this.fpInstance = flatpickr(this.wrapperRef.nativeElement, {
|
this.fpInstance = flatpickr(this.wrapperRef.nativeElement, {
|
||||||
...this.options,
|
...this.options,
|
||||||
locale: 'fa',
|
locale: 'fa',
|
||||||
|
minDate: this.minDate,
|
||||||
|
maxDate: this.maxDate,
|
||||||
altInputClass: 'p-inputtext w-full',
|
altInputClass: 'p-inputtext w-full',
|
||||||
dateFormat: 'Y-m-d',
|
dateFormat: 'Y-m-d',
|
||||||
altFormat: 'Y-m-d',
|
altFormat: 'Y-m-d',
|
||||||
|
|||||||
Reference in New Issue
Block a user