update superAdmin users business
This commit is contained in:
@@ -9,58 +9,28 @@ export const MENU_ITEMS = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// label: 'انبارها',
|
{
|
||||||
// icon: 'pi pi-fw pi-box',
|
label: 'مدیریت اطلاعات مرجع',
|
||||||
// items: [
|
icon: 'pi pi-fw pi-cog',
|
||||||
// {
|
items: [
|
||||||
// label: 'لیست انبارها',
|
{
|
||||||
// icon: 'pi pi-fw pi-list',
|
label: 'برندهای دستگاه',
|
||||||
// routerLink: ['/inventories'],
|
icon: 'pi pi-fw pi-list',
|
||||||
// },
|
routerLink: ['/super_admin/device_brands'],
|
||||||
// ],
|
},
|
||||||
// },
|
{
|
||||||
// {
|
label: 'دستگاهها',
|
||||||
// label: 'کالاها',
|
icon: 'pi pi-fw pi-list',
|
||||||
// icon: 'pi pi-fw pi-tags',
|
routerLink: ['/super_admin/devices'],
|
||||||
// items: [
|
},
|
||||||
// {
|
],
|
||||||
// label: 'لیست کالاها',
|
},
|
||||||
// icon: 'pi pi-fw pi-list',
|
|
||||||
// routerLink: ['/products'],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: 'برندهای کالا',
|
|
||||||
// icon: 'pi pi-fw pi-tags',
|
|
||||||
// routerLink: ['/product-brands'],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: 'دستهبندیهای کالا',
|
|
||||||
// icon: 'pi pi-fw pi-list',
|
|
||||||
// routerLink: ['/product-categories'],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: 'تامینکنندگان',
|
|
||||||
// icon: 'pi pi-fw pi-users',
|
|
||||||
// items: [
|
|
||||||
// {
|
|
||||||
// label: 'لیست تامینکنندگان',
|
|
||||||
// icon: 'pi pi-fw pi-list',
|
|
||||||
// routerLink: ['/suppliers'],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
label: 'مدیریت سیستم',
|
label: 'مدیریت سیستم',
|
||||||
icon: 'pi pi-fw pi-cog',
|
icon: 'pi pi-fw pi-cog',
|
||||||
items: [
|
items: [
|
||||||
// {
|
|
||||||
// label: 'حسابهای بانکی',
|
|
||||||
// icon: 'pi pi-fw pi-credit-card',
|
|
||||||
// routerLink: ['/bankAccounts'],
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
label: 'کاربران',
|
label: 'کاربران',
|
||||||
icon: 'pi pi-fw pi-user',
|
icon: 'pi pi-fw pi-user',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export interface RouteInfo {
|
|||||||
meta: {
|
meta: {
|
||||||
title: string;
|
title: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
pagePath?: (params?: any) => string;
|
pagePath?: (...params: any) => string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default interface ISummary {
|
export default interface ISummary {
|
||||||
id: number;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ export class BreadcrumbService {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
addItems(items: MenuItem[]) {
|
addItems(items: MenuItem[]) {
|
||||||
this._items.update((value) => ({ ...value, ...this.mapItems(items) }));
|
this._items.update((value) => {
|
||||||
|
return [...value, ...this.mapItems(items)];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
|||||||
@@ -182,6 +182,17 @@ export abstract class EntityStore<
|
|||||||
entity,
|
entity,
|
||||||
} as Partial<TState>);
|
} as Partial<TState>);
|
||||||
}
|
}
|
||||||
|
override reset(): void {
|
||||||
|
// @ts-ignore
|
||||||
|
// @TODO: check to familiar with ts
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { ValidatorFn } from '@angular/forms';
|
|||||||
|
|
||||||
// Password must be minimum 8 characters, include at least one uppercase,
|
// Password must be minimum 8 characters, include at least one uppercase,
|
||||||
// one lowercase, one number and one special character
|
// one lowercase, one number and one special character
|
||||||
export const PASSWORD_PATTERN = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/;
|
// export const PASSWORD_PATTERN = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/;
|
||||||
|
export const PASSWORD_PATTERN = /^[0-9]{6,}$/;
|
||||||
|
|
||||||
// Validator factory named `password` as requested. Returns `null` for empty
|
// Validator factory named `password` as requested. Returns `null` for empty
|
||||||
// values so `Validators.required` can be used alongside it when needed.
|
// values so `Validators.required` can be used alongside it when needed.
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<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-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { InputComponent } from '@/shared/components';
|
||||||
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { Component, computed, inject, Input } from '@angular/core';
|
||||||
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { Dialog } from 'primeng/dialog';
|
||||||
|
import { IDeviceBrandRequest, IDeviceBrandResponse } from '../models';
|
||||||
|
import { DeviceBrandsService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'deviceBrand-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||||
|
})
|
||||||
|
export class DeviceBrandFormComponent extends AbstractFormDialog<
|
||||||
|
IDeviceBrandRequest,
|
||||||
|
IDeviceBrandResponse
|
||||||
|
> {
|
||||||
|
@Input() brandId?: string;
|
||||||
|
private service = inject(DeviceBrandsService);
|
||||||
|
|
||||||
|
form = this.fb.group({
|
||||||
|
name: this.fb.control<string>(this.initialValues?.name || '', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
preparedTitle = computed(() => `${this.editMode ? 'ویرایش' : 'ایجاد'} برند دستگاه`);
|
||||||
|
|
||||||
|
override ngOnChanges() {
|
||||||
|
this.form.patchValue(this.initialValues ?? {});
|
||||||
|
if (this.editMode && !this.brandId) {
|
||||||
|
throw 'missing some arguments';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override submitForm(payload: IDeviceBrandRequest) {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.brandId!, payload);
|
||||||
|
}
|
||||||
|
return this.service.create(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const baseUrl = '/api/v1/admin/device_brands';
|
||||||
|
|
||||||
|
export const DEVICE_BRANDS_API_ROUTES = {
|
||||||
|
list: () => `${baseUrl}`,
|
||||||
|
single: (id: string) => `${baseUrl}/${id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apiRoutes';
|
||||||
|
export * from './routes';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export type TDeviceBrandsRouteNames = 'deviceBrands';
|
||||||
|
|
||||||
|
export const deviceBrandsNamedRoutes: NamedRoutes<TDeviceBrandsRouteNames> = {
|
||||||
|
deviceBrands: {
|
||||||
|
path: 'device_brands',
|
||||||
|
loadComponent: () => import('../../views/list.component').then((m) => m.DeviceBrandsComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'برندها',
|
||||||
|
pagePath: () => '/super_admin/deviceBrands',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DEVICE_BRANDS_ROUTES: Routes = Object.values(deviceBrandsNamedRoutes);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './io';
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export interface IDeviceBrandRawResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface IDeviceBrandResponse extends IDeviceBrandRawResponse {}
|
||||||
|
|
||||||
|
export interface IDeviceBrandRequest {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
@@ -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 { DEVICE_BRANDS_API_ROUTES } from '../constants';
|
||||||
|
import { IDeviceBrandRawResponse, IDeviceBrandRequest, IDeviceBrandResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class DeviceBrandsService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = DEVICE_BRANDS_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(): Observable<IPaginatedResponse<IDeviceBrandResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IDeviceBrandRawResponse>>(this.apiRoutes.list());
|
||||||
|
}
|
||||||
|
// getSingle(userId: string): Observable<IDeviceBrandResponse> {
|
||||||
|
// return this.http.get<IDeviceBrandRawResponse>(this.apiRoutes.single(userId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
create(userData: IDeviceBrandRequest): Observable<IDeviceBrandResponse> {
|
||||||
|
return this.http.post<IDeviceBrandResponse>(this.apiRoutes.list(), userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(userId: string, userData: IDeviceBrandRequest): Observable<IDeviceBrandResponse> {
|
||||||
|
return this.http.patch<IDeviceBrandResponse>(this.apiRoutes.single(userId), userData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت برند دستگاهها"
|
||||||
|
[addNewCtaLabel]="'افزودن برند دستگاه جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="برند دستگاه یافت نشد"
|
||||||
|
emptyPlaceholderDescription="برای افزودن برند دستگاه جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
/>
|
||||||
|
<deviceBrand-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[brandId]="selectedItemForEdit()?.id"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { DeviceBrandFormComponent } from '../components/form.component';
|
||||||
|
import { IDeviceBrandResponse } from '../models';
|
||||||
|
import { DeviceBrandsService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-deviceBrands',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, DeviceBrandFormComponent],
|
||||||
|
})
|
||||||
|
export class DeviceBrandsComponent extends AbstractList<IDeviceBrandResponse> {
|
||||||
|
private readonly service = inject(DeviceBrandsService);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = [
|
||||||
|
{ field: 'id', header: 'شناسه' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// toSinglePage(partner: IDeviceBrandResponse) {
|
||||||
|
// this.router.navigateByUrl(partnersNamedRoutes.partner.meta.pagePath!(partner.id));
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<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" />
|
||||||
|
<catalog-deviceBrand-select [control]="form.controls.brand_id" />
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
|
import { CatalogDeviceBrandSelectComponent } from '@/shared/catalog/deviceBrands';
|
||||||
|
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 { IDeviceRequest, IDeviceResponse } from '../models';
|
||||||
|
import { SuperAdminDeviceService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-device-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
CatalogDeviceBrandSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class UserComplexFormComponent extends AbstractFormDialog<IDeviceRequest, IDeviceResponse> {
|
||||||
|
private readonly service = inject(SuperAdminDeviceService);
|
||||||
|
|
||||||
|
@Input() deviceId?: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
return this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
brand_id: [this.initialValues?.brand.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 IDeviceRequest;
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.deviceId!, formValue);
|
||||||
|
}
|
||||||
|
return this.service.create(formValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const baseUrl = '/api/v1/admin/devices';
|
||||||
|
|
||||||
|
export const DEVICES_API_ROUTES = {
|
||||||
|
list: () => `${baseUrl}`,
|
||||||
|
single: (id: string) => `${baseUrl}/${id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apiRoutes';
|
||||||
|
export * from './routes';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export type TDevicesRouteNames = 'devices';
|
||||||
|
|
||||||
|
export const devicesRoutes: NamedRoutes<TDevicesRouteNames> = {
|
||||||
|
devices: {
|
||||||
|
path: 'devices',
|
||||||
|
loadComponent: () => import('../../views/list.component').then((m) => m.DevicesComponent),
|
||||||
|
meta: {
|
||||||
|
title: 'دستگاهها',
|
||||||
|
pagePath: () => '/super_admin/devices',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DEVICES_ROUTES: Routes = Object.values(devicesRoutes);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './io';
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import ISummary from '@/core/models/summary';
|
||||||
|
|
||||||
|
export interface IDeviceRawResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
brand: ISummary;
|
||||||
|
}
|
||||||
|
export interface IDeviceResponse extends IDeviceRawResponse {}
|
||||||
|
|
||||||
|
export interface IDeviceRequest {
|
||||||
|
name: string;
|
||||||
|
brand_id: string;
|
||||||
|
}
|
||||||
@@ -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 { DEVICES_API_ROUTES } from '../constants';
|
||||||
|
import { IDeviceRawResponse, IDeviceRequest, IDeviceResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class SuperAdminDeviceService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = DEVICES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(): Observable<IPaginatedResponse<IDeviceResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IDeviceRawResponse>>(this.apiRoutes.list());
|
||||||
|
}
|
||||||
|
// getSingle(userId: string): Observable<IDeviceBrandResponse> {
|
||||||
|
// return this.http.get<IDeviceBrandRawResponse>(this.apiRoutes.single(userId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
create(userData: IDeviceRequest): Observable<IDeviceResponse> {
|
||||||
|
return this.http.post<IDeviceResponse>(this.apiRoutes.list(), userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(userId: string, userData: IDeviceRequest): Observable<IDeviceResponse> {
|
||||||
|
return this.http.patch<IDeviceResponse>(this.apiRoutes.single(userId), userData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<app-page-data-list
|
||||||
|
pageTitle="مدیریت دستگاهها"
|
||||||
|
[addNewCtaLabel]="'افزودن دستگاه جدید'"
|
||||||
|
[columns]="columns"
|
||||||
|
[showAdd]="true"
|
||||||
|
emptyPlaceholderTitle="دستگاه یافت نشد"
|
||||||
|
emptyPlaceholderDescription="برای افزودن دستگاه جدید، روی دکمهٔ بالا کلیک کنید."
|
||||||
|
[items]="items()"
|
||||||
|
[loading]="loading()"
|
||||||
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
|
(onAdd)="openAddForm()"
|
||||||
|
(onEdit)="onEditClick($event)"
|
||||||
|
/>
|
||||||
|
<superAdmin-device-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[deviceId]="selectedItemForEdit()?.id"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||||
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { UserComplexFormComponent } from '../components/form.component';
|
||||||
|
import { IDeviceResponse } from '../models';
|
||||||
|
import { SuperAdminDeviceService } from '../services/main.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-deviceBrands',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, UserComplexFormComponent],
|
||||||
|
})
|
||||||
|
export class DevicesComponent extends AbstractList<IDeviceResponse> {
|
||||||
|
private readonly service = inject(SuperAdminDeviceService);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = [
|
||||||
|
{ field: 'id', header: 'شناسه' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{ field: 'brand', header: 'برند دستگاه', type: 'nested', nestedPath: 'name' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// toSinglePage(partner: IDeviceBrandResponse) {
|
||||||
|
// this.router.navigateByUrl(partnersNamedRoutes.partner.meta.pagePath!(partner.id));
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||||
<app-input label="کد" [control]="form.controls.code" name="code" />
|
<app-input label="کد" [control]="form.controls.code" name="code" />
|
||||||
|
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p-dialog
|
<p-dialog
|
||||||
header="فرم کاربر"
|
[header]="preparedTitle()"
|
||||||
[(visible)]="visible"
|
[(visible)]="visible"
|
||||||
[modal]="true"
|
[modal]="true"
|
||||||
[style]="{ width: '500px' }"
|
[style]="{ width: '500px' }"
|
||||||
@@ -9,6 +9,14 @@
|
|||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||||
<app-input label="کد" [control]="form.controls.code" name="code" />
|
<app-input label="کد" [control]="form.controls.code" name="code" />
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
<app-input
|
||||||
|
label="تعداد لایسنسهای رزرو"
|
||||||
|
[control]="form.controls.license_quota"
|
||||||
|
name="license_quota"
|
||||||
|
type="number"
|
||||||
|
[min]="0"
|
||||||
|
[max]="2"
|
||||||
|
/>
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import { InputComponent } from '@/shared/components';
|
import { InputComponent } from '@/shared/components';
|
||||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
import { Component, inject } from '@angular/core';
|
import { Component, computed, inject, Input } from '@angular/core';
|
||||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { Dialog } from 'primeng/dialog';
|
import { Dialog } from 'primeng/dialog';
|
||||||
import { IPartnerRequest, IPartnerResponse } from '../models';
|
import { IPartnerRequest, IPartnerResponse } from '../models';
|
||||||
@@ -13,6 +13,7 @@ import { PartnersService } from '../services/main.service';
|
|||||||
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||||
})
|
})
|
||||||
export class GuildFormComponent extends AbstractFormDialog<IPartnerRequest, IPartnerResponse> {
|
export class GuildFormComponent extends AbstractFormDialog<IPartnerRequest, IPartnerResponse> {
|
||||||
|
@Input() partnerId?: string;
|
||||||
private service = inject(PartnersService);
|
private service = inject(PartnersService);
|
||||||
|
|
||||||
form = this.fb.group({
|
form = this.fb.group({
|
||||||
@@ -24,9 +25,25 @@ export class GuildFormComponent extends AbstractFormDialog<IPartnerRequest, IPar
|
|||||||
nonNullable: true,
|
nonNullable: true,
|
||||||
validators: [Validators.required],
|
validators: [Validators.required],
|
||||||
}),
|
}),
|
||||||
|
license_quota: this.fb.control<number>(this.initialValues?.license_quota || 0, {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
preparedTitle = computed(() => `${this.editMode ? 'ویرایش' : 'ایجاد'} شریک تجاری`);
|
||||||
|
|
||||||
|
override ngOnChanges() {
|
||||||
|
this.form.patchValue(this.initialValues ?? {});
|
||||||
|
if (this.editMode && !this.partnerId) {
|
||||||
|
throw 'missing some arguments';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override submitForm(payload: IPartnerRequest) {
|
override submitForm(payload: IPartnerRequest) {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.partnerId!, payload);
|
||||||
|
}
|
||||||
return this.service.create(payload);
|
return this.service.create(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { BreadcrumbService } from '@/core/services';
|
||||||
|
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||||
|
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { partnersNamedRoutes } from '../constants';
|
||||||
|
import { PartnerStore } from '../store/partner.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-guild-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class GuildLayoutComponent {
|
||||||
|
private readonly store = inject(PartnerStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
|
||||||
|
readonly partnerId = signal<string>(this.route.snapshot.paramMap.get('partnerId')!);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly partner = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
if (this.partner()?.id) {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.partnerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
{
|
||||||
|
...partnersNamedRoutes.partners.meta,
|
||||||
|
routerLink: partnersNamedRoutes.partners.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.partner()?.name,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ export const partnersNamedRoutes: NamedRoutes<TPartnersRouteNames> = {
|
|||||||
path: 'partners',
|
path: 'partners',
|
||||||
loadComponent: () => import('../../views/list.component').then((m) => m.PartnersComponent),
|
loadComponent: () => import('../../views/list.component').then((m) => m.PartnersComponent),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'کاربران',
|
title: 'شرکای تجاری',
|
||||||
pagePath: () => '/super_admin/partners',
|
pagePath: () => '/super_admin/partners',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -16,10 +16,24 @@ export const partnersNamedRoutes: NamedRoutes<TPartnersRouteNames> = {
|
|||||||
path: 'partners/:partnerId',
|
path: 'partners/:partnerId',
|
||||||
loadComponent: () => import('../../views/single.component').then((m) => m.PartnerComponent),
|
loadComponent: () => import('../../views/single.component').then((m) => m.PartnerComponent),
|
||||||
meta: {
|
meta: {
|
||||||
title: 'کاربر',
|
title: 'شریک تجاری',
|
||||||
pagePath: () => '/super_admin/partners/:partnerId',
|
pagePath: (guildId: string) => `/super_admin/partners/${guildId}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PARTNERS_ROUTES: Routes = Object.values(partnersNamedRoutes);
|
export const PARTNERS_ROUTES: Routes = [
|
||||||
|
partnersNamedRoutes.partners,
|
||||||
|
{
|
||||||
|
path: 'partners/:partnerId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/layout.component').then((m) => m.GuildLayoutComponent),
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: () => import('../../views/single.component').then((m) => m.PartnerComponent),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ export interface IPartnerRawResponse {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
code: string;
|
code: string;
|
||||||
|
remained_license: number;
|
||||||
|
license_quota: number;
|
||||||
}
|
}
|
||||||
export interface IPartnerResponse extends IPartnerRawResponse {}
|
export interface IPartnerResponse extends IPartnerRawResponse {}
|
||||||
|
|
||||||
export interface IPartnerRequest {
|
export interface IPartnerRequest {
|
||||||
name: string;
|
name: string;
|
||||||
code: string;
|
code: string;
|
||||||
|
license_quota: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { inject, Injectable } from '@angular/core';
|
||||||
|
import { catchError, finalize, throwError } from 'rxjs';
|
||||||
|
import { IPartnerResponse } from '../models';
|
||||||
|
import { PartnersService } from '../services/main.service';
|
||||||
|
|
||||||
|
interface PartnerState extends EntityState<IPartnerResponse> {}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PartnerStore extends EntityStore<IPartnerResponse, PartnerState> {
|
||||||
|
private readonly service = inject(PartnersService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(partnerId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(partnerId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError(() => {
|
||||||
|
this.patchState({
|
||||||
|
error: '',
|
||||||
|
});
|
||||||
|
return throwError('');
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,23 @@
|
|||||||
<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"
|
||||||
[showAdd]="true"
|
[showAdd]="true"
|
||||||
|
[showEdit]="true"
|
||||||
(onAdd)="openAddForm()"
|
(onAdd)="openAddForm()"
|
||||||
>
|
(onDetails)="toSinglePage($event)"
|
||||||
<!-- <ng-template #role let-data>
|
(onEdit)="onEditClick($event)"
|
||||||
<catalog-role-tag [role]="data.role" />
|
/>
|
||||||
</ng-template> -->
|
<partner-form
|
||||||
</app-page-data-list>
|
[(visible)]="visibleForm"
|
||||||
<partner-form [(visible)]="visibleForm" (onSubmit)="refresh()" />
|
[editMode]="editMode()"
|
||||||
|
[partnerId]="selectedItemForEdit()?.id"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
import { Component, inject } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { GuildFormComponent } from '../components/form.component';
|
import { GuildFormComponent } from '../components/form.component';
|
||||||
|
import { partnersNamedRoutes } from '../constants';
|
||||||
import { IPartnerResponse } from '../models';
|
import { IPartnerResponse } from '../models';
|
||||||
import { PartnersService } from '../services/main.service';
|
import { PartnersService } from '../services/main.service';
|
||||||
|
|
||||||
@@ -13,12 +15,14 @@ import { PartnersService } from '../services/main.service';
|
|||||||
})
|
})
|
||||||
export class PartnersComponent extends AbstractList<IPartnerResponse> {
|
export class PartnersComponent extends AbstractList<IPartnerResponse> {
|
||||||
private readonly service = inject(PartnersService);
|
private readonly service = inject(PartnersService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
override setColumns(): void {
|
override setColumns(): void {
|
||||||
this.columns = [
|
this.columns = [
|
||||||
{ field: 'id', header: 'شناسه' },
|
{ field: 'id', header: 'شناسه' },
|
||||||
{ field: 'name', header: 'نام' },
|
{ field: 'name', header: 'نام' },
|
||||||
{ field: 'code', header: 'کد' },
|
{ field: 'code', header: 'کد' },
|
||||||
|
{ field: 'license_quota', header: 'تعداد لایسنس خریداری شده' },
|
||||||
{
|
{
|
||||||
field: 'created_at',
|
field: 'created_at',
|
||||||
header: 'تاریخ ایجاد',
|
header: 'تاریخ ایجاد',
|
||||||
@@ -30,4 +34,8 @@ export class PartnersComponent extends AbstractList<IPartnerResponse> {
|
|||||||
override getDataRequest() {
|
override getDataRequest() {
|
||||||
return this.service.getAll();
|
return this.service.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toSinglePage(partner: IPartnerResponse) {
|
||||||
|
this.router.navigateByUrl(partnersNamedRoutes.partner.meta.pagePath!(partner.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,21 @@
|
|||||||
<div class=""></div>
|
<div class="flex flex-col gap-6">
|
||||||
|
<app-card-data cardTitle="اطلاعات شریک تجاری" [editable]="true" [(editMode)]="editMode">
|
||||||
|
<ng-template #moreAction> </ng-template>
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-3 gap-4 items-center">
|
||||||
|
<app-key-value label="عنوان شریک تجاری" [value]="partner()?.name" />
|
||||||
|
<app-key-value label="کد شریک تجاری" [value]="partner()?.code" />
|
||||||
|
<app-key-value label="تعداد لایسنسهای خریداری شده" [value]="partner()?.license_quota + ''" />
|
||||||
|
<app-key-value label="تعداد لایسنسهای باقیمانده" [value]="partner()?.remained_license + ''" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<partner-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[partnerId]="partnerId()"
|
||||||
|
[initialValues]="partner() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
import { Component } from '@angular/core';
|
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||||
|
import { Component, computed, inject, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { GuildFormComponent } from '../components/form.component';
|
||||||
|
import { PartnerStore } from '../store/partner.store';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user',
|
selector: 'app-user',
|
||||||
templateUrl: './single.component.html',
|
templateUrl: './single.component.html',
|
||||||
|
imports: [AppCardComponent, KeyValueComponent, GuildFormComponent],
|
||||||
})
|
})
|
||||||
export class PartnerComponent {
|
export class PartnerComponent {
|
||||||
constructor() {}
|
private readonly store = inject(PartnerStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly partnerId = signal<string>(this.route.snapshot.paramMap.get('partnerId')!);
|
||||||
|
editMode = signal<boolean>(false);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly partner = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.partnerId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p-dialog
|
<p-dialog
|
||||||
header="فرم کاربر"
|
[header]="preparedTitle()"
|
||||||
[(visible)]="visible"
|
[(visible)]="visible"
|
||||||
[modal]="true"
|
[modal]="true"
|
||||||
[style]="{ width: '500px' }"
|
[style]="{ width: '500px' }"
|
||||||
@@ -8,6 +8,6 @@
|
|||||||
>
|
>
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import { InputComponent } from '@/shared/components';
|
import { InputComponent } from '@/shared/components';
|
||||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
import { Component, inject } from '@angular/core';
|
import { Component, computed, inject, Input } from '@angular/core';
|
||||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { Dialog } from 'primeng/dialog';
|
import { Dialog } from 'primeng/dialog';
|
||||||
import { IProviderRequest, IProviderResponse } from '../models';
|
import { IProviderRequest, IProviderResponse } from '../models';
|
||||||
@@ -13,13 +13,29 @@ import { ProvidersService } from '../services/main.service';
|
|||||||
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||||
})
|
})
|
||||||
export class GuildFormComponent extends AbstractFormDialog<IProviderRequest, IProviderResponse> {
|
export class GuildFormComponent extends AbstractFormDialog<IProviderRequest, IProviderResponse> {
|
||||||
|
@Input() providerId?: string;
|
||||||
private service = inject(ProvidersService);
|
private service = inject(ProvidersService);
|
||||||
|
|
||||||
form = this.fb.group({
|
form = this.fb.group({
|
||||||
name: [this.initialValues?.name || '', [Validators.required]],
|
name: this.fb.control<string>(this.initialValues?.name || '', {
|
||||||
|
nonNullable: true,
|
||||||
|
validators: [Validators.required],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
preparedTitle = computed(() => `${this.editMode ? 'ویرایش' : 'ایجاد'} ارایهدهنده`);
|
||||||
|
|
||||||
|
override ngOnChanges() {
|
||||||
|
this.form.patchValue(this.initialValues ?? {});
|
||||||
|
if (this.editMode && !this.providerId) {
|
||||||
|
throw 'missing some arguments';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override submitForm(payload: IProviderRequest) {
|
override submitForm(payload: IProviderRequest) {
|
||||||
|
if (this.editMode) {
|
||||||
|
return this.service.update(this.providerId!, payload);
|
||||||
|
}
|
||||||
return this.service.create(payload);
|
return this.service.create(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
<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"
|
||||||
[showAdd]="true"
|
[showAdd]="true"
|
||||||
(onAdd)="openAddForm()"
|
(onAdd)="openAddForm()"
|
||||||
>
|
/>
|
||||||
<!-- <ng-template #role let-data>
|
<provider-form
|
||||||
<catalog-role-tag [role]="data.role" />
|
[(visible)]="visibleForm"
|
||||||
</ng-template> -->
|
[editMode]="editMode()"
|
||||||
</app-page-data-list>
|
[providerId]="selectedItemForEdit()?.id"
|
||||||
<provider-form [(visible)]="visibleForm" (onSubmit)="refresh()" />
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Route } from '@angular/router';
|
import { Route } from '@angular/router';
|
||||||
|
import { DEVICE_BRANDS_ROUTES } from './deviceBrands/constants';
|
||||||
|
import { DEVICES_ROUTES } from './devices/constants';
|
||||||
import { GUILDS_ROUTES } from './guilds/constants';
|
import { GUILDS_ROUTES } from './guilds/constants';
|
||||||
import { LICENSES_ROUTES } from './licenses/constants';
|
import { LICENSES_ROUTES } from './licenses/constants';
|
||||||
import { PARTNERS_ROUTES } from './partners/constants';
|
import { PARTNERS_ROUTES } from './partners/constants';
|
||||||
@@ -14,5 +16,7 @@ export const SUPER_ADMIN_ROUTES = {
|
|||||||
...PARTNERS_ROUTES,
|
...PARTNERS_ROUTES,
|
||||||
...PROVIDERS_ROUTES,
|
...PROVIDERS_ROUTES,
|
||||||
...LICENSES_ROUTES,
|
...LICENSES_ROUTES,
|
||||||
|
...DEVICE_BRANDS_ROUTES,
|
||||||
|
...DEVICES_ROUTES,
|
||||||
],
|
],
|
||||||
} as Route;
|
} as Route;
|
||||||
|
|||||||
@@ -73,9 +73,11 @@ export class UserAccountFormComponent extends AbstractFormDialog<
|
|||||||
|
|
||||||
submitForm() {
|
submitForm() {
|
||||||
const formValue = this.form.value as IAccountRequest;
|
const formValue = this.form.value as IAccountRequest;
|
||||||
|
// @ts-ignore
|
||||||
|
const { confirmPassword, ...rest } = formValue;
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
return this.service.update(this.userId, this.accountId, formValue);
|
return this.service.update(this.userId, this.accountId, rest);
|
||||||
}
|
}
|
||||||
return this.service.create(this.userId, formValue);
|
return this.service.create(this.userId, rest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,11 @@
|
|||||||
(onAdd)="openAddForm()"
|
(onAdd)="openAddForm()"
|
||||||
>
|
>
|
||||||
</app-page-data-list>
|
</app-page-data-list>
|
||||||
<superAdmin-user-account-form [(visible)]="visibleForm" [editMode]="editMode()" (onSubmit)="refresh()" />
|
<superAdmin-user-account-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[userId]="userId"
|
||||||
|
[accountId]="selectedItemForEdit()?.id || ''"
|
||||||
|
[initialValues]="selectedItemForEdit() || undefined"
|
||||||
|
(onSubmit)="refresh()"
|
||||||
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<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" />
|
||||||
|
<catalog-guild-select label="صنف" [control]="form.controls.guild_id" name="guild_id" />
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -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 { AdminUserBusinessActivitiesService } from '../../services/businessActivities.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-businessActivities-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
CatalogGuildSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class UserBusinessActivitiesFormComponent extends AbstractFormDialog<
|
||||||
|
IBusinessActivityRequest,
|
||||||
|
IBusinessActivityResponse
|
||||||
|
> {
|
||||||
|
private readonly service = inject(AdminUserBusinessActivitiesService);
|
||||||
|
|
||||||
|
@Input() userId!: string;
|
||||||
|
@Input() businessActivityId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
return this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
// @ts-ignore
|
||||||
|
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.userId, this.businessActivityId, formValue);
|
||||||
|
}
|
||||||
|
return this.service.create(this.userId, formValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (loading()) {
|
||||||
|
<shared-page-loading />
|
||||||
|
} @else {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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: 'superAdmin-user-businessActivity-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserBusinessActivityLayoutComponent {
|
||||||
|
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 userId = computed(() => this.pageParams()['userId']!);
|
||||||
|
readonly user = computed(() => this.pageParams()['userId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
console.log(this.pageParams());
|
||||||
|
|
||||||
|
this.store.getData(this.userId(), this.businessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
|
<superAdmin-user-businessActivities-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[userId]="userId"
|
||||||
|
[businessActivityId]="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 {
|
||||||
|
IColumn,
|
||||||
|
PageDataListComponent,
|
||||||
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { Component, inject, Input } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { superAdminUserBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { IBusinessActivityResponse } from '../../models';
|
||||||
|
import { AdminUserBusinessActivitiesService } from '../../services/businessActivities.service';
|
||||||
|
import { UserBusinessActivitiesFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-businessActivities-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, UserBusinessActivitiesFormComponent],
|
||||||
|
})
|
||||||
|
export class UserBusinessActivitiesComponent extends AbstractList<IBusinessActivityResponse> {
|
||||||
|
@Input() userId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{ field: 'guild', header: 'صنف', type: 'nested', nestedPath: 'name' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly service = inject(AdminUserBusinessActivitiesService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(item: IBusinessActivityResponse) {
|
||||||
|
this.router.navigateByUrl(
|
||||||
|
superAdminUserBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
|
||||||
|
this.userId,
|
||||||
|
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.tax_id" name="tax_id" />
|
||||||
|
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
||||||
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
|
</form>
|
||||||
|
</p-dialog>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// 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 { AdminComplexesService } from '../../services/complexes.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-complex-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||||
|
})
|
||||||
|
export class UserComplexFormComponent extends AbstractFormDialog<
|
||||||
|
IComplexRequest,
|
||||||
|
IComplexResponse
|
||||||
|
> {
|
||||||
|
private readonly service = inject(AdminComplexesService);
|
||||||
|
|
||||||
|
@Input() userId!: string;
|
||||||
|
@Input() businessActivityId!: string;
|
||||||
|
@Input() complexId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
return this.fb.group({
|
||||||
|
name: [this.initialValues?.name || '', [Validators.required]],
|
||||||
|
tax_id: [this.initialValues?.tax_id || '', [Validators.required]],
|
||||||
|
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.userId, this.businessActivityId, this.complexId, formValue);
|
||||||
|
}
|
||||||
|
return this.service.create(this.userId, 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: 'superAdmin-user-complex-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserComplexLayoutComponent {
|
||||||
|
private readonly store = inject(ComplexStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly userId = computed(() => this.pageParams()['userId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = computed(() => this.pageParams()['complexId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.userId(), 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>
|
||||||
|
<superAdmin-user-complex-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[userId]="userId"
|
||||||
|
[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 { superAdminUserComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
|
import { IComplexResponse } from '../../models';
|
||||||
|
import { AdminComplexesService } from '../../services/complexes.service';
|
||||||
|
import { UserComplexFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-complexes-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, UserComplexFormComponent],
|
||||||
|
})
|
||||||
|
export class UserComplexesComponent extends AbstractList<IComplexResponse> {
|
||||||
|
@Input() userId!: string;
|
||||||
|
@Input() businessId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه' },
|
||||||
|
{ field: 'name', header: 'عنوان' },
|
||||||
|
{
|
||||||
|
field: 'created_at',
|
||||||
|
header: 'تاریخ ایجاد',
|
||||||
|
type: 'date',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
private readonly service = inject(AdminComplexesService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
|
override setColumns(): void {
|
||||||
|
this.columns = this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDataRequest() {
|
||||||
|
return this.service.getAll(this.userId, this.businessId);
|
||||||
|
}
|
||||||
|
|
||||||
|
toSinglePage(item: IComplexResponse) {
|
||||||
|
this.router.navigateByUrl(
|
||||||
|
superAdminUserComplexesNamedRoutes.complex.meta.pagePath!(
|
||||||
|
this.userId,
|
||||||
|
this.businessId,
|
||||||
|
item.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,6 +40,6 @@
|
|||||||
[invalid]="form.get('confirmPassword')?.touched && form.get('confirmPassword')?.invalid"
|
[invalid]="form.get('confirmPassword')?.touched && form.get('confirmPassword')?.invalid"
|
||||||
/>
|
/>
|
||||||
</uikit-field> -->
|
</uikit-field> -->
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MustMatch, password } from '@/core/validators';
|
import { mobileValidator } from '@/core/validators';
|
||||||
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||||
@@ -37,7 +37,10 @@ export class UserAccountFormComponent extends AbstractFormDialog<IUserRequest, I
|
|||||||
{
|
{
|
||||||
first_name: [this.initialValues?.first_name || '', [Validators.required]],
|
first_name: [this.initialValues?.first_name || '', [Validators.required]],
|
||||||
last_name: [this.initialValues?.last_name || '', [Validators.required]],
|
last_name: [this.initialValues?.last_name || '', [Validators.required]],
|
||||||
mobile_number: [this.initialValues?.mobile_number || '', [Validators.required]],
|
mobile_number: [
|
||||||
|
this.initialValues?.mobile_number || '',
|
||||||
|
[Validators.required, mobileValidator()],
|
||||||
|
],
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// role: [this.initialValues?.role || '', [Validators.required]],
|
// role: [this.initialValues?.role || '', [Validators.required]],
|
||||||
|
|
||||||
@@ -53,15 +56,18 @@ export class UserAccountFormComponent extends AbstractFormDialog<IUserRequest, I
|
|||||||
{
|
{
|
||||||
first_name: [this.initialValues?.first_name || '', [Validators.required]],
|
first_name: [this.initialValues?.first_name || '', [Validators.required]],
|
||||||
last_name: [this.initialValues?.last_name || '', [Validators.required]],
|
last_name: [this.initialValues?.last_name || '', [Validators.required]],
|
||||||
mobile_number: [this.initialValues?.mobile_number || '', [Validators.required]],
|
mobile_number: [
|
||||||
|
this.initialValues?.mobile_number || '',
|
||||||
|
[Validators.required, mobileValidator()],
|
||||||
|
],
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// role: [this.initialValues?.role || '', [Validators.required]],
|
// role: [this.initialValues?.role || '', [Validators.required]],
|
||||||
password: ['', [Validators.required, password()]],
|
// password: ['', [Validators.required, password()]],
|
||||||
confirmPassword: ['', [Validators.required]],
|
// confirmPassword: ['', [Validators.required]],
|
||||||
},
|
|
||||||
{
|
|
||||||
validators: [MustMatch('password', 'confirmPassword')],
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// validators: [MustMatch('password', 'confirmPassword')],
|
||||||
|
// },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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, signal } from '@angular/core';
|
||||||
|
import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
||||||
|
import { UserStore } from '../store/user.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class UserLayoutComponent {
|
||||||
|
private readonly store = inject(UserStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
readonly userId = signal<string>(this.route.snapshot.paramMap.get('userId')!);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly user = computed(() => this.store.entity());
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.userId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getData();
|
||||||
|
// this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,89 @@
|
|||||||
|
// 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 { AdminPosesService } from '../../services/poses.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-pos-form',
|
||||||
|
templateUrl: './form.component.html',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
Dialog,
|
||||||
|
InputComponent,
|
||||||
|
FormFooterActionsComponent,
|
||||||
|
CatalogDeviceSelectComponent,
|
||||||
|
CatalogProviderSelectComponent,
|
||||||
|
EnumSelectComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class UserPosFormComponent extends AbstractFormDialog<IPosRequest, IPosResponse> {
|
||||||
|
private readonly service = inject(AdminPosesService);
|
||||||
|
|
||||||
|
@Input({ required: true }) userId!: string;
|
||||||
|
@Input({ required: true }) businessActivityId!: string;
|
||||||
|
@Input({ required: true }) complexId!: string;
|
||||||
|
@Input() posId!: string;
|
||||||
|
|
||||||
|
initForm = () => {
|
||||||
|
console.log('posId', this.posId);
|
||||||
|
|
||||||
|
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: 'superAdmin-user-pos-layout',
|
||||||
|
templateUrl: './layout.component.html',
|
||||||
|
imports: [PageLoadingComponent, RouterOutlet],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserPosLayoutComponent {
|
||||||
|
private readonly store = inject(PosStore);
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
readonly loading = computed(() => this.store.loading());
|
||||||
|
readonly pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly userId = computed(() => this.pageParams()['userId']!);
|
||||||
|
readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
|
||||||
|
readonly complexId = computed(() => this.pageParams()['complexId']!);
|
||||||
|
readonly posId = computed(() => this.pageParams()['posId']!);
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(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>
|
||||||
|
<superAdmin-user-pos-form
|
||||||
|
[(visible)]="visibleForm"
|
||||||
|
[editMode]="editMode()"
|
||||||
|
[userId]="userId"
|
||||||
|
[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 { superAdminUserPosesNamedRoutes } from '../../constants/routes/poses';
|
||||||
|
import { IPosResponse } from '../../models';
|
||||||
|
import { AdminPosesService } from '../../services/poses.service';
|
||||||
|
import { UserPosFormComponent } from './form.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-poses-list',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [PageDataListComponent, UserPosFormComponent],
|
||||||
|
})
|
||||||
|
export class UserPosesComponent extends AbstractList<IPosResponse> {
|
||||||
|
@Input() userId!: string;
|
||||||
|
@Input() businessId!: string;
|
||||||
|
@Input() complexId!: string;
|
||||||
|
@Input() fullHeight?: boolean;
|
||||||
|
@Input() header: IColumn[] = [
|
||||||
|
{ field: 'id', header: 'شناسه' },
|
||||||
|
{ 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(AdminPosesService);
|
||||||
|
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(
|
||||||
|
superAdminUserPosesNamedRoutes.pos.meta.pagePath!(
|
||||||
|
this.userId,
|
||||||
|
this.businessId,
|
||||||
|
this.complexId,
|
||||||
|
item.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
const baseUrl = (userId: string) => `/api/v1/admin/users/${userId}/business_activities`;
|
||||||
|
|
||||||
|
export const BUSINESS_ACTIVITIES_API_ROUTES = {
|
||||||
|
list: (userId: string) => `${baseUrl(userId)}`,
|
||||||
|
single: (userId: string, business_activity_id: string) =>
|
||||||
|
`${baseUrl(userId)}/${business_activity_id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const baseUrl = (userId: string, business_activity_id: string) =>
|
||||||
|
`/api/v1/admin/users/${userId}/business_activities/${business_activity_id}/complexes`;
|
||||||
|
|
||||||
|
export const BUSINESS_ACTIVITY_COMPLEXES_API_ROUTES = {
|
||||||
|
list: (userId: string, business_activity_id: string) =>
|
||||||
|
`${baseUrl(userId, business_activity_id)}`,
|
||||||
|
single: (userId: string, business_activity_id: string, complex_id: string) =>
|
||||||
|
`${baseUrl(userId, business_activity_id)}/${complex_id}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const baseUrl = (business_activity_id: string, complex_id: string) =>
|
||||||
|
`/api/v1/admin/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}`,
|
||||||
|
};
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
export * from './accounts';
|
export * from './accounts';
|
||||||
|
export * from './businessActivities';
|
||||||
|
export * from './businessActivityComplexes';
|
||||||
|
export * from './complexPoses';
|
||||||
|
export * from './posAccounts';
|
||||||
|
|
||||||
const baseUrl = '/api/v1/admin/users';
|
const baseUrl = '/api/v1/admin/users';
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
const baseUrl = (complexId: string, posId: string) =>
|
||||||
|
`/api/v1/admin/complexes/${complexId}/poses/${posId}/accounts`;
|
||||||
|
|
||||||
|
export const POS_ACCOUNTS_API_ROUTES = {
|
||||||
|
list: (complexId: string, posId: string) => `${baseUrl(complexId, posId)}`,
|
||||||
|
single: (complexId: string, posId: string, accountId: string) =>
|
||||||
|
`${baseUrl(complexId, posId)}/${accountId}`,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { SUPER_ADMIN_USER_COMPLEXES_ROUTES } from './complexes';
|
||||||
|
|
||||||
|
export type TBusinessActivitiesRouteNames = 'businessActivities' | 'businessActivity';
|
||||||
|
|
||||||
|
export const superAdminUserBusinessActivitiesNamedRoutes: NamedRoutes<TBusinessActivitiesRouteNames> =
|
||||||
|
{
|
||||||
|
businessActivities: {
|
||||||
|
path: 'business_activities',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/list.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivitiesComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیتهای اقتصادی',
|
||||||
|
pagePath: (userId: string) => `/super_admin/users/${userId}/business_activities`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
businessActivity: {
|
||||||
|
path: 'business_activities/:businessActivityId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/single.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivityComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیت اقتصادی',
|
||||||
|
pagePath: (userId: string, businessId: string) =>
|
||||||
|
`/super_admin/users/${userId}/business_activities/${businessId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SUPER_ADMIN_USER_BUSINESS_ACTIVITIES_ROUTES: Routes = [
|
||||||
|
superAdminUserBusinessActivitiesNamedRoutes.businessActivities,
|
||||||
|
{
|
||||||
|
path: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/businessActivities/layout.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivityLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.loadComponent,
|
||||||
|
},
|
||||||
|
...SUPER_ADMIN_USER_COMPLEXES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { SUPER_ADMIN_USER_COMPLEXES_ROUTES } from './complexes';
|
||||||
|
|
||||||
|
export type TBusinessActivitiesRouteNames = 'businessActivities' | 'businessActivity';
|
||||||
|
|
||||||
|
export const superAdminUserBusinessActivitiesNamedRoutes: NamedRoutes<TBusinessActivitiesRouteNames> =
|
||||||
|
{
|
||||||
|
businessActivities: {
|
||||||
|
path: 'business_activities',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/list.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivitiesComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیتهای اقتصادی',
|
||||||
|
pagePath: (userId: string) => `/super_admin/users/${userId}/business_activities`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
businessActivity: {
|
||||||
|
path: 'business_activities/:businessActivityId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/businessActivities/single.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivityComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فعالیت اقتصادی',
|
||||||
|
pagePath: (userId: string, businessId: string) =>
|
||||||
|
`/super_admin/users/${userId}/business_activities/${businessId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SUPER_ADMIN_USER_BUSINESS_ACTIVITIES_ROUTES: Routes = [
|
||||||
|
superAdminUserBusinessActivitiesNamedRoutes.businessActivities,
|
||||||
|
{
|
||||||
|
path: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/businessActivities/layout.component').then(
|
||||||
|
(m) => m.SuperAdminUserBusinessActivityLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.loadComponent,
|
||||||
|
},
|
||||||
|
...SUPER_ADMIN_USER_COMPLEXES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
import { SUPER_ADMIN_USER_POSES_ROUTES } from './poses';
|
||||||
|
|
||||||
|
export type TComplexesRouteNames = 'complexes' | 'complex';
|
||||||
|
|
||||||
|
const baseUrl = (userId: string, businessId: string) =>
|
||||||
|
`/super_admin/users/${userId}/business_activities/${businessId}/complexes`;
|
||||||
|
|
||||||
|
export const superAdminUserComplexesNamedRoutes: NamedRoutes<TComplexesRouteNames> = {
|
||||||
|
complexes: {
|
||||||
|
path: 'complexes',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/complexes/list.component').then(
|
||||||
|
(m) => m.SuperAdminUserComplexesComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فروشگاهها',
|
||||||
|
pagePath: (userId: string, businessId: string) => baseUrl(userId, businessId),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
complex: {
|
||||||
|
path: 'complexes/:complexId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/complexes/single.component').then(
|
||||||
|
(m) => m.SuperAdminUserComplexComponent,
|
||||||
|
),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'فروشگاه',
|
||||||
|
pagePath: (userId: string, businessId: string, complexId: string) =>
|
||||||
|
`${baseUrl(userId, businessId)}/${complexId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SUPER_ADMIN_USER_COMPLEXES_ROUTES: Routes = [
|
||||||
|
superAdminUserComplexesNamedRoutes.complexes,
|
||||||
|
{
|
||||||
|
path: superAdminUserComplexesNamedRoutes.complex.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/complexes/layout.component').then(
|
||||||
|
(m) => m.SuperAdminUserComplexLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: superAdminUserComplexesNamedRoutes.complex.loadComponent,
|
||||||
|
},
|
||||||
|
...SUPER_ADMIN_USER_POSES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NamedRoutes } from '@/core';
|
import { NamedRoutes } from '@/core';
|
||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
|
import { SUPER_ADMIN_USER_BUSINESS_ACTIVITIES_ROUTES } from './businessActivities';
|
||||||
|
|
||||||
export type TUsersRouteNames = 'users' | 'user';
|
export type TUsersRouteNames = 'users' | 'user';
|
||||||
|
|
||||||
@@ -22,4 +23,18 @@ export const usersNamedRoutes: NamedRoutes<TUsersRouteNames> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const USERS_ROUTES: Routes = Object.values(usersNamedRoutes);
|
export const USERS_ROUTES: Routes = [
|
||||||
|
usersNamedRoutes.users,
|
||||||
|
{
|
||||||
|
path: usersNamedRoutes.user.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/layout.component').then((m) => m.UserLayoutComponent),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: usersNamedRoutes.user.loadComponent,
|
||||||
|
},
|
||||||
|
...SUPER_ADMIN_USER_BUSINESS_ACTIVITIES_ROUTES,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { NamedRoutes } from '@/core';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export type TPosesRouteNames = 'poses' | 'pos';
|
||||||
|
|
||||||
|
const baseUrl = (userId: string, businessId: string, complexId: string) =>
|
||||||
|
`/super_admin/users/${userId}/business_activities/${businessId}/complexes/${complexId}/poses`;
|
||||||
|
|
||||||
|
export const superAdminUserPosesNamedRoutes: NamedRoutes<TPosesRouteNames> = {
|
||||||
|
poses: {
|
||||||
|
path: 'poses',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/poses/list.component').then((m) => m.SuperAdminUserPosesComponent),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'پایانههای فروش',
|
||||||
|
pagePath: (userId: string, businessId: string, complexId: string) =>
|
||||||
|
baseUrl(userId, businessId, complexId),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pos: {
|
||||||
|
path: 'poses/:posId',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../views/poses/single.component').then((m) => m.SuperAdminUserPosComponent),
|
||||||
|
// @ts-ignore
|
||||||
|
meta: {
|
||||||
|
title: 'پایانهی فروش',
|
||||||
|
pagePath: (userId: string, businessId: string, complexId: string, posId: string) =>
|
||||||
|
`${baseUrl(userId, businessId, complexId)}/${posId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SUPER_ADMIN_USER_POSES_ROUTES: Routes = [
|
||||||
|
superAdminUserPosesNamedRoutes.poses,
|
||||||
|
{
|
||||||
|
path: superAdminUserPosesNamedRoutes.pos.path,
|
||||||
|
loadComponent: () =>
|
||||||
|
import('../../components/poses/layout.component').then(
|
||||||
|
(m) => m.SuperAdminUserPosLayoutComponent,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: superAdminUserPosesNamedRoutes.pos.loadComponent,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -2,7 +2,7 @@ import { TAccountType } from '@/core/constants/accountTypes.const';
|
|||||||
|
|
||||||
export interface IAccountRawResponse {
|
export interface IAccountRawResponse {
|
||||||
username: string;
|
username: string;
|
||||||
id: number;
|
id: string;
|
||||||
}
|
}
|
||||||
export interface IAccountResponse extends IAccountRawResponse {}
|
export interface IAccountResponse extends IAccountRawResponse {}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import ISummary from '@/core/models/summary';
|
||||||
|
|
||||||
|
export interface IBusinessActivityRawResponse {
|
||||||
|
name: string;
|
||||||
|
guild: ISummary;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
||||||
|
|
||||||
|
export interface IBusinessActivityRequest {
|
||||||
|
name: string;
|
||||||
|
guild_id: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export interface IComplexRawResponse {
|
||||||
|
name: string;
|
||||||
|
address: string;
|
||||||
|
tax_id: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface IComplexResponse extends IComplexRawResponse {}
|
||||||
|
|
||||||
|
export interface IComplexRequest {
|
||||||
|
name: string;
|
||||||
|
address: string;
|
||||||
|
tax_id: string;
|
||||||
|
}
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
export * from './accounts_io';
|
export * from './accounts_io';
|
||||||
|
export * from './businessActivities_io';
|
||||||
|
export * from './complexes_io';
|
||||||
export * from './io';
|
export * from './io';
|
||||||
|
export * from './poses_io';
|
||||||
|
|||||||
@@ -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,45 @@
|
|||||||
|
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 AdminUserBusinessActivitiesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = BUSINESS_ACTIVITIES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(userId: string): Observable<IPaginatedResponse<IBusinessActivityResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IBusinessActivityRawResponse>>(
|
||||||
|
this.apiRoutes.list(userId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(userId: string, businessActivityId: string): Observable<IBusinessActivityResponse> {
|
||||||
|
console.log(userId, businessActivityId);
|
||||||
|
|
||||||
|
return this.http.get<IBusinessActivityRawResponse>(
|
||||||
|
this.apiRoutes.single(userId, businessActivityId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(userId: string, data: IBusinessActivityRequest): Observable<IBusinessActivityResponse> {
|
||||||
|
return this.http.post<IBusinessActivityRawResponse>(this.apiRoutes.list(userId), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
userId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
data: IBusinessActivityRequest,
|
||||||
|
): Observable<IBusinessActivityResponse> {
|
||||||
|
return this.http.patch<IBusinessActivityRawResponse>(
|
||||||
|
this.apiRoutes.single(userId, 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 AdminComplexesService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private apiRoutes = BUSINESS_ACTIVITY_COMPLEXES_API_ROUTES;
|
||||||
|
|
||||||
|
getAll(
|
||||||
|
userId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
): Observable<IPaginatedResponse<IComplexResponse>> {
|
||||||
|
return this.http.get<IPaginatedResponse<IComplexRawResponse>>(
|
||||||
|
this.apiRoutes.list(userId, businessActivityId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
getSingle(
|
||||||
|
userId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.get<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.single(userId, businessActivityId, complexId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
create(
|
||||||
|
userId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
data: IComplexRequest,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.post<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.list(userId, businessActivityId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
userId: string,
|
||||||
|
businessActivityId: string,
|
||||||
|
complexId: string,
|
||||||
|
data: IComplexRequest,
|
||||||
|
): Observable<IComplexResponse> {
|
||||||
|
return this.http.patch<IComplexRawResponse>(
|
||||||
|
this.apiRoutes.single(userId, businessActivityId, complexId),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class AdminPosesService {
|
||||||
|
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';
|
||||||
|
import { IPosRawResponse, IPosRequest, IPosResponse } from '../models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class AdminPosesService {
|
||||||
|
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,56 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { inject, Injectable } from '@angular/core';
|
||||||
|
import { catchError, finalize, throwError } from 'rxjs';
|
||||||
|
import { IBusinessActivityResponse } from '../models';
|
||||||
|
import { AdminUserBusinessActivitiesService } from '../services/businessActivities.service';
|
||||||
|
|
||||||
|
interface BusinessActivityState extends EntityState<IBusinessActivityResponse> {}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class BusinessActivityStore extends EntityStore<
|
||||||
|
IBusinessActivityResponse,
|
||||||
|
BusinessActivityState
|
||||||
|
> {
|
||||||
|
private readonly service = inject(AdminUserBusinessActivitiesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(userId: string, business_id: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(userId, business_id)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError(() => {
|
||||||
|
this.patchState({
|
||||||
|
error: '',
|
||||||
|
});
|
||||||
|
return throwError('');
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { inject, Injectable } from '@angular/core';
|
||||||
|
import { catchError, finalize, throwError } from 'rxjs';
|
||||||
|
import { IComplexResponse } from '../models';
|
||||||
|
import { AdminComplexesService } from '../services/complexes.service';
|
||||||
|
|
||||||
|
interface ComplexState extends EntityState<IComplexResponse> {}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class ComplexStore extends EntityStore<IComplexResponse, ComplexState> {
|
||||||
|
private readonly service = inject(AdminComplexesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(userId: string, businessId: string, complexId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(userId, businessId, complexId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError(() => {
|
||||||
|
this.patchState({
|
||||||
|
error: '',
|
||||||
|
});
|
||||||
|
return throwError('');
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { EntityState, EntityStore } from '@/core/state';
|
||||||
|
import { inject, Injectable } from '@angular/core';
|
||||||
|
import { catchError, finalize, throwError } from 'rxjs';
|
||||||
|
import { IPosResponse } from '../models';
|
||||||
|
import { AdminPosesService } from '../services/poses.service';
|
||||||
|
|
||||||
|
interface PosState extends EntityState<IPosResponse> {}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PosStore extends EntityStore<IPosResponse, PosState> {
|
||||||
|
private readonly service = inject(AdminPosesService);
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(businessId: string, complexId: string, posId: string) {
|
||||||
|
this.patchState({ loading: true });
|
||||||
|
this.service
|
||||||
|
.getSingle(businessId, complexId, posId)
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.patchState({ loading: false });
|
||||||
|
}),
|
||||||
|
catchError(() => {
|
||||||
|
this.patchState({
|
||||||
|
error: '',
|
||||||
|
});
|
||||||
|
return throwError('');
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.subscribe((entity) => {
|
||||||
|
this.patchState({ entity });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override reset(): void {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
|
entity: null,
|
||||||
|
initialized: false,
|
||||||
|
isRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<superAdmin-user-businessActivities-list [userId]="userId()" />
|
||||||
@@ -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 { UserBusinessActivitiesComponent } from '../../components/businessActivities/list.component';
|
||||||
|
import { usersNamedRoutes } from '../../constants';
|
||||||
|
import { superAdminUserBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { UserStore } from '../../store/user.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-businessActivities',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [UserBusinessActivitiesComponent],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserBusinessActivitiesComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly userStore = inject(UserStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
userId = signal<string>(this.pageParams()['userId']);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
{
|
||||||
|
...usersNamedRoutes.users.meta,
|
||||||
|
routerLink: usersNamedRoutes.users.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.userStore.entity()?.fullname,
|
||||||
|
routerLink: usersNamedRoutes.user.meta.pagePath!(this.userId()),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta.title,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<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()?.guild?.name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<superAdmin-user-complexes-list [userId]="userId()" [businessId]="businessId()" />
|
||||||
|
|
||||||
|
<superAdmin-user-businessActivities-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[userId]="userId()"
|
||||||
|
[businessActivityId]="businessId()"
|
||||||
|
[initialValues]="businessActivity() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
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 { UserBusinessActivitiesFormComponent } from '../../components/businessActivities/form.component';
|
||||||
|
import { UserComplexesComponent } from '../../components/complexes/list.component';
|
||||||
|
import { usersNamedRoutes } from '../../constants';
|
||||||
|
import { superAdminUserBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { UserStore } from '../../store/user.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-businessActivity',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [
|
||||||
|
AppCardComponent,
|
||||||
|
KeyValueComponent,
|
||||||
|
UserBusinessActivitiesFormComponent,
|
||||||
|
UserComplexesComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserBusinessActivityComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly store = inject(BusinessActivityStore);
|
||||||
|
private readonly userStore = inject(UserStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly userId = signal<string>(this.pageParams()['userId']!);
|
||||||
|
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) {
|
||||||
|
console.log(this.businessActivity()?.id);
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
this.store.getData(this.userId(), this.businessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
{
|
||||||
|
...usersNamedRoutes.users.meta,
|
||||||
|
routerLink: usersNamedRoutes.users.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.userStore.entity()?.fullname,
|
||||||
|
routerLink: usersNamedRoutes.user.meta.pagePath!(this.userId()),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.businessActivity()?.name,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './list.component';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<superAdmin-user-complexes-list [userId]="userId()" [businessId]="businessId()" />
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// 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 { UserComplexesComponent } from '../../components/complexes/list.component';
|
||||||
|
import { usersNamedRoutes } from '../../constants';
|
||||||
|
import { superAdminUserBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { superAdminUserComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { UserStore } from '../../store/user.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-complexes',
|
||||||
|
templateUrl: './list.component.html',
|
||||||
|
imports: [UserComplexesComponent],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserComplexesComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly userStore = inject(UserStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
userId = signal<string>(this.pageParams()['userId']);
|
||||||
|
businessId = signal<string>(this.pageParams()['businessActivityId']);
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.setBreadcrumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
{
|
||||||
|
...usersNamedRoutes.users.meta,
|
||||||
|
routerLink: usersNamedRoutes.users.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.userStore.entity()?.fullname,
|
||||||
|
routerLink: usersNamedRoutes.user.meta.pagePath!(this.userId()),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta.title,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.businessStore.entity()?.name,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: superAdminUserComplexesNamedRoutes.complexes.meta.title,
|
||||||
|
routerLink: superAdminUserComplexesNamedRoutes.complexes.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<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()?.tax_id" />
|
||||||
|
<app-key-value label="آدرس" [value]="complex()?.address" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</app-card-data>
|
||||||
|
|
||||||
|
<superAdmin-user-poses-list [userId]="userId()" [businessId]="businessId()" [complexId]="complexId()" />
|
||||||
|
|
||||||
|
<superAdmin-user-complex-form
|
||||||
|
[(visible)]="editMode"
|
||||||
|
[editMode]="true"
|
||||||
|
[userId]="userId()"
|
||||||
|
[businessActivityId]="businessId()"
|
||||||
|
[complexId]="complexId()"
|
||||||
|
[initialValues]="complex() || undefined"
|
||||||
|
(onSubmit)="getData()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
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 { UserComplexFormComponent } from '../../components/complexes/form.component';
|
||||||
|
import { UserPosesComponent } from '../../components/poses/list.component';
|
||||||
|
import { usersNamedRoutes } from '../../constants';
|
||||||
|
import { superAdminUserBusinessActivitiesNamedRoutes } from '../../constants/routes/businessActivities';
|
||||||
|
import { superAdminUserComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
|
import { BusinessActivityStore } from '../../store/businessActivity.store';
|
||||||
|
import { ComplexStore } from '../../store/complex.store';
|
||||||
|
import { UserStore } from '../../store/user.store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'superAdmin-user-complex',
|
||||||
|
templateUrl: './single.component.html',
|
||||||
|
imports: [AppCardComponent, KeyValueComponent, UserComplexFormComponent, UserPosesComponent],
|
||||||
|
})
|
||||||
|
export class SuperAdminUserComplexComponent {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
private readonly breadcrumbService = inject(BreadcrumbService);
|
||||||
|
private readonly store = inject(ComplexStore);
|
||||||
|
private readonly userStore = inject(UserStore);
|
||||||
|
private readonly businessStore = inject(BusinessActivityStore);
|
||||||
|
|
||||||
|
pageParams = computed(() => pageParamsUtils(this.route));
|
||||||
|
|
||||||
|
readonly userId = signal<string>(this.pageParams()['userId']!);
|
||||||
|
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.userId(), this.businessId(), this.complexId());
|
||||||
|
}
|
||||||
|
|
||||||
|
setBreadcrumb() {
|
||||||
|
this.breadcrumbService.setItems([
|
||||||
|
{
|
||||||
|
...usersNamedRoutes.users.meta,
|
||||||
|
routerLink: usersNamedRoutes.users.meta.pagePath!(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.userStore.entity()?.fullname,
|
||||||
|
routerLink: usersNamedRoutes.user.meta.pagePath!(this.userId()),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivities.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.businessStore.entity()?.name,
|
||||||
|
routerLink: superAdminUserBusinessActivitiesNamedRoutes.businessActivity.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...superAdminUserComplexesNamedRoutes.complexes.meta,
|
||||||
|
routerLink: superAdminUserComplexesNamedRoutes.complexes.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.complex()?.name,
|
||||||
|
routerLink: superAdminUserComplexesNamedRoutes.complex.meta.pagePath!(
|
||||||
|
this.userId(),
|
||||||
|
this.businessId(),
|
||||||
|
this.complexId(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user