feat(consumers): implement consumer and POS stores with breadcrumb management
- Added ConsumerStore and PosStore to manage state and data fetching for consumers and POS entities. - Implemented breadcrumb functionality in both stores to enhance navigation. - Created views for consumer accounts, business activities, complexes, and poses with respective components. - Developed single view components for detailed display and editing of consumer and POS data. - Introduced charge account management components in the super admin module, including forms and lists for charge transactions. - Established API routes and services for handling charge account transactions.
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<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.tax_id" name="tax_id" />
|
<app-input label="کد شعبه" [control]="form.controls.branch_code" name="branch_code" />
|
||||||
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
|||||||
initForm = () => {
|
initForm = () => {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
name: [this.initialValues?.name || '', [Validators.required]],
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
tax_id: [this.initialValues?.tax_id || '', [Validators.required]],
|
branch_code: [this.initialValues?.branch_code || ''],
|
||||||
address: [this.initialValues?.address || '', [Validators.required]],
|
address: [this.initialValues?.address || '', [Validators.required]],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -33,7 +33,7 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
|||||||
form = this.initForm();
|
form = this.initForm();
|
||||||
|
|
||||||
get preparedTitle() {
|
get preparedTitle() {
|
||||||
return `ویرایش فروشگاه ${this.initialValues?.name}`;
|
return `ویرایش شعبه ${this.initialValues?.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
override ngOnChanges(): void {
|
override ngOnChanges(): void {
|
||||||
|
|||||||
+2
-2
@@ -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()"
|
||||||
[showDetails]="true"
|
[showDetails]="true"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const consumerComplexesNamedRoutes: NamedRoutes<TComplexesRouteNames> = {
|
|||||||
loadComponent: () =>
|
loadComponent: () =>
|
||||||
import('../../views/complexes/list.component').then((m) => m.ConsumerComplexesComponent),
|
import('../../views/complexes/list.component').then((m) => m.ConsumerComplexesComponent),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'فروشگاهها',
|
title: 'شعب',
|
||||||
pagePath: (businessId: string) => baseUrl(businessId),
|
pagePath: (businessId: string) => baseUrl(businessId),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -21,7 +21,7 @@ export const consumerComplexesNamedRoutes: NamedRoutes<TComplexesRouteNames> = {
|
|||||||
loadComponent: () =>
|
loadComponent: () =>
|
||||||
import('../../views/complexes/single.component').then((m) => m.ConsumerComplexComponent),
|
import('../../views/complexes/single.component').then((m) => m.ConsumerComplexComponent),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'فروشگاه',
|
title: 'شعبه',
|
||||||
pagePath: (businessId: string, complexId: string) => `${baseUrl(businessId)}/${complexId}`,
|
pagePath: (businessId: string, complexId: string) => `${baseUrl(businessId)}/${complexId}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
export interface IComplexRawResponse {
|
export interface IComplexRawResponse {
|
||||||
name: string;
|
name: string;
|
||||||
address: string;
|
address: string;
|
||||||
tax_id: string;
|
branch_code: string;
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
export interface IComplexResponse extends IComplexRawResponse {}
|
export interface IComplexResponse extends IComplexRawResponse {}
|
||||||
@@ -9,5 +9,5 @@ export interface IComplexResponse extends IComplexRawResponse {}
|
|||||||
export interface IComplexRequest {
|
export interface IComplexRequest {
|
||||||
name: string;
|
name: string;
|
||||||
address: string;
|
address: string;
|
||||||
tax_id: string;
|
branch_code: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import ISummary from '@/core/models/summary';
|
|||||||
export interface IBusinessActivityRawResponse {
|
export interface IBusinessActivityRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
economic_code: string;
|
||||||
guild: ISummary;
|
guild: ISummary;
|
||||||
}
|
}
|
||||||
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
||||||
|
|
||||||
export interface IBusinessActivityRequest {
|
export interface IBusinessActivityRequest {
|
||||||
|
economic_code: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -1,9 +1,8 @@
|
|||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<app-card-data cardTitle="اطلاعات فروشگاه" [editable]="true" [(editMode)]="editMode">
|
<app-card-data cardTitle="اطلاعات شعبه" [editable]="true" [(editMode)]="editMode">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<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]="complex()?.name" />
|
<app-key-value label="عنوان" [value]="complex()?.name" />
|
||||||
<app-key-value label="کد مالیاتی" [value]="complex()?.tax_id" />
|
|
||||||
<app-key-value label="آدرس" [value]="complex()?.address" />
|
<app-key-value label="آدرس" [value]="complex()?.address" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<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]="business()?.name" />
|
<app-key-value label="عنوان" [value]="business()?.name" />
|
||||||
|
<app-key-value label="کد اقتصادی" [value]="business()?.economic_code" />
|
||||||
<app-key-value label="صنف" [value]="business()?.guild?.name" />
|
<app-key-value label="صنف" [value]="business()?.guild?.name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+2
-2
@@ -27,9 +27,9 @@ export class ConsumerCustomerSaleInvoiceListComponent extends AbstractList<ICust
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'pos',
|
field: 'pos',
|
||||||
header: 'فروشگاه',
|
header: 'شعبه',
|
||||||
customDataModel(item: ICustomerSaleInvoicesResponse) {
|
customDataModel(item: ICustomerSaleInvoicesResponse) {
|
||||||
return `${item.pos.complex.business_activity.name}، فروشگاه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
return `${item.pos.complex.business_activity.name}، شعبه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export class ConsumerPosListComponent extends AbstractList<IPosResponse> {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'complex',
|
field: 'complex',
|
||||||
header: 'عنوان فروشگاه',
|
header: 'عنوان شعبه',
|
||||||
type: 'nested',
|
type: 'nested',
|
||||||
nestedPath: 'complex.name',
|
nestedPath: 'complex.name',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export class ConsumerSaleInvoiceListComponent extends AbstractList<IConsumerSale
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'pos',
|
field: 'pos',
|
||||||
header: 'فروشگاه',
|
header: 'شعبه',
|
||||||
customDataModel(item: IConsumerSaleInvoicesResponse) {
|
customDataModel(item: IConsumerSaleInvoicesResponse) {
|
||||||
return `${item.pos.complex.business_activity.name}، فروشگاه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
return `${item.pos.complex.business_activity.name}، شعبه ${item.pos.complex.name}، پایانهی فروش ${item.pos.name}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const PARTNER_MENU_ITEMS = [
|
|||||||
{
|
{
|
||||||
label: 'مشتریان',
|
label: 'مشتریان',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-home',
|
||||||
routerLink: ['/partner/customers'],
|
routerLink: ['/partner/consumers'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<p-dialog
|
||||||
|
header="فرم کاربر"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
|
<app-input label="نام کاربری" [control]="form.controls.username" name="username" />
|
||||||
|
<app-enum-select [control]="form.controls.role" name="role" type="consumerRole" />
|
||||||
|
<uikit-field label="رمز عبور" class="" [control]="form.controls.password">
|
||||||
|
<p-password
|
||||||
|
id="password1"
|
||||||
|
name="password"
|
||||||
|
formControlName="password"
|
||||||
|
autocomplete="password"
|
||||||
|
[toggleMask]="true"
|
||||||
|
[fluid]="true"
|
||||||
|
[feedback]="false"
|
||||||
|
[invalid]="form.controls.password.touched && form.controls.password.invalid"
|
||||||
|
/>
|
||||||
|
<span class="text-xs mt-2 text-muted-color">
|
||||||
|
رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.
|
||||||
|
</span>
|
||||||
|
</uikit-field>
|
||||||
|
|
||||||
|
<uikit-field label="تکرار رمز عبور" class="" [control]="form.controls.confirmPassword">
|
||||||
|
<p-password
|
||||||
|
id="confirmPassword"
|
||||||
|
name="confirmPassword"
|
||||||
|
formControlName="confirmPassword"
|
||||||
|
autocomplete="new-password"
|
||||||
|
[toggleMask]="true"
|
||||||
|
[fluid]="true"
|
||||||
|
[feedback]="false"
|
||||||
|
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
|
||||||
|
/>
|
||||||
|
</uikit-field>
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { MustMatch, password } from '@/core/validators';
|
||||||
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { UikitFieldComponent } from '@/uikit';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { Password } from 'primeng/password';
|
||||||
|
import { IConsumerAccountRequest, IConsumerAccountResponse } from '../../models';
|
||||||
|
import { PartnerConsumerAccountsService } from '../../services/accounts.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-account-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
UikitFieldComponent,
|
||||||
|
Password,
|
||||||
|
EnumSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ConsumerAccountFormComponent extends AbstractFormDialog<
|
||||||
|
IConsumerAccountRequest,
|
||||||
|
IConsumerAccountResponse
|
||||||
|
> {
|
||||||
|
private readonly service = inject(PartnerConsumerAccountsService);
|
||||||
|
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() accountId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.fb.group(
|
||||||
|
{
|
||||||
|
username: [this.initialValues?.username || '', [Validators.required]],
|
||||||
|
password: ['', [password()]],
|
||||||
|
confirmPassword: [''],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validators: [MustMatch('password', 'confirmPassword')],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this.fb.group(
|
||||||
|
{
|
||||||
|
username: [this.initialValues?.username || '', [Validators.required]],
|
||||||
|
role: ['', [Validators.required]],
|
||||||
|
password: ['', [Validators.required, password()]],
|
||||||
|
confirmPassword: ['', [Validators.required]],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validators: [MustMatch('password', 'confirmPassword')],
|
||||||
|
},
|
||||||
|
) as any;
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
override ngOnChanges(): void {
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
submitForm() {
|
||||||
|
const formValue = this.form.value as IConsumerAccountRequest;
|
||||||
|
// @ts-ignore
|
||||||
|
const { confirmPassword, ...rest } = formValue;
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.consumerId, this.accountId, rest);
|
||||||
|
}
|
||||||
|
return this.service.create(this.consumerId, rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت حسابهای کاربری"
|
||||||
|
[addNewCtaLabel]="'افزودن حساب کاربری جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="حساب کاربریای یافت نشد."
|
||||||
|
emptyPlaceholderDescription="برای افزودن حساب کاربری جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showDetails]="true"
|
||||||
|
[showAdd]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
>
|
||||||
|
</app-page-data-list>
|
||||||
|
<partner-consumer-account-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[consumerId]="consumerId"
|
||||||
|
[accountId]="selectedItemForEdit()?.id || ''"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import {
|
||||||
|
IColumn,
|
||||||
|
PageDataListComponent,
|
||||||
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { IConsumerAccountResponse } from '../../models';
|
||||||
|
import { PartnerConsumerAccountsService } from '../../services/accounts.service';
|
||||||
|
import { ConsumerAccountFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-account-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, ConsumerAccountFormComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerAccountListComponent extends AbstractList<IConsumerAccountResponse> {
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||||
|
{
|
||||||
|
field: 'username',
|
||||||
|
header: 'نام کاربری',
|
||||||
|
type: 'nested',
|
||||||
|
nestedPath: 'account.username',
|
||||||
|
},
|
||||||
|
{ field: 'role', header: 'نوع حساب' },
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
header: 'وضعیت',
|
||||||
|
type: 'nested',
|
||||||
|
nestedPath: 'account.status',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
private readonly service = inject(PartnerConsumerAccountsService);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.consumerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<p-dialog
|
||||||
|
[header]="preparedTitle"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<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.economic_code" name="economic_code" />
|
||||||
|
<catalog-guild-select label="صنف" [control]="form.controls.guild_id" name="guild_id" />
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { CatalogGuildSelectComponent } from '@/shared/catalog/guild/components/select.component';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { IBusinessActivityRequest, IBusinessActivityResponse } from '../../models';
|
||||||
|
import { PartnerConsumerBusinessActivitiesService } from '../../services/businessActivities.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-businessActivities-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
CatalogGuildSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ConsumerBusinessActivitiesFormComponent extends AbstractFormDialog<
|
||||||
|
IBusinessActivityRequest,
|
||||||
|
IBusinessActivityResponse
|
||||||
|
> {
|
||||||
|
private readonly service = inject(PartnerConsumerBusinessActivitiesService);
|
||||||
|
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() businessActivityId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
return this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
economic_code: [this.initialValues?.economic_code || '', [Validators.required]],
|
||||||
|
guild_id: [this.initialValues?.guild?.id || '', [Validators.required]],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
get preparedTitle() {
|
||||||
|
return `${this.editMode ? 'ویرایش' : 'ایجاد'} فعالیت اقتصادی`;
|
||||||
|
}
|
||||||
|
|
||||||
|
override ngOnChanges(): void {
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
submitForm() {
|
||||||
|
const formValue = this.form.value as IBusinessActivityRequest;
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.consumerId, this.businessActivityId, formValue);
|
||||||
|
}
|
||||||
|
return this.service.create(this.consumerId, formValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-businessActivity-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class PartnerUserBusinessActivityLayoutComponent {
|
||||||
|
private readonly store = inject(BusinessActivityStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly businessActivity = computed(() => this.store.entity());
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = computed(() => this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت فعالیتهای اقتصادی"
|
||||||
|
[addNewCtaLabel]="'افزودن فعالیت اقتصادی جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="فعالیت اقتصادیای یافت نشد."
|
||||||
|
emptyPlaceholderDescription="برای افزودن فعالیت اقتصادی جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showDetails]="true"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
(onDetails)="toSinglePage($event)"
|
||||||
|
>
|
||||||
|
</app-page-data-list>
|
||||||
|
<partner-consumer-businessActivities-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[consumerId]="consumerId"
|
||||||
|
[businessActivityId]="selectedItemForEdit()?.id || ''"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import {
|
||||||
|
IColumn,
|
||||||
|
PageDataListComponent,
|
||||||
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { partnerConsumerBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { IBusinessActivityResponse } from '../../models';
|
||||||
|
import { PartnerConsumerBusinessActivitiesService } from '../../services/businessActivities.service';
|
||||||
|
import { ConsumerBusinessActivitiesFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-businessActivities-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, ConsumerBusinessActivitiesFormComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerBusinessActivitiesComponent extends AbstractList<IBusinessActivityResponse> {
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{ field: 'guild', header: 'صنف', type: 'nested', nestedPath: 'name' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly service = inject(PartnerConsumerBusinessActivitiesService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.consumerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(item: IBusinessActivityResponse) {
|
||||||
|
this.router.navigateByUrl(
|
||||||
|
partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
|
||||||
|
this.consumerId,
|
||||||
|
item.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<p-dialog
|
||||||
|
[header]="preparedTitle"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<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.branch_code" name="branch_code" />
|
||||||
|
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { IComplexRequest, IComplexResponse } from '../../models';
|
||||||
|
import { PartnerComplexesService } from '../../services/complexes.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-complex-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
||||||
|
IComplexRequest,
|
||||||
|
IComplexResponse
|
||||||
|
> {
|
||||||
|
private readonly service = inject(PartnerComplexesService);
|
||||||
|
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() businessActivityId!: string;
|
||||||
|
@Input() complexId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
return this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
branch_code: [this.initialValues?.branch_code || ''],
|
||||||
|
address: [this.initialValues?.address || '', [Validators.required]],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
get preparedTitle() {
|
||||||
|
return `${this.editMode ? 'ویرایش' : 'ایجاد'} شعبه`;
|
||||||
|
}
|
||||||
|
|
||||||
|
override ngOnChanges(): void {
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
submitForm() {
|
||||||
|
const formValue = this.form.value as IComplexRequest;
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(
|
||||||
|
this.consumerId,
|
||||||
|
this.businessActivityId,
|
||||||
|
this.complexId,
|
||||||
|
formValue,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this.service.create(this.consumerId, this.businessActivityId, formValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { ComplexStore } from '../../store/complex.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-complex-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class PartnerConsumerComplexLayoutComponent {
|
||||||
|
private readonly store = inject(ComplexStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = computed(() => this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = computed(() => this.pageParams()['complexId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId(), this.complexId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت شعب"
|
||||||
|
[addNewCtaLabel]="'افزودن شعبه جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="شعبهای یافت نشد."
|
||||||
|
emptyPlaceholderDescription="برای افزودن شعبه جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showDetails]="true"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
(onDetails)="toSinglePage($event)"
|
||||||
|
>
|
||||||
|
</app-page-data-list>
|
||||||
|
<partner-consumer-complex-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[consumerId]="consumerId"
|
||||||
|
[businessActivityId]="businessId"
|
||||||
|
[complexId]="selectedItemForEdit()?.id || ''"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import {
|
||||||
|
IColumn,
|
||||||
|
PageDataListComponent,
|
||||||
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { partnerConsumerComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
|
import { IComplexResponse } from '../../models';
|
||||||
|
import { PartnerComplexesService } from '../../services/complexes.service';
|
||||||
|
import { ConsumerComplexFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-complexes-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, ConsumerComplexFormComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerComplexesComponent extends AbstractList<IComplexResponse> {
|
||||||
|
@Input() consumerId!: string;
|
||||||
|
@Input() businessId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly service = inject(PartnerComplexesService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.consumerId, this.businessId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(item: IComplexResponse) {
|
||||||
|
this.router.navigateByUrl(
|
||||||
|
partnerConsumerComplexesNamedRoutes.complex.meta.pagePath!(
|
||||||
|
this.consumerId,
|
||||||
|
this.businessId,
|
||||||
|
item.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<p-dialog
|
||||||
|
[header]="preparedTitle()"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
|
<app-input label="نام" [control]="form.controls.first_name" name="first_name" />
|
||||||
|
<app-input label="نام خانوادگی" [control]="form.controls.last_name" name="last_name" />
|
||||||
|
<app-input label="موبایل" [control]="form.controls.mobile_number" name="mobile_number" type="mobile" />
|
||||||
|
<app-input label="کد ملی" [control]="form.controls.national_code" name="national_code" type="nationalId" />
|
||||||
|
|
||||||
|
@if (!editMode) {
|
||||||
|
<p-divider align="center"> اطلاعات ورود </p-divider>
|
||||||
|
<!-- @ts-ignore -->
|
||||||
|
<app-input label="نام کاربری" [control]="form.controls.username" name="username" [isLtrInput]="true" />
|
||||||
|
<uikit-field label="رمز عبور" class="" [control]="form.controls.password">
|
||||||
|
<p-password
|
||||||
|
id="password1"
|
||||||
|
name="password"
|
||||||
|
formControlName="password"
|
||||||
|
autocomplete="password"
|
||||||
|
[toggleMask]="true"
|
||||||
|
[fluid]="true"
|
||||||
|
[feedback]="false"
|
||||||
|
[invalid]="form.controls.password.touched && form.controls.password.invalid"
|
||||||
|
/>
|
||||||
|
<span class="text-xs mt-1 text-muted-color">
|
||||||
|
رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.
|
||||||
|
</span>
|
||||||
|
</uikit-field>
|
||||||
|
|
||||||
|
<uikit-field label="تکرار رمز عبور" class="" [control]="form.controls.confirmPassword">
|
||||||
|
<p-password
|
||||||
|
id="confirmPassword"
|
||||||
|
name="confirmPassword"
|
||||||
|
formControlName="confirmPassword"
|
||||||
|
autocomplete="new-password"
|
||||||
|
[toggleMask]="true"
|
||||||
|
[fluid]="true"
|
||||||
|
[feedback]="false"
|
||||||
|
[invalid]="form.controls.confirmPassword.touched && form.controls.confirmPassword.invalid"
|
||||||
|
/>
|
||||||
|
</uikit-field>
|
||||||
|
<p-divider align="center"> اطلاعات لایسنس </p-divider>
|
||||||
|
<uikit-datepicker
|
||||||
|
label="تاریخ شروع لایسنس"
|
||||||
|
[control]="form.controls.license_starts_at"
|
||||||
|
name="license_starts_at"
|
||||||
|
hint="مدت زمان لایسنسها ۱ ساله هستند."
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import { mobileValidator, MustMatch } from '@/core/validators';
|
||||||
|
import { nationalIdValidator } from '@/core/validators/national-id.validator';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { UikitFieldComponent, UikitFlatpickrJalaliComponent } from '@/uikit';
|
||||||
|
import { nowJalali } from '@/utils';
|
||||||
|
import { Component, computed, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { Divider } from 'primeng/divider';
|
||||||
|
import { Password } from 'primeng/password';
|
||||||
|
import { IConsumerRequest, IConsumerResponse } from '../models';
|
||||||
|
import { ConsumersService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
Divider,
|
||||||
|
UikitFieldComponent,
|
||||||
|
Password,
|
||||||
|
UikitFlatpickrJalaliComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ConsumerUserFormComponent extends AbstractFormDialog<
|
||||||
|
IConsumerRequest,
|
||||||
|
IConsumerResponse
|
||||||
|
> {
|
||||||
|
@Input() consumerId?: string;
|
||||||
|
private service = inject(ConsumersService);
|
||||||
|
|
||||||
|
preparedTitle = computed(() => `${this.editMode ? 'ویرایش' : 'ایجاد'} مشتری`);
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
const form = this.fb.group({
|
||||||
|
first_name: [this.initialValues?.first_name || '', [Validators.required]],
|
||||||
|
last_name: [this.initialValues?.last_name || '', [Validators.required]],
|
||||||
|
mobile_number: [
|
||||||
|
this.initialValues?.mobile_number || '',
|
||||||
|
[Validators.required, mobileValidator()],
|
||||||
|
],
|
||||||
|
national_code: [
|
||||||
|
this.initialValues?.national_code || '',
|
||||||
|
[Validators.required, nationalIdValidator()],
|
||||||
|
],
|
||||||
|
username: [''],
|
||||||
|
password: [''],
|
||||||
|
confirmPassword: [''],
|
||||||
|
license_starts_at: [nowJalali(), [Validators.required]],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.editMode) {
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('username');
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('password');
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('confirmPassword');
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('license_starts_at');
|
||||||
|
form.removeValidators([MustMatch('password', 'confirmPassword')]);
|
||||||
|
} else {
|
||||||
|
form.addControl(
|
||||||
|
'username',
|
||||||
|
this.fb.control<string>('', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
form.addControl(
|
||||||
|
'password',
|
||||||
|
this.fb.control<string>('', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
form.addControl(
|
||||||
|
'confirmPassword',
|
||||||
|
this.fb.control<string>('', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
form.addControl(
|
||||||
|
'license_starts_at',
|
||||||
|
this.fb.control<string>(nowJalali(), {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
form.addValidators([MustMatch('password', 'confirmPassword')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return form;
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
override ngOnChanges() {
|
||||||
|
this.form.patchValue(this.initialValues || {});
|
||||||
|
if (this.editMode && !this.consumerId) {
|
||||||
|
throw 'missing some arguments';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
override submitForm(payload: IConsumerRequest) {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.consumerId!, payload);
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
const { confirmPassword, ...rest } = payload;
|
||||||
|
return this.service.create(rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { ConsumerStore } from '../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class ConsumerLayoutComponent {
|
||||||
|
private readonly store = inject(ConsumerStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly consumerId = signal<string>(this.route.snapshot.paramMap.get('consumerId')!);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly consumer = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<p-dialog
|
||||||
|
[header]="preparedTitle()"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
|
<uikit-datepicker
|
||||||
|
label="تاریخ شروع لایسنس"
|
||||||
|
[control]="form.controls.starts_at"
|
||||||
|
name="starts_at"
|
||||||
|
hint="مدت زمان لایسنسها ۱ ساله هستند."
|
||||||
|
/>
|
||||||
|
<!-- <uikit-datepicker label="تاریخ انقضای لایسنس" [control]="form.controls.expires_at" name="expires_at" /> -->
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { UikitFlatpickrJalaliComponent } from '@/uikit';
|
||||||
|
import { Component, computed, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { ILicenseRequest, ILicenseResponse } from '../../models';
|
||||||
|
import { LicensesService } from '../../services/licenses.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-license-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, UikitFlatpickrJalaliComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerLicenseFormComponent extends AbstractFormDialog<
|
||||||
|
ILicenseRequest,
|
||||||
|
ILicenseResponse
|
||||||
|
> {
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input() licenseId?: string;
|
||||||
|
private service = inject(LicensesService);
|
||||||
|
|
||||||
|
preparedTitle = computed(() => `${this.editMode ? 'ویرایش' : 'ایجاد'} لایسنس`);
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
const form = this.fb.group({
|
||||||
|
starts_at: [this.initialValues?.starts_at || ''],
|
||||||
|
partner_id: [this.initialValues?.partner?.id || ''],
|
||||||
|
});
|
||||||
|
|
||||||
|
return form;
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
override ngOnChanges() {
|
||||||
|
this.form.patchValue({ ...this.initialValues });
|
||||||
|
if (this.editMode && !this.licenseId) {
|
||||||
|
throw 'missing some arguments';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
override submitForm(payload: ILicenseRequest) {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.consumerId!, this.licenseId!, payload);
|
||||||
|
}
|
||||||
|
return this.service.create(this.consumerId, payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<p-dialog
|
||||||
|
[header]="preparedTitle"
|
||||||
|
[(visible)]="visible"
|
||||||
|
[modal]="true"
|
||||||
|
[style]="{ width: '500px' }"
|
||||||
|
[closable]="true"
|
||||||
|
(onHide)="close()"
|
||||||
|
>
|
||||||
|
<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.serial" name="serial" />
|
||||||
|
<!-- <app-input label="مدل دستگاه" [control]="form.controls.model" name="model" /> -->
|
||||||
|
<app-enum-select [control]="form.controls.pos_type" type="posType" name="pos_type" />
|
||||||
|
@if (form.controls.pos_type.value === "PSP") {
|
||||||
|
<catalog-device-select [control]="form.controls.device_id" />
|
||||||
|
<catalog-provider-select [control]="form.controls.provider_id" />
|
||||||
|
}
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||||
|
import { CatalogProviderSelectComponent } from '@/shared/catalog';
|
||||||
|
import { CatalogDeviceSelectComponent } from '@/shared/catalog/devices';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { IPosRequest, IPosResponse } from '../../models';
|
||||||
|
import { PartnerPosesService } from '../../services/poses.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-pos-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
CatalogDeviceSelectComponent,
|
||||||
|
CatalogProviderSelectComponent,
|
||||||
|
EnumSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IPosResponse> {
|
||||||
|
private readonly service = inject(PartnerPosesService);
|
||||||
|
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input({ required: true }) businessActivityId!: string;
|
||||||
|
@Input({ required: true }) complexId!: string;
|
||||||
|
@Input() posId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
const form = this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
serial: [this.initialValues?.serial || '', [Validators.required]],
|
||||||
|
// model: [this.initialValues?.model || '', [Validators.required]],
|
||||||
|
pos_type: [this.initialValues?.pos_type || '', [Validators.required]],
|
||||||
|
device_id: [this.initialValues?.device?.id || ''],
|
||||||
|
provider_id: [this.initialValues?.provider?.id || ''],
|
||||||
|
});
|
||||||
|
form.controls.pos_type.valueChanges.subscribe((value) => {
|
||||||
|
if (value === 'PSP') {
|
||||||
|
form.addControl(
|
||||||
|
'device_id',
|
||||||
|
this.fb.control<string>(this.initialValues?.device?.id ?? '', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
form.addControl(
|
||||||
|
'provider_id',
|
||||||
|
this.fb.control<string>(this.initialValues?.provider?.id ?? '', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('device_id');
|
||||||
|
// @ts-ignore
|
||||||
|
form.removeControl('provider_id');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return form;
|
||||||
|
};
|
||||||
|
|
||||||
|
form = this.initForm();
|
||||||
|
|
||||||
|
get preparedTitle() {
|
||||||
|
return `${this.editMode ? 'ویرایش' : 'ایجاد'} پایانه فروش`;
|
||||||
|
}
|
||||||
|
|
||||||
|
override ngOnChanges(): void {
|
||||||
|
this.form = this.initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
submitForm() {
|
||||||
|
const formValue = this.form.value as IPosRequest;
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.businessActivityId, this.complexId, this.posId, formValue);
|
||||||
|
}
|
||||||
|
return this.service.create(this.businessActivityId, this.complexId, formValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { PosStore } from '../../store/pos.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-pos-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class PartnerConsumerPosLayoutComponent {
|
||||||
|
private readonly store = inject(PosStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = computed(() => this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = computed(() => this.pageParams()['complexId']!);
|
||||||
|
readonly posId = computed(() => this.pageParams()['posId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId(), this.complexId(), this.posId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت پایانههای فروش"
|
||||||
|
[addNewCtaLabel]="'افزودن پایانهی فروش جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="پایانهی فروشی یافت نشد."
|
||||||
|
emptyPlaceholderDescription="برای افزودن پایانهی فروش جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showDetails]="true"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
(onDetails)="toSinglePage($event)"
|
||||||
|
>
|
||||||
|
</app-page-data-list>
|
||||||
|
<partner-consumer-pos-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[consumerId]="consumerId"
|
||||||
|
[businessActivityId]="businessId"
|
||||||
|
[complexId]="complexId"
|
||||||
|
[posId]="selectedItemForEdit()?.id || ''"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import {
|
||||||
|
IColumn,
|
||||||
|
PageDataListComponent,
|
||||||
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { partnerConsumerPosesNamedRoutes } from '../../constants/routes/poses';
|
||||||
|
import { IPosResponse } from '../../models';
|
||||||
|
import { PartnerPosesService } from '../../services/poses.service';
|
||||||
|
import { ConsumerPosFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-poses-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, ConsumerPosFormComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerPosesComponent extends AbstractList<IPosResponse> {
|
||||||
|
@Input({ required: true }) consumerId!: string;
|
||||||
|
@Input({ required: true }) businessId!: string;
|
||||||
|
@Input({ required: true }) complexId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{ field: 'serial', header: 'شماره سریال' },
|
||||||
|
{ field: 'device', header: 'دستگاه', type: 'nested', nestedPath: 'device.name' },
|
||||||
|
{ field: 'pos_type', header: 'نوع دستگاه' },
|
||||||
|
{ field: 'provider', header: 'ارایهدهنده', type: 'nested', nestedPath: 'provider.name' },
|
||||||
|
{ field: 'status', header: 'وضعیت' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly service = inject(PartnerPosesService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.businessId, this.complexId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(item: IPosResponse) {
|
||||||
|
this.router.navigateByUrl(
|
||||||
|
partnerConsumerPosesNamedRoutes.pos.meta.pagePath!(
|
||||||
|
this.consumerId,
|
||||||
|
this.businessId,
|
||||||
|
this.complexId,
|
||||||
|
item.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const baseUrl = (consumerId: string) => `/api/v1/partner/consumers/${consumerId}/accounts`;
|
||||||
|
|
||||||
|
export const CONSUMER_ACCOUNTS_API_ROUTES = {
|
||||||
|
list: (consumerId: string) => `${baseUrl(consumerId)}`,
|
||||||
|
single: (consumerId: string, accountId: string) => `${baseUrl(consumerId)}/${accountId}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
const baseUrl = (consumerId: string) => `/api/v1/partner/consumers/${consumerId}/business_activities`;
|
||||||
|
|
||||||
|
export const BUSINESS_ACTIVITIES_API_ROUTES = {
|
||||||
|
list: (consumerId: string) => `${baseUrl(consumerId)}`,
|
||||||
|
single: (consumerId: string, business_activity_id: string) =>
|
||||||
|
`${baseUrl(consumerId)}/${business_activity_id}`,
|
||||||
|
};
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
const baseUrl = (consumerId: string, business_activity_id: string) =>
|
||||||
|
`/api/v1/partner/consumers/${consumerId}/business_activities/${business_activity_id}/complexes`;
|
||||||
|
|
||||||
|
export const BUSINESS_ACTIVITY_COMPLEXES_API_ROUTES = {
|
||||||
|
list: (consumerId: string, business_activity_id: string) =>
|
||||||
|
`${baseUrl(consumerId, business_activity_id)}`,
|
||||||
|
single: (consumerId: string, business_activity_id: string, complex_id: string) =>
|
||||||
|
`${baseUrl(consumerId, business_activity_id)}/${complex_id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const baseUrl = (business_activity_id: string, complex_id: string) =>
|
||||||
|
`/api/v1/partner/business_activities/${business_activity_id}/complexes/${complex_id}/poses`;
|
||||||
|
|
||||||
|
export const COMPLEX_POSES_API_ROUTES = {
|
||||||
|
list: (business_activity_id: string, complex_id: string) =>
|
||||||
|
`${baseUrl(business_activity_id, complex_id)}`,
|
||||||
|
single: (business_activity_id: string, complex_id: string, posId: string) =>
|
||||||
|
`${baseUrl(business_activity_id, complex_id)}/${posId}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export * from './accounts';
|
||||||
|
export * from './businessActivities';
|
||||||
|
export * from './businessActivityComplexes';
|
||||||
|
export * from './complexPoses';
|
||||||
|
export * from './licenses';
|
||||||
|
|
||||||
|
const baseUrl = '/api/v1/partner/consumers';
|
||||||
|
|
||||||
|
export const CONSUMERS_API_ROUTES = {
|
||||||
|
list: () => `${baseUrl}`,
|
||||||
|
single: (id: string) => `${baseUrl}/${id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const baseUrl = (consumerId: string) => `/api/v1/partner/consumers/${consumerId}/licenses`;
|
||||||
|
|
||||||
|
export const CONSUMER_LICENSES_API_ROUTES = {
|
||||||
|
list: (consumerId: string) => baseUrl(consumerId),
|
||||||
|
single: (consumerId: string, licenseId: string) => `${baseUrl(consumerId)}/${licenseId}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apiRoutes';
|
||||||
|
export * from './routes';
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export type TAccountsRouteNames = 'accounts' | 'account';
|
||||||
|
|
||||||
|
export const partnerConsumerAccountsNamedRoutes: NamedRoutes<TAccountsRouteNames> = {
|
||||||
|
accounts: {
|
||||||
|
path: 'accounts',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/accounts/list.component').then((m) => m.ConsumerAccountsComponent),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'حسابهای کاربری',
|
||||||
|
pagePath: (consumerId: string) => `/partner/consumers/${consumerId}/accounts`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
path: 'accounts/:accountId',
|
||||||
|
meta: {
|
||||||
|
title: 'حساب کاربری',
|
||||||
|
pagePath: (consumerId: string, accountId: string) =>
|
||||||
|
`/partner/consumers/${consumerId}/accounts/${accountId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PARTNER_CONSUMER_ACCOUNTS_ROUTES: Routes = [
|
||||||
|
partnerConsumerAccountsNamedRoutes.accounts,
|
||||||
|
];
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { PARTNER_CONSUMER_COMPLEXES_ROUTES } from './complexes';
|
||||||
|
|
||||||
|
export type TBusinessActivitiesRouteNames = 'businessActivities' | 'businessActivity';
|
||||||
|
|
||||||
|
export const partnerConsumerBusinessActivitiesNamedRoutes: NamedRoutes<TBusinessActivitiesRouteNames> =
|
||||||
|
{
|
||||||
|
businessActivities: {
|
||||||
|
path: 'business_activities',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/list.component').then(
|
||||||
|
(m) => m.PartnerUserBusinessActivitiesComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیتهای اقتصادی',
|
||||||
|
pagePath: (consumerId: string) =>
|
||||||
|
`/partner/consumers/${consumerId}/business_activities`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
businessActivity: {
|
||||||
|
path: 'business_activities/:businessActivityId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/single.component').then(
|
||||||
|
(m) => m.PartnerUserBusinessActivityComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیت اقتصادی',
|
||||||
|
pagePath: (consumerId: string, businessId: string) =>
|
||||||
|
`/partner/consumers/${consumerId}/business_activities/${businessId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES: Routes = [
|
||||||
|
partnerConsumerBusinessActivitiesNamedRoutes.businessActivities,
|
||||||
|
{
|
||||||
|
path: partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/businessActivities/layout.component').then(
|
||||||
|
(m) => m.PartnerUserBusinessActivityLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent:
|
||||||
|
partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.loadComponent,
|
||||||
|
},
|
||||||
|
...PARTNER_CONSUMER_COMPLEXES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { PARTNER_CONSUMER_POSES_ROUTES } from './poses';
|
||||||
|
|
||||||
|
export type TComplexesRouteNames = 'complexes' | 'complex';
|
||||||
|
|
||||||
|
const baseUrl = (consumerId: string, businessId: string) =>
|
||||||
|
`/partner/consumers/${consumerId}/business_activities/${businessId}/complexes`;
|
||||||
|
|
||||||
|
export const partnerConsumerComplexesNamedRoutes: NamedRoutes<TComplexesRouteNames> = {
|
||||||
|
complexes: {
|
||||||
|
path: 'complexes',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/complexes/list.component').then((m) => m.PartnerUserComplexesComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'شعب',
|
||||||
|
pagePath: (consumerId: string, businessId: string) => baseUrl(consumerId, businessId),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
complex: {
|
||||||
|
path: 'complexes/:complexId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/complexes/single.component').then((m) => m.PartnerUserComplexComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'شعبه',
|
||||||
|
pagePath: (consumerId: string, businessId: string, complexId: string) =>
|
||||||
|
`${baseUrl(consumerId, businessId)}/${complexId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PARTNER_CONSUMER_COMPLEXES_ROUTES: Routes = [
|
||||||
|
partnerConsumerComplexesNamedRoutes.complexes,
|
||||||
|
{
|
||||||
|
path: partnerConsumerComplexesNamedRoutes.complex.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/complexes/layout.component').then(
|
||||||
|
(m) => m.PartnerConsumerComplexLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: partnerConsumerComplexesNamedRoutes.complex.loadComponent,
|
||||||
|
},
|
||||||
|
...PARTNER_CONSUMER_POSES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { PARTNER_CONSUMER_ACCOUNTS_ROUTES } from './accounts';
|
||||||
|
import { PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES } from './businessActivities';
|
||||||
|
|
||||||
|
export type TConsumersRouteNames = 'consumers' | 'consumer';
|
||||||
|
|
||||||
|
export const partnerConsumersNamedRoutes: NamedRoutes<TConsumersRouteNames> = {
|
||||||
|
consumers: {
|
||||||
|
path: 'consumers',
|
||||||
|
loadComponent: () => import('../../views/list.component').then((m) => m.ConsumersComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'مشتریان',
|
||||||
|
pagePath: () => '/partner/consumers',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
consumer: {
|
||||||
|
path: 'consumers/:consumerId',
|
||||||
|
loadComponent: () => import('../../views/single.component').then((m) => m.ConsumerComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'مشتری',
|
||||||
|
pagePath: (guildId: string) => `/partner/consumers/${guildId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PARTNER_CONSUMERS_ROUTES: Routes = [
|
||||||
|
partnerConsumersNamedRoutes.consumers,
|
||||||
|
{
|
||||||
|
path: 'consumers/:consumerId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/layout.component').then((m) => m.ConsumerLayoutComponent),
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/single.component').then((m) => m.ConsumerComponent),
|
||||||
|
},
|
||||||
|
...PARTNER_CONSUMER_ACCOUNTS_ROUTES,
|
||||||
|
...PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export type TPosesRouteNames = 'poses' | 'pos';
|
||||||
|
|
||||||
|
const baseUrl = (consumerId: string, businessId: string, complexId: string) =>
|
||||||
|
`/partner/consumers/${consumerId}/business_activities/${businessId}/complexes/${complexId}/poses`;
|
||||||
|
|
||||||
|
export const partnerConsumerPosesNamedRoutes: NamedRoutes<TPosesRouteNames> = {
|
||||||
|
poses: {
|
||||||
|
path: 'poses',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/poses/list.component').then((m) => m.PartnerUserPosesComponent),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'پایانههای فروش',
|
||||||
|
pagePath: (consumerId: string, businessId: string, complexId: string) =>
|
||||||
|
baseUrl(consumerId, businessId, complexId),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pos: {
|
||||||
|
path: 'poses/:posId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/poses/single.component').then((m) => m.PartnerUserPosComponent),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'پایانهی فروش',
|
||||||
|
pagePath: (consumerId: string, businessId: string, complexId: string, posId: string) =>
|
||||||
|
`${baseUrl(consumerId, businessId, complexId)}/${posId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PARTNER_CONSUMER_POSES_ROUTES: Routes = [
|
||||||
|
partnerConsumerPosesNamedRoutes.poses,
|
||||||
|
{
|
||||||
|
path: partnerConsumerPosesNamedRoutes.pos.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/poses/layout.component').then(
|
||||||
|
(m) => m.PartnerConsumerPosLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: partnerConsumerPosesNamedRoutes.pos.loadComponent,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { TAccountType } from '@/core/constants/accountTypes.const';
|
||||||
|
|
||||||
|
export interface IConsumerAccountRawResponse {
|
||||||
|
username: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface IConsumerAccountResponse extends IConsumerAccountRawResponse {}
|
||||||
|
|
||||||
|
export interface IConsumerAccountRequest {
|
||||||
|
username: string;
|
||||||
|
password?: string;
|
||||||
|
type: TAccountType;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import ISummary from '@/core/models/summary';
|
||||||
|
|
||||||
|
export interface IBusinessActivityRawResponse {
|
||||||
|
name: string;
|
||||||
|
economic_code: string;
|
||||||
|
guild: ISummary;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
||||||
|
|
||||||
|
export interface IBusinessActivityRequest {
|
||||||
|
name: string;
|
||||||
|
economic_code: string;
|
||||||
|
guild_id: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export interface IComplexRawResponse {
|
||||||
|
name: string;
|
||||||
|
address: string;
|
||||||
|
branch_code: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface IComplexResponse extends IComplexRawResponse {}
|
||||||
|
|
||||||
|
export interface IComplexRequest {
|
||||||
|
name: string;
|
||||||
|
address: string;
|
||||||
|
branch_code: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export * from './accounts_io';
|
||||||
|
export * from './businessActivities_io';
|
||||||
|
export * from './complexes_io';
|
||||||
|
export * from './io';
|
||||||
|
export * from './licenses_io';
|
||||||
|
export * from './poses_io';
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
export interface IConsumerRawResponse {
|
||||||
|
id: string;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
mobile_number: string;
|
||||||
|
national_code: string;
|
||||||
|
status: string;
|
||||||
|
created_at: string;
|
||||||
|
fullname: string;
|
||||||
|
license_info: ILicenseInfo;
|
||||||
|
}
|
||||||
|
export interface IConsumerResponse extends IConsumerRawResponse {}
|
||||||
|
|
||||||
|
export interface IConsumerRequest {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
mobile_number: string;
|
||||||
|
national_code: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
license_starts_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ILicenseInfo {
|
||||||
|
id: string;
|
||||||
|
starts_at: string;
|
||||||
|
expires_at: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import ISummary from '@/core/models/summary';
|
||||||
|
|
||||||
|
export interface ILicenseRawResponse {
|
||||||
|
id: string;
|
||||||
|
starts_at: string;
|
||||||
|
expires_at: string;
|
||||||
|
// status: TLicenseStatus;
|
||||||
|
partner?: ISummary;
|
||||||
|
}
|
||||||
|
export interface ILicenseResponse extends ILicenseRawResponse {}
|
||||||
|
|
||||||
|
export interface ILicenseRequest {
|
||||||
|
starts_at: string;
|
||||||
|
expires_at?: string;
|
||||||
|
// status: TLicenseStatus;
|
||||||
|
partner_id: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import ISummary from '@/core/models/summary';
|
||||||
|
|
||||||
|
export interface IPosRawResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
serial: string;
|
||||||
|
model?: string;
|
||||||
|
status: string;
|
||||||
|
pos_type: string;
|
||||||
|
complex: ISummary;
|
||||||
|
device?: ISummary;
|
||||||
|
provider?: ISummary;
|
||||||
|
}
|
||||||
|
export interface IPosResponse extends IPosRawResponse {}
|
||||||
|
|
||||||
|
export interface IPosRequest {
|
||||||
|
name: string;
|
||||||
|
serial: string;
|
||||||
|
model?: string;
|
||||||
|
status: string;
|
||||||
|
pos_type: string;
|
||||||
|
device_id: string;
|
||||||
|
provider_id: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { CONSUMER_ACCOUNTS_API_ROUTES } from '../constants';
|
||||||
|
import {
|
||||||
|
IConsumerAccountRawResponse,
|
||||||
|
IConsumerAccountRequest,
|
||||||
|
IConsumerAccountResponse,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PartnerConsumerAccountsService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = CONSUMER_ACCOUNTS_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(consumerId: string): Observable<IPaginatedResponse<IConsumerAccountResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IConsumerAccountRawResponse>>(
|
||||||
|
this.apiRoutes.list(consumerId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(consumerId: string, accountId: string): Observable<IConsumerAccountResponse> {
|
||||||
|
return this.http.get<IConsumerAccountRawResponse>(this.apiRoutes.single(consumerId, accountId));
|
||||||
|
}
|
||||||
|
|
||||||
|
create(consumerId: string, data: IConsumerAccountRequest): Observable<IConsumerAccountResponse> {
|
||||||
|
return this.http.post<IConsumerAccountResponse>(this.apiRoutes.list(consumerId), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
consumerId: string,
|
||||||
|
accountId: string,
|
||||||
|
data: IConsumerAccountRequest,
|
||||||
|
): Observable<IConsumerAccountResponse> {
|
||||||
|
return this.http.patch<IConsumerAccountResponse>(
|
||||||
|
this.apiRoutes.single(consumerId, accountId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { BUSINESS_ACTIVITIES_API_ROUTES } from '../constants/apiRoutes/businessActivities';
|
||||||
|
import {
|
||||||
|
IBusinessActivityRawResponse,
|
||||||
|
IBusinessActivityRequest,
|
||||||
|
IBusinessActivityResponse,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PartnerConsumerBusinessActivitiesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = BUSINESS_ACTIVITIES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(consumerId: string): Observable<IPaginatedResponse<IBusinessActivityResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IBusinessActivityRawResponse>>(
|
||||||
|
this.apiRoutes.list(consumerId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(consumerId: string, businessActivityId: string): Observable<IBusinessActivityResponse> {
|
||||||
|
return this.http.get<IBusinessActivityRawResponse>(
|
||||||
|
this.apiRoutes.single(consumerId, businessActivityId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(
|
||||||
|
consumerId: string,
|
||||||
|
data: IBusinessActivityRequest,
|
||||||
|
): Observable<IBusinessActivityResponse> {
|
||||||
|
return this.http.post<IBusinessActivityRawResponse>(this.apiRoutes.list(consumerId), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
consumerId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
data: IBusinessActivityRequest,
|
||||||
|
): Observable<IBusinessActivityResponse> {
|
||||||
|
return this.http.patch<IBusinessActivityRawResponse>(
|
||||||
|
this.apiRoutes.single(consumerId, businessActivityId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { BUSINESS_ACTIVITY_COMPLEXES_API_ROUTES } from '../constants/apiRoutes/businessActivityComplexes';
|
||||||
|
import { IComplexRawResponse, IComplexRequest, IComplexResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PartnerComplexesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = BUSINESS_ACTIVITY_COMPLEXES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(
|
||||||
|
consumerId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
): Observable<IPaginatedResponse<IComplexResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IComplexRawResponse>>(
|
||||||
|
this.apiRoutes.list(consumerId, businessActivityId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(
|
||||||
|
consumerId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.get<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.single(consumerId, businessActivityId, complexId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(
|
||||||
|
consumerId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
data: IComplexRequest,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.post<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.list(consumerId, businessActivityId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
consumerId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
data: IComplexRequest,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.patch<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.single(consumerId, businessActivityId, complexId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { CONSUMER_LICENSES_API_ROUTES } from '../constants';
|
||||||
|
import { ILicenseRawResponse, ILicenseRequest, ILicenseResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class LicensesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = CONSUMER_LICENSES_API_ROUTES;
|
||||||
|
|
||||||
|
create(consumerId: string, data: ILicenseRequest): Observable<ILicenseResponse> {
|
||||||
|
return this.http.post<ILicenseRawResponse>(this.apiRoutes.list(consumerId), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
consumerId: string,
|
||||||
|
licenseId: string,
|
||||||
|
data: ILicenseRequest,
|
||||||
|
): Observable<ILicenseResponse> {
|
||||||
|
return this.http.patch<ILicenseRawResponse>(this.apiRoutes.single(consumerId, licenseId), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { CONSUMERS_API_ROUTES } from '../constants';
|
||||||
|
import { IConsumerRawResponse, IConsumerRequest, IConsumerResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class ConsumersService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = CONSUMERS_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(): Observable<IPaginatedResponse<IConsumerResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IConsumerRawResponse>>(this.apiRoutes.list());
|
||||||
|
}
|
||||||
|
getSingle(consumerId: string): Observable<IConsumerResponse> {
|
||||||
|
return this.http.get<IConsumerRawResponse>(this.apiRoutes.single(consumerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
create(userData: IConsumerRequest): Observable<IConsumerResponse> {
|
||||||
|
return this.http.post<IConsumerResponse>(this.apiRoutes.list(), userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(consumerId: string, userData: IConsumerRequest): Observable<IConsumerResponse> {
|
||||||
|
return this.http.patch<IConsumerResponse>(this.apiRoutes.single(consumerId), userData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
// import { HttpClient } from '@angular/common/http';
|
||||||
|
// import { Injectable } from '@angular/core';
|
||||||
|
// import { Observable } from 'rxjs';
|
||||||
|
// import { POS_ACCOUNTS_API_ROUTES } from '../constants';
|
||||||
|
// import { IAccountRawResponse, IAccountRequest, IAccountResponse } from '../../users/models';
|
||||||
|
|
||||||
|
// @Injectable({ providedIn: 'root' })
|
||||||
|
// export class PartnerPosesService {
|
||||||
|
// constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
// private apiRoutes = POS_ACCOUNTS_API_ROUTES;
|
||||||
|
|
||||||
|
// getAll(complexId: string, posId: string): Observable<IPaginatedResponse<IAccountResponse>> {
|
||||||
|
// return this.http.get<IPaginatedResponse<IAccountRawResponse>>(
|
||||||
|
// this.apiRoutes.list(complexId, posId),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// getSingle(complexId: string, posId: string, accountId: string): Observable<IAccountResponse> {
|
||||||
|
// return this.http.get<IAccountRawResponse>(this.apiRoutes.single(complexId, posId, accountId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// create(complexId: string, posId: string, data: IAccountRequest): Observable<IAccountResponse> {
|
||||||
|
// return this.http.post<IAccountRawResponse>(this.apiRoutes.list(complexId, posId), data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// update(
|
||||||
|
// complexId: string,
|
||||||
|
// posId: string,
|
||||||
|
// accountId: string,
|
||||||
|
// data: IAccountRequest,
|
||||||
|
// ): Observable<IAccountResponse> {
|
||||||
|
// return this.http.patch<IAccountRawResponse>(
|
||||||
|
// this.apiRoutes.single(complexId, posId, accountId),
|
||||||
|
// data,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { COMPLEX_POSES_API_ROUTES } from '../constants/apiRoutes/complexPoses';
|
||||||
|
import { IPosRawResponse, IPosRequest, IPosResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PartnerPosesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = COMPLEX_POSES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
): Observable<IPaginatedResponse<IPosResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IPosRawResponse>>(
|
||||||
|
this.apiRoutes.list(businessActivityId, complexId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
posId: string,
|
||||||
|
): Observable<IPosResponse> {
|
||||||
|
return this.http.get<IPosRawResponse>(
|
||||||
|
this.apiRoutes.single(businessActivityId, complexId, posId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
data: IPosRequest,
|
||||||
|
): Observable<IPosResponse> {
|
||||||
|
return this.http.post<IPosRawResponse>(
|
||||||
|
this.apiRoutes.list(businessActivityId, complexId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
posId: string,
|
||||||
|
data: IPosRequest,
|
||||||
|
): Observable<IPosResponse> {
|
||||||
|
return this.http.patch<IPosRawResponse>(
|
||||||
|
this.apiRoutes.single(businessActivityId, complexId, posId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { computed, inject, Injectable } from '@angular/core';
|
||||||
|
import { MenuItem } from 'primeng/api';
|
||||||
|
import { catchError, finalize } from 'rxjs';
|
||||||
|
import { partnerConsumerBusinessActivitiesNamedRoutes } from '../constants/routes/businessActivities';
|
||||||
|
import { IBusinessActivityResponse } from '../models';
|
||||||
|
import { PartnerConsumerBusinessActivitiesService } from '../services/businessActivities.service';
|
||||||
|
|
||||||
|
interface BusinessActivityState extends EntityState<IBusinessActivityResponse> {
|
||||||
|
breadcrumbItems: MenuItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class BusinessActivityStore extends EntityStore<
|
||||||
|
IBusinessActivityResponse,
|
||||||
|
BusinessActivityState
|
||||||
|
> {
|
||||||
|
private readonly service = inject(PartnerConsumerBusinessActivitiesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
breadcrumbItems = computed(() => this._state().breadcrumbItems);
|
||||||
|
|
||||||
|
private setBreadcrumb(consumerId: string, businessId: string) {
|
||||||
|
this.patchState({
|
||||||
|
breadcrumbItems: [
|
||||||
|
{
|
||||||
|
...partnerConsumerBusinessActivitiesNamedRoutes.businessActivities.meta,
|
||||||
|
routerLink:
|
||||||
|
partnerConsumerBusinessActivitiesNamedRoutes.businessActivities.meta.pagePath!(
|
||||||
|
consumerId,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.entity()?.name,
|
||||||
|
routerLink: partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.meta
|
||||||
|
.pagePath!(consumerId, businessId),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(consumerId: string, businessId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(consumerId, businessId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError((error) => {
|
||||||
|
this.setError(error);
|
||||||
|
throw error;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
this.setBreadcrumb(consumerId, businessId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { computed, inject, Injectable } from '@angular/core';
|
||||||
|
import { MenuItem } from 'primeng/api';
|
||||||
|
import { catchError, finalize } from 'rxjs';
|
||||||
|
import { partnerConsumerComplexesNamedRoutes } from '../constants/routes/complexes';
|
||||||
|
import { IComplexResponse } from '../models';
|
||||||
|
import { PartnerComplexesService } from '../services/complexes.service';
|
||||||
|
|
||||||
|
interface ComplexState extends EntityState<IComplexResponse> {
|
||||||
|
breadcrumbItems: MenuItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class ComplexStore extends EntityStore<IComplexResponse, ComplexState> {
|
||||||
|
private readonly service = inject(PartnerComplexesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
breadcrumbItems = computed(() => this._state().breadcrumbItems);
|
||||||
|
|
||||||
|
private setBreadcrumb(consumerId: string, businessId: string, complexId: string) {
|
||||||
|
this.patchState({
|
||||||
|
breadcrumbItems: [
|
||||||
|
{
|
||||||
|
...partnerConsumerComplexesNamedRoutes.complexes.meta,
|
||||||
|
routerLink: partnerConsumerComplexesNamedRoutes.complexes.meta.pagePath!(
|
||||||
|
consumerId,
|
||||||
|
businessId,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.entity()?.name,
|
||||||
|
routerLink: partnerConsumerComplexesNamedRoutes.complex.meta.pagePath!(
|
||||||
|
consumerId,
|
||||||
|
businessId,
|
||||||
|
complexId,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(consumerId: string, businessId: string, complexId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(consumerId, businessId, complexId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError((error) => {
|
||||||
|
this.setError(error);
|
||||||
|
throw error;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
this.setBreadcrumb(consumerId, businessId, complexId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { computed, inject, Injectable } from '@angular/core';
|
||||||
|
import { MenuItem } from 'primeng/api';
|
||||||
|
import { catchError, finalize } from 'rxjs';
|
||||||
|
import { partnerConsumersNamedRoutes } from '../constants';
|
||||||
|
import { IConsumerResponse } from '../models';
|
||||||
|
import { ConsumersService } from '../services/main.service';
|
||||||
|
|
||||||
|
interface ConsumerState extends EntityState<IConsumerResponse> {
|
||||||
|
breadcrumbItems: MenuItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class ConsumerStore extends EntityStore<IConsumerResponse, ConsumerState> {
|
||||||
|
private readonly service = inject(ConsumersService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
breadcrumbItems = computed(() => this._state().breadcrumbItems);
|
||||||
|
|
||||||
|
private setBreadcrumb(consumerId: string) {
|
||||||
|
this.patchState({
|
||||||
|
breadcrumbItems: [
|
||||||
|
{
|
||||||
|
...partnerConsumersNamedRoutes.consumers.meta,
|
||||||
|
routerLink: partnerConsumersNamedRoutes.consumers.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.entity()?.fullname,
|
||||||
|
routerLink: partnerConsumersNamedRoutes.consumer.meta.pagePath!(consumerId),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(consumerId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(consumerId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError((error) => {
|
||||||
|
this.setError(error);
|
||||||
|
throw error;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
this.setBreadcrumb(consumerId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { computed, inject, Injectable } from '@angular/core';
|
||||||
|
import { MenuItem } from 'primeng/api';
|
||||||
|
import { catchError, finalize } from 'rxjs';
|
||||||
|
import { partnerConsumerPosesNamedRoutes } from '../constants/routes/poses';
|
||||||
|
import { IPosResponse } from '../models';
|
||||||
|
import { PartnerPosesService } from '../services/poses.service';
|
||||||
|
|
||||||
|
interface PosState extends EntityState<IPosResponse> {
|
||||||
|
breadcrumbItems: MenuItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PosStore extends EntityStore<IPosResponse, PosState> {
|
||||||
|
private readonly service = inject(PartnerPosesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
breadcrumbItems = computed(() => this._state().breadcrumbItems);
|
||||||
|
|
||||||
|
private setBreadcrumb(consumerId: string, businessId: string, complexId: string, posId: string) {
|
||||||
|
this.patchState({
|
||||||
|
breadcrumbItems: [
|
||||||
|
{
|
||||||
|
title: partnerConsumerPosesNamedRoutes.poses.meta.title,
|
||||||
|
routerLink: partnerConsumerPosesNamedRoutes.poses.meta.pagePath!(
|
||||||
|
consumerId,
|
||||||
|
businessId,
|
||||||
|
complexId,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: this.entity()?.name,
|
||||||
|
routerLink: partnerConsumerPosesNamedRoutes.pos.meta.pagePath!(
|
||||||
|
consumerId,
|
||||||
|
businessId,
|
||||||
|
complexId,
|
||||||
|
posId,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(consumerId: string, businessId: string, complexId: string, posId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(businessId, complexId, posId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError((error) => {
|
||||||
|
this.setError(error);
|
||||||
|
throw error;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
this.setBreadcrumb(consumerId, businessId, complexId, posId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
breadcrumbItems: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<partner-consumer-account-list [consumerId]="consumerId()" />
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { Component, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerAccountListComponent } from '../../components/accounts/list.component';
|
||||||
|
import { partnerConsumerAccountsNamedRoutes } from '../../constants/routes/accounts';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumer-accounts',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [ConsumerAccountListComponent],
|
||||||
|
})
|
||||||
|
export class ConsumerAccountsComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly store = inject(ConsumerStore);
|
||||||
|
|
||||||
|
consumerId = signal<string>(this.route.snapshot.params['consumerId']);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.store.breadcrumbItems(),
|
||||||
|
{
|
||||||
|
title: partnerConsumerAccountsNamedRoutes.accounts.meta.title,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<partner-consumer-businessActivities-list [consumerId]="consumerId()" />
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerBusinessActivitiesComponent } from '../../components/businessActivities/list.component';
|
||||||
|
import { partnerConsumerBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-businessActivities',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [ConsumerBusinessActivitiesComponent],
|
||||||
|
})
|
||||||
|
export class PartnerUserBusinessActivitiesComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
consumerId = signal<string>(this.pageParams()['consumerId']);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
{
|
||||||
|
title: partnerConsumerBusinessActivitiesNamedRoutes.businessActivities.meta.title,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<app-card-data cardTitle="اطلاعات فعالیت اقتصادی" [editable]="true" [(editMode)]="editMode">
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
|
<app-key-value label="عنوان" [value]="businessActivity()?.name" />
|
||||||
|
<app-key-value label="کد اقتصادی" [value]="businessActivity()?.economic_code" />
|
||||||
|
<app-key-value label="صنف" [value]="businessActivity()?.guild?.name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<partner-consumer-complexes-list [consumerId]="consumerId()" [businessId]="businessId()" />
|
||||||
|
|
||||||
|
<partner-consumer-businessActivities-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[consumerId]="consumerId()"
|
||||||
|
[businessActivityId]="businessId()"
|
||||||
|
[initialValues]="businessActivity() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
import { ConsumerBusinessActivitiesFormComponent } from '../../components/businessActivities/form.component';
|
||||||
|
import { ConsumerComplexesComponent } from '../../components/complexes/list.component';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-businessActivity',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [
|
||||||
|
AppCardComponent,
|
||||||
|
KeyValueComponent,
|
||||||
|
ConsumerBusinessActivitiesFormComponent,
|
||||||
|
ConsumerComplexesComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class PartnerUserBusinessActivityComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly store = inject(BusinessActivityStore);
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = signal<string>(this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = signal<string>(this.pageParams()['businessActivityId']!);
|
||||||
|
editMode = signal<boolean>(false);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly businessActivity = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
if (this.businessActivity()?.id) {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
...this.store.breadcrumbItems(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<partner-consumer-complexes-list [consumerId]="consumerId()" [businessId]="businessId()" />
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerComplexesComponent } from '../../components/complexes/list.component';
|
||||||
|
import { partnerConsumerComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-complexes',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [ConsumerComplexesComponent],
|
||||||
|
})
|
||||||
|
export class PartnerUserComplexesComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
consumerId = signal<string>(this.pageParams()['consumerId']);
|
||||||
|
businessId = signal<string>(this.pageParams()['businessActivityId']);
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
...this.businessStore.breadcrumbItems(),
|
||||||
|
{
|
||||||
|
title: partnerConsumerComplexesNamedRoutes.complexes.meta.title,
|
||||||
|
routerLink: partnerConsumerComplexesNamedRoutes.complexes.meta.pagePath!(
|
||||||
|
this.consumerId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<app-card-data cardTitle="اطلاعات شعبه" [editable]="true" [(editMode)]="editMode">
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
|
<app-key-value label="عنوان" [value]="complex()?.name" />
|
||||||
|
<app-key-value label="آدرس" [value]="complex()?.address" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<partner-consumer-poses-list [consumerId]="consumerId()" [businessId]="businessId()" [complexId]="complexId()" />
|
||||||
|
|
||||||
|
<partner-consumer-complex-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[consumerId]="consumerId()"
|
||||||
|
[businessActivityId]="businessId()"
|
||||||
|
[complexId]="complexId()"
|
||||||
|
[initialValues]="complex() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerComplexFormComponent } from '../../components/complexes/form.component';
|
||||||
|
import { ConsumerPosesComponent } from '../../components/poses/list.component';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ComplexStore } from '../../store/complex.store';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-complex',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [
|
||||||
|
AppCardComponent,
|
||||||
|
KeyValueComponent,
|
||||||
|
ConsumerComplexFormComponent,
|
||||||
|
ConsumerPosesComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class PartnerUserComplexComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly store = inject(ComplexStore);
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = signal<string>(this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = signal<string>(this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = signal<string>(this.pageParams()['complexId']!);
|
||||||
|
|
||||||
|
editMode = signal<boolean>(false);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly complex = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
if (this.complex()?.id) {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId(), this.complexId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
...this.businessStore.breadcrumbItems(),
|
||||||
|
...this.store.breadcrumbItems(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './list.component';
|
||||||
|
export * from './single.component';
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت مشتریان"
|
||||||
|
[addNewCtaLabel]="'افزودن مشتری جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="مشتریای یافت نشد"
|
||||||
|
emptyPlaceholderDescription="برای افزودن مشتری جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showDetails]="true"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onDetails)="toSinglePage($event)"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
/>
|
||||||
|
<partner-consumer-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[consumerId]="selectedItemForEdit()?.id"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { formatJalali } from '@/utils';
|
||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { ConsumerUserFormComponent } from '../components/form.component';
|
||||||
|
import { partnerConsumersNamedRoutes } from '../constants';
|
||||||
|
import { IConsumerResponse } from '../models';
|
||||||
|
import { ConsumersService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-consumers',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, ConsumerUserFormComponent],
|
||||||
|
})
|
||||||
|
export class ConsumersComponent extends AbstractList<IConsumerResponse> {
|
||||||
|
private readonly service = inject(ConsumersService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = [
|
||||||
|
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||||
|
{ field: 'fullname', header: 'نام' },
|
||||||
|
{ field: 'mobile_number', header: 'شماره موبایل' },
|
||||||
|
{ field: 'status', header: 'وضعیت' },
|
||||||
|
{
|
||||||
|
field: 'license_expires_at',
|
||||||
|
header: 'تاریخ انقضای لایسنس',
|
||||||
|
customDataModel(item) {
|
||||||
|
if (item.license_info) {
|
||||||
|
return formatJalali(item.license_info.expires_at);
|
||||||
|
}
|
||||||
|
return 'بدون لایسنس';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(consumer: IConsumerResponse) {
|
||||||
|
this.router.navigateByUrl(partnerConsumersNamedRoutes.consumer.meta.pagePath!(consumer.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<partner-consumer-poses-list [consumerId]="consumerId()" [businessId]="businessId()" [complexId]="complexId()" />
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerPosesComponent } from '../../components/poses/list.component';
|
||||||
|
import { partnerConsumerPosesNamedRoutes } from '../../constants/routes/poses';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ComplexStore } from '../../store/complex.store';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-poses',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [ConsumerPosesComponent],
|
||||||
|
})
|
||||||
|
export class PartnerUserPosesComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
private readonly complexStore = inject(ComplexStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
consumerId = signal<string>(this.pageParams()['consumerId']);
|
||||||
|
businessId = signal<string>(this.pageParams()['businessActivityId']);
|
||||||
|
complexId = signal<string>(this.pageParams()['complexId']);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
...this.businessStore.breadcrumbItems(),
|
||||||
|
...this.complexStore.breadcrumbItems(),
|
||||||
|
{
|
||||||
|
title: partnerConsumerPosesNamedRoutes.poses.meta.title,
|
||||||
|
routerLink: partnerConsumerPosesNamedRoutes.poses.meta.pagePath!(
|
||||||
|
this.consumerId(),
|
||||||
|
this.businessId(),
|
||||||
|
this.complexId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<app-card-data cardTitle="اطلاعات پایانهی فروش" [editable]="true" [(editMode)]="editMode">
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
|
<app-key-value label="عنوان" [value]="pos()?.name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<partner-consumer-pos-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[consumerId]="consumerId()"
|
||||||
|
[businessActivityId]="businessId()"
|
||||||
|
[complexId]="complexId()"
|
||||||
|
[posId]="posId()"
|
||||||
|
[initialValues]="pos() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
|
import pageParamsUtils from '@/utils/page-params.utils';
|
||||||
|
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ConsumerPosFormComponent } from '../../components/poses/form.component';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ComplexStore } from '../../store/complex.store';
|
||||||
|
import { ConsumerStore } from '../../store/consumer.store';
|
||||||
|
import { PosStore } from '../../store/pos.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'partner-user-pos',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [AppCardComponent, KeyValueComponent, ConsumerPosFormComponent],
|
||||||
|
})
|
||||||
|
export class PartnerUserPosComponent {
|
||||||
|
private readonly consumerStore = inject(ConsumerStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
private readonly complexStore = inject(ComplexStore);
|
||||||
|
private readonly store = inject(PosStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly consumerId = signal<string>(this.pageParams()['consumerId']!);
|
||||||
|
readonly businessId = signal<string>(this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = signal<string>(this.pageParams()['complexId']!);
|
||||||
|
readonly posId = signal<string>(this.pageParams()['posId']!);
|
||||||
|
editMode = signal<boolean>(false);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
if (this.pos()?.id) {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly pos = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId(), this.businessId(), this.complexId(), this.posId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
...this.consumerStore.breadcrumbItems(),
|
||||||
|
...this.businessStore.breadcrumbItems(),
|
||||||
|
...this.complexStore.breadcrumbItems(),
|
||||||
|
...this.store.breadcrumbItems(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<app-card-data cardTitle="اطلاعات مشتری" [editable]="true" [(editMode)]="editMode">
|
||||||
|
<ng-template #moreActions> </ng-template>
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
|
<app-key-value label="نام مشتری" [value]="consumer()?.fullname" />
|
||||||
|
<app-key-value label="شماره موبایل" [value]="consumer()?.mobile_number" />
|
||||||
|
<app-key-value label="وضعیت" [value]="consumer()?.status" />
|
||||||
|
@if (licenseStatus() === "EXPIRED") {
|
||||||
|
<app-key-value label="وضعیت لایسنس">
|
||||||
|
<p-button size="small" outlined severity="warn" (onClick)="openLicenseForm()">
|
||||||
|
منقضی شده در <span [jalaliDate]="license()!.expires_at"></span>
|
||||||
|
</p-button>
|
||||||
|
</app-key-value>
|
||||||
|
<!-- <app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرمافزار'" /> -->
|
||||||
|
} @else if (licenseStatus() === "ACTIVE") {
|
||||||
|
<app-key-value label="وضعیت لایسنس">
|
||||||
|
<p-button size="small" outlined severity="success" (onClick)="openLicenseForm()">
|
||||||
|
تا تاریخ <span [jalaliDate]="license()!.expires_at"></span>
|
||||||
|
</p-button>
|
||||||
|
</app-key-value>
|
||||||
|
<!-- <app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرمافزار'" /> -->
|
||||||
|
} @else {
|
||||||
|
<app-key-value label="وضعیت لایسنس">
|
||||||
|
<p-button size="small" outlined severity="danger" (onClick)="openLicenseForm()"> ارایه نشده </p-button>
|
||||||
|
</app-key-value>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<partner-consumer-account-list [consumerId]="consumerId()" />
|
||||||
|
<partner-consumer-businessActivities-list [consumerId]="consumerId()" />
|
||||||
|
|
||||||
|
<partner-consumer-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[consumerId]="consumerId()"
|
||||||
|
[initialValues]="consumer() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<partner-consumer-license-form
|
||||||
|
[(visible)]="visibleLicenseForm"
|
||||||
|
[editMode]="!!license()?.id"
|
||||||
|
[consumerId]="consumerId()"
|
||||||
|
[licenseId]="license()?.id"
|
||||||
|
[initialValues]="license() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
|
import { JalaliDateDirective } from '@/shared/directives';
|
||||||
|
import { getLicenseStatus } from '@/utils';
|
||||||
|
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { Button } from 'primeng/button';
|
||||||
|
import { ConsumerAccountListComponent } from '../components/accounts/list.component';
|
||||||
|
import { ConsumerBusinessActivitiesComponent } from '../components/businessActivities/list.component';
|
||||||
|
import { ConsumerUserFormComponent } from '../components/form.component';
|
||||||
|
import { ConsumerLicenseFormComponent } from '../components/licenses/form.component';
|
||||||
|
import { ConsumerStore } from '../store/consumer.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'consumer-user',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [
|
||||||
|
AppCardComponent,
|
||||||
|
KeyValueComponent,
|
||||||
|
ConsumerUserFormComponent,
|
||||||
|
ConsumerAccountListComponent,
|
||||||
|
ConsumerBusinessActivitiesComponent,
|
||||||
|
Button,
|
||||||
|
JalaliDateDirective,
|
||||||
|
ConsumerLicenseFormComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ConsumerComponent {
|
||||||
|
private readonly store = inject(ConsumerStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
|
||||||
|
readonly consumerId = signal<string>(this.route.snapshot.paramMap.get('consumerId')!);
|
||||||
|
editMode = signal<boolean>(false);
|
||||||
|
|
||||||
|
visibleLicenseForm = signal(false);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly consumer = computed(() => this.store.entity());
|
||||||
|
readonly license = computed(() => this.store.entity()?.license_info);
|
||||||
|
readonly licenseStatus = computed(() =>
|
||||||
|
getLicenseStatus(this.store.entity()?.license_info?.expires_at),
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
if (this.consumer()?.id) {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.consumerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems(this.store.breadcrumbItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
openLicenseForm() {
|
||||||
|
// this.visibleLicenseForm.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Route } from '@angular/router';
|
import { Route } from '@angular/router';
|
||||||
import { PARTNER_ACCOUNTS_ROUTES } from './modules/accounts/constants';
|
import { PARTNER_ACCOUNTS_ROUTES } from './modules/accounts/constants';
|
||||||
import { PARTNER_CUSTOMERS_ROUTES } from './modules/customers/constants';
|
import { PARTNER_CONSUMERS_ROUTES } from './modules/consumers/constants';
|
||||||
|
|
||||||
export const PARTNER_ROUTES = {
|
export const PARTNER_ROUTES = {
|
||||||
path: 'partner',
|
path: 'partner',
|
||||||
@@ -12,6 +12,6 @@ export const PARTNER_ROUTES = {
|
|||||||
import('./modules/dashboard/views/index.component').then((m) => m.DashboardComponent),
|
import('./modules/dashboard/views/index.component').then((m) => m.DashboardComponent),
|
||||||
},
|
},
|
||||||
...PARTNER_ACCOUNTS_ROUTES,
|
...PARTNER_ACCOUNTS_ROUTES,
|
||||||
...PARTNER_CUSTOMERS_ROUTES,
|
...PARTNER_CONSUMERS_ROUTES,
|
||||||
],
|
],
|
||||||
} as Route;
|
} as Route;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<img [src]="placeholderLogo" alt="Logo" class="w-full h-full object-cover rounded-md bg-surface-card" />
|
<img [src]="placeholderLogo" alt="Logo" class="w-full h-full object-cover rounded-md bg-surface-card" />
|
||||||
</div>
|
</div>
|
||||||
@if (posInfo()) {
|
@if (posInfo()) {
|
||||||
<span class="text-lg font-bold">{{ posInfo()?.name }} - فروشگاه {{ posInfo()?.complex?.name }}</span>
|
<span class="text-lg font-bold">{{ posInfo()?.name }} - شعبه {{ posInfo()?.complex?.name }}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
|
|||||||
@@ -5,16 +5,10 @@ export interface IPosInfoRawResponse {
|
|||||||
complex: {
|
complex: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
tax_id: string;
|
branch_code: string;
|
||||||
};
|
|
||||||
businessActivity: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
guild: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
};
|
||||||
|
businessActivity: ISummary;
|
||||||
|
guild: ISummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPosInfoResponse extends IPosInfoRawResponse {}
|
export interface IPosInfoResponse extends IPosInfoRawResponse {}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<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.tax_id" name="tax_id" />
|
<app-input label="کد شعبه" [control]="form.controls.branch_code" name="branch_code" />
|
||||||
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
|||||||
initForm = () => {
|
initForm = () => {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
name: [this.initialValues?.name || '', [Validators.required]],
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
tax_id: [this.initialValues?.tax_id || '', [Validators.required]],
|
branch_code: [this.initialValues?.branch_code || ''],
|
||||||
address: [this.initialValues?.address || '', [Validators.required]],
|
address: [this.initialValues?.address || '', [Validators.required]],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -34,7 +34,7 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
|||||||
form = this.initForm();
|
form = this.initForm();
|
||||||
|
|
||||||
get preparedTitle() {
|
get preparedTitle() {
|
||||||
return `${this.editMode ? 'ویرایش' : 'ایجاد'} فروشگاه`;
|
return `${this.editMode ? 'ویرایش' : 'ایجاد'} شعبه`;
|
||||||
}
|
}
|
||||||
|
|
||||||
override ngOnChanges(): void {
|
override ngOnChanges(): void {
|
||||||
|
|||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
<app-page-data-list
|
<app-page-data-list
|
||||||
pageTitle="مدیریت فروشگاهها"
|
pageTitle="مدیریت شعب"
|
||||||
[addNewCtaLabel]="'افزودن فروشگاه جدید'"
|
[addNewCtaLabel]="'افزودن شعبه جدید'"
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
[showAdd]="true"
|
[showAdd]="true"
|
||||||
emptyPlaceholderTitle="فروشگاهی یافت نشد."
|
emptyPlaceholderTitle="شعبهای یافت نشد."
|
||||||
emptyPlaceholderDescription="برای افزودن فروشگاه جدید، روی دکمهٔ بالا کلیک کنید."
|
emptyPlaceholderDescription="برای افزودن شعبه جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
[items]="items()"
|
[items]="items()"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[showDetails]="true"
|
[showDetails]="true"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const superAdminConsumerComplexesNamedRoutes: NamedRoutes<TComplexesRoute
|
|||||||
(m) => m.SuperAdminUserComplexesComponent,
|
(m) => m.SuperAdminUserComplexesComponent,
|
||||||
),
|
),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'فروشگاهها',
|
title: 'شعب',
|
||||||
pagePath: (consumerId: string, businessId: string) => baseUrl(consumerId, businessId),
|
pagePath: (consumerId: string, businessId: string) => baseUrl(consumerId, businessId),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -26,7 +26,7 @@ export const superAdminConsumerComplexesNamedRoutes: NamedRoutes<TComplexesRoute
|
|||||||
(m) => m.SuperAdminUserComplexComponent,
|
(m) => m.SuperAdminUserComplexComponent,
|
||||||
),
|
),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'فروشگاه',
|
title: 'شعبه',
|
||||||
pagePath: (consumerId: string, businessId: string, complexId: string) =>
|
pagePath: (consumerId: string, businessId: string, complexId: string) =>
|
||||||
`${baseUrl(consumerId, businessId)}/${complexId}`,
|
`${baseUrl(consumerId, businessId)}/${complexId}`,
|
||||||
},
|
},
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user