create license management
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<p-dialog
|
||||
header="اطلاعات لایسنس"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
[style]="{ width: '400px' }"
|
||||
[closable]="true"
|
||||
(onHide)="close()"
|
||||
>
|
||||
@if (!licenseStatus()) {
|
||||
<p-message severity="warn" [closable]="false" variant="text" icon="pi pi-info-circle" class="mb-5">
|
||||
برای کاربر شما لایسنسی در نظر گرفته نشده است. برای پیگیری با پشتیبانی تماس بگیرید.
|
||||
</p-message>
|
||||
} @else {
|
||||
@if (licenseStatus() === "EXPIRED") {
|
||||
<p-message severity="error" [closable]="false" variant="text" icon="pi pi-info-circle" class="mb-5">
|
||||
لایسنس شما منقضی شده است. برای تمدید با پشتیبانی تماس بگیرید.
|
||||
</p-message>
|
||||
}
|
||||
<div class="flex flex-col gap-4">
|
||||
<app-key-value label="شروع لایسنس از" [value]="license()?.starts_at!" type="date" />
|
||||
<app-key-value label="انقضای لایسنس" [value]="license()?.expires_at!" type="date" />
|
||||
<app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرمافزار'" />
|
||||
</div>
|
||||
}
|
||||
</p-dialog>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||
import { KeyValueComponent } from '@/shared/components';
|
||||
import { licenseStatus } from '@/shared/localEnum/constants/licenseStatus';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { Message } from 'primeng/message';
|
||||
import { ConsumerStore } from '../store/main.store';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-license-info-dialog',
|
||||
templateUrl: './license-info-dialog.component.html',
|
||||
imports: [Dialog, KeyValueComponent, Message],
|
||||
})
|
||||
export class ConsumerLicenseInfoDialogComponent extends AbstractDialog {
|
||||
private readonly store = inject(ConsumerStore);
|
||||
|
||||
license = computed(() => this.store.entity()?.license);
|
||||
|
||||
licenseStatus = computed(() => {
|
||||
if (!this.store.entity()?.license?.expires_at) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
new Date().toDateString() >
|
||||
new Date(this.store.entity()?.license?.expires_at || '').toDateString()
|
||||
) {
|
||||
return licenseStatus.EXPIRED;
|
||||
}
|
||||
return licenseStatus.ACTIVE;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user