diff --git a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html index 4d969e2..dd9b4dd 100644 --- a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html +++ b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.html @@ -46,17 +46,17 @@
@if (invoice.customer.type === "INDIVIDUAL") { - - - - - + + + + + } @else { - - - - + + + + }
} @else if (invoice.unknown_customer) { diff --git a/src/app/domains/consumer/models/saleInvoice.io.ts b/src/app/domains/consumer/models/saleInvoice.io.ts index 45e3d97..e97b79c 100644 --- a/src/app/domains/consumer/models/saleInvoice.io.ts +++ b/src/app/domains/consumer/models/saleInvoice.io.ts @@ -30,8 +30,8 @@ interface Payment { interface Customer { id: string; type: string; - customer_legal?: CustomerLegal; - customer_individual?: CustomerIndividual; + legal?: CustomerLegal; + individual?: CustomerIndividual; } interface CustomerIndividual { diff --git a/src/app/domains/consumer/modules/accounts/components/form.component.html b/src/app/domains/consumer/modules/accounts/components/form.component.html index 79a0dc2..eb59e74 100644 --- a/src/app/domains/consumer/modules/accounts/components/form.component.html +++ b/src/app/domains/consumer/modules/accounts/components/form.component.html @@ -7,34 +7,10 @@ (onHide)="close()" >
- - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/consumer/modules/accounts/components/form.component.ts b/src/app/domains/consumer/modules/accounts/components/form.component.ts index a64efb6..9a1a768 100644 --- a/src/app/domains/consumer/modules/accounts/components/form.component.ts +++ b/src/app/domains/consumer/modules/accounts/components/form.component.ts @@ -1,18 +1,17 @@ import { MustMatch, password } from '@/core/validators'; import { AbstractFormDialog } from '@/shared/abstractClasses'; +import { SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IAccountRequest, IAccountResponse } from '../models'; import { AccountsService } from '../services/main.service'; @Component({ selector: 'account-password-form', templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, UikitFieldComponent, Password], + imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, SharedPasswordInputComponent], }) export class ConsumerAccountPasswordFormComponent extends AbstractFormDialog< IAccountRequest, diff --git a/src/app/domains/consumer/modules/businessActivities/components/goods/form.component.ts b/src/app/domains/consumer/modules/businessActivities/components/goods/form.component.ts index 50f5dd3..80ed53f 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/goods/form.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/components/goods/form.component.ts @@ -7,11 +7,14 @@ import { Dialog } from 'primeng/dialog'; import { EnumSelectComponent } from '@/shared/apiEnum/select.component'; import { CatalogGuildGoodCategoriesSelectComponent } from '@/shared/catalog/guildGoodCategories'; -import { IConsumerComplexGoodRequest, IConsumerComplexGoodResponse } from '../../models/goods_io'; -import { GuildGoodsService } from '../../services/goods.service'; +import { + IConsumerBusinessActivityGoodRequest, + IConsumerBusinessActivityGoodResponse, +} from '../../models/goods_io'; +import { BusinessActivityGoodsService } from '../../services/goods.service'; @Component({ - selector: 'consumer-complex-good-form', + selector: 'consumer-businessActivity-good-form', templateUrl: './form.component.html', imports: [ ReactiveFormsModule, @@ -22,16 +25,15 @@ import { GuildGoodsService } from '../../services/goods.service'; CatalogGuildGoodCategoriesSelectComponent, ], }) -export class ConsumerComplexGoodFormComponent extends AbstractFormDialog< - IConsumerComplexGoodRequest, - IConsumerComplexGoodResponse +export class ConsumerBusinessActivityGoodFormComponent extends AbstractFormDialog< + IConsumerBusinessActivityGoodRequest, + IConsumerBusinessActivityGoodResponse > { @Input({ required: true }) businessId!: string; - @Input({ required: true }) complexId!: string; @Input({ required: true }) guildId!: string; @Input() categoryId?: string; - private service = inject(GuildGoodsService); + private service = inject(BusinessActivityGoodsService); form = this.fb.group({ name: [this.initialValues?.name || '', [Validators.required]], @@ -46,10 +48,10 @@ export class ConsumerComplexGoodFormComponent extends AbstractFormDialog< return `${this.editMode ? 'ویرایش' : 'ایجاد'} کالا`; } - override submitForm(payload: IConsumerComplexGoodRequest) { + override submitForm(payload: IConsumerBusinessActivityGoodRequest) { if (this.editMode) { - return this.service.update(this.businessId, this.complexId, this.categoryId!, payload); + return this.service.update(this.businessId, this.categoryId!, payload); } - return this.service.create(this.businessId, this.complexId, payload); + return this.service.create(this.businessId, payload); } } diff --git a/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.html b/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.html index 331d3aa..4a72f19 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.html +++ b/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.html @@ -14,9 +14,8 @@ (onAdd)="openAddForm()" (onRefresh)="refresh()" /> - { +export class ConsumerBusinessActivityGoodsListComponent extends AbstractList { @Input({ required: true }) businessId!: string; - @Input({ required: true }) complexId!: string; @Input({ required: true }) guildId!: string; @Input() fullHeight?: boolean; @Input() header: IColumn[] = [ @@ -35,13 +34,13 @@ export class ConsumerComplexGoodsListComponent extends AbstractList اطلاعات ورود - - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + } diff --git a/src/app/domains/consumer/modules/businessActivities/components/poses/form.component.ts b/src/app/domains/consumer/modules/businessActivities/components/poses/form.component.ts index ad7e283..b844993 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/poses/form.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/components/poses/form.component.ts @@ -4,14 +4,12 @@ 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 { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; import { Divider } from 'primeng/divider'; -import { Password } from 'primeng/password'; import { IPosRequest, IPosResponse } from '../../models'; import { ConsumerPosesService } from '../../services/poses.service'; @@ -26,9 +24,8 @@ import { ConsumerPosesService } from '../../services/poses.service'; CatalogDeviceSelectComponent, CatalogProviderSelectComponent, EnumSelectComponent, - UikitFieldComponent, - Password, Divider, + SharedPasswordInputComponent, ], }) export class ConsumerPosFormComponent extends AbstractFormDialog { diff --git a/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/businessActivityGoods.ts b/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/businessActivityGoods.ts new file mode 100644 index 0000000..0bc934e --- /dev/null +++ b/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/businessActivityGoods.ts @@ -0,0 +1,6 @@ +const baseUrl = (businessId: string) => `/api/v1/consumer/business_activities/${businessId}/goods`; + +export const CONSUMER_BUSINESS_ACTIVITY_GOODS_API_ROUTES = { + list: (businessId: string) => `${baseUrl(businessId)}`, + single: (businessId: string, id: string) => `${baseUrl(businessId)}/${id}`, +}; diff --git a/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/complexGoods.ts b/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/complexGoods.ts deleted file mode 100644 index 4ad6919..0000000 --- a/src/app/domains/consumer/modules/businessActivities/constants/apiRoutes/complexGoods.ts +++ /dev/null @@ -1,8 +0,0 @@ -const baseUrl = (businessId: string, complexId: string) => - `/api/v1/consumer/business_activities/${businessId}/complexes/${complexId}/goods`; - -export const CONSUMER_COMPLEX_GOODS_API_ROUTES = { - list: (businessId: string, complexId: string) => `${baseUrl(businessId, complexId)}`, - single: (businessId: string, complexId: string, id: string) => - `${baseUrl(businessId, complexId)}/${id}`, -}; diff --git a/src/app/domains/consumer/modules/businessActivities/constants/routes/goods.ts b/src/app/domains/consumer/modules/businessActivities/constants/routes/goods.ts index ca881ad..342e9af 100644 --- a/src/app/domains/consumer/modules/businessActivities/constants/routes/goods.ts +++ b/src/app/domains/consumer/modules/businessActivities/constants/routes/goods.ts @@ -3,18 +3,19 @@ import { Routes } from '@angular/router'; export type TGoodsRouteNames = 'goods'; -const baseUrl = (businessId: string, complexId: string) => - `/consumer/business_activities/${businessId}/complexes/${complexId}/goods`; +const baseUrl = (businessId: string) => `/consumer/business_activities/${businessId}/goods`; -export const consumerComplexGoodsNamedRoutes: NamedRoutes = { +export const consumerBusinessActivityGoodsNamedRoutes: NamedRoutes = { goods: { path: 'goods', loadComponent: () => - import('../../views/goods/list.component').then((m) => m.ConsumerComplexGoodsComponent), + import('../../views/goods/list.component').then( + (m) => m.ConsumerBusinessActivityGoodsComponent, + ), // @ts-ignore meta: { title: 'کالاها', - pagePath: (businessId: string, complexId: string) => baseUrl(businessId, complexId), + pagePath: (businessId: string) => baseUrl(businessId), }, }, // good: { @@ -25,15 +26,15 @@ export const consumerComplexGoodsNamedRoutes: NamedRoutes = { // meta: { // title: 'پایانه‌ی فروش', // pagePath: (businessId: string, complexId: string, goodId: string) => - // `${baseUrl(businessId, complexId)}/${goodId}`, + // `${baseUrl(businessId)}/${goodId}`, // }, // }, }; -export const CONSUMER_COMPLEX_GOODS_ROUTES: Routes = [ - consumerComplexGoodsNamedRoutes.goods, +export const CONSUMER_BUSINESS_ACTIVITY_GOODS_ROUTES: Routes = [ + consumerBusinessActivityGoodsNamedRoutes.goods, // { - // path: consumerComplexGoodsNamedRoutes.good.path, + // path: consumerBusinessActivityGoodsNamedRoutes.good.path, // loadComponent: () => // import('../../components/goods/layout.component').then( // (m) => m.SuperAdminConsumerPosLayoutComponent, @@ -41,7 +42,7 @@ export const CONSUMER_COMPLEX_GOODS_ROUTES: Routes = [ // children: [ // { // path: '', - // loadComponent: consumerComplexGoodsNamedRoutes.good.loadComponent, + // loadComponent: consumerBusinessActivityGoodsNamedRoutes.good.loadComponent, // }, // ], // }, diff --git a/src/app/domains/consumer/modules/businessActivities/constants/routes/index.ts b/src/app/domains/consumer/modules/businessActivities/constants/routes/index.ts index ae7ab6b..bbf316d 100644 --- a/src/app/domains/consumer/modules/businessActivities/constants/routes/index.ts +++ b/src/app/domains/consumer/modules/businessActivities/constants/routes/index.ts @@ -1,6 +1,7 @@ import { NamedRoutes } from '@/core'; import { Routes } from '@angular/router'; import { CONSUMER_COMPLEXES_ROUTES } from './complexes'; +import { CONSUMER_BUSINESS_ACTIVITY_GOODS_ROUTES } from './goods'; export type TConsumerBusinessActivityRouteNames = 'businessActivities' | 'businessActivity'; @@ -38,6 +39,7 @@ export const CONSUMER_BUSINESS_ACTIVITIES_ROUTES: Routes = [ ...consumerBusinessActivityNamedRoutes.businessActivity, path: '', }, + ...CONSUMER_BUSINESS_ACTIVITY_GOODS_ROUTES, ...CONSUMER_COMPLEXES_ROUTES, ], }, diff --git a/src/app/domains/consumer/modules/businessActivities/models/goods_io.d.ts b/src/app/domains/consumer/modules/businessActivities/models/goods_io.d.ts index 017bb49..feb43c7 100644 --- a/src/app/domains/consumer/modules/businessActivities/models/goods_io.d.ts +++ b/src/app/domains/consumer/modules/businessActivities/models/goods_io.d.ts @@ -1,6 +1,6 @@ import ISummary from '@/core/models'; -export interface IConsumerComplexGoodRawResponse { +export interface IConsumerBusinessActivityGoodRawResponse { id: string; name: string; sku: string; @@ -11,9 +11,9 @@ export interface IConsumerComplexGoodRawResponse { created_at: string; updated_at: string; } -export interface IConsumerComplexGoodResponse extends IConsumerComplexGoodRawResponse {} +export interface IConsumerBusinessActivityGoodResponse extends IConsumerBusinessActivityGoodRawResponse {} -export interface IConsumerComplexGoodRequest { +export interface IConsumerBusinessActivityGoodRequest { name: string; sku: string; category_id: string; diff --git a/src/app/domains/consumer/modules/businessActivities/services/goods.service.ts b/src/app/domains/consumer/modules/businessActivities/services/goods.service.ts index 3c339ab..9373af3 100644 --- a/src/app/domains/consumer/modules/businessActivities/services/goods.service.ts +++ b/src/app/domains/consumer/modules/businessActivities/services/goods.service.ts @@ -2,56 +2,49 @@ import { IPaginatedResponse } from '@/core/models/service.model'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { CONSUMER_COMPLEX_GOODS_API_ROUTES } from '../constants/apiRoutes/complexGoods'; +import { CONSUMER_BUSINESS_ACTIVITY_GOODS_API_ROUTES } from '../constants/apiRoutes/businessActivityGoods'; import { - IConsumerComplexGoodRawResponse, - IConsumerComplexGoodRequest, - IConsumerComplexGoodResponse, + IConsumerBusinessActivityGoodRawResponse, + IConsumerBusinessActivityGoodRequest, + IConsumerBusinessActivityGoodResponse, } from '../models/goods_io'; @Injectable({ providedIn: 'root' }) -export class GuildGoodsService { +export class BusinessActivityGoodsService { constructor(private http: HttpClient) {} - private apiRoutes = CONSUMER_COMPLEX_GOODS_API_ROUTES; + private apiRoutes = CONSUMER_BUSINESS_ACTIVITY_GOODS_API_ROUTES; getAll( businessId: string, - complexId: string, - ): Observable> { - return this.http.get>( - this.apiRoutes.list(businessId, complexId), + ): Observable> { + return this.http.get>( + this.apiRoutes.list(businessId), ); } - getSingle( - businessId: string, - complexId: string, - id: string, - ): Observable { - return this.http.get( - this.apiRoutes.single(businessId, complexId, id), + getSingle(businessId: string, id: string): Observable { + return this.http.get( + this.apiRoutes.single(businessId, id), ); } create( businessId: string, - complexId: string, - data: IConsumerComplexGoodRequest, - ): Observable { - return this.http.post( - this.apiRoutes.list(businessId, complexId), + data: IConsumerBusinessActivityGoodRequest, + ): Observable { + return this.http.post( + this.apiRoutes.list(businessId), data, ); } update( businessId: string, - complexId: string, id: string, - data: IConsumerComplexGoodRequest, - ): Observable { - return this.http.patch( - this.apiRoutes.single(businessId, complexId, id), + data: IConsumerBusinessActivityGoodRequest, + ): Observable { + return this.http.patch( + this.apiRoutes.single(businessId, id), data, ); } diff --git a/src/app/domains/consumer/modules/businessActivities/views/complexes/single.component.html b/src/app/domains/consumer/modules/businessActivities/views/complexes/single.component.html index ef22f77..3cfb78f 100644 --- a/src/app/domains/consumer/modules/businessActivities/views/complexes/single.component.html +++ b/src/app/domains/consumer/modules/businessActivities/views/complexes/single.component.html @@ -10,7 +10,6 @@ - + diff --git a/src/app/domains/consumer/modules/businessActivities/views/goods/list.component.ts b/src/app/domains/consumer/modules/businessActivities/views/goods/list.component.ts index 5fc301b..6198623 100644 --- a/src/app/domains/consumer/modules/businessActivities/views/goods/list.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/views/goods/list.component.ts @@ -3,26 +3,23 @@ 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 { ConsumerComplexGoodsListComponent } from '../../components/goods/list.component'; -import { consumerComplexGoodsNamedRoutes } from '../../constants/routes/goods'; +import { ConsumerBusinessActivityGoodsListComponent } from '../../components/goods/list.component'; +import { consumerBusinessActivityGoodsNamedRoutes } from '../../constants/routes/goods'; import { BusinessActivityStore } from '../../store/businessActivity.store'; -import { ConsumerComplexStore } from '../../store/complex.store'; @Component({ - selector: 'consumer-complex-goods', + selector: 'consumer-businessActivity-goods', templateUrl: './list.component.html', - imports: [ConsumerComplexGoodsListComponent], + imports: [ConsumerBusinessActivityGoodsListComponent], }) -export class ConsumerComplexGoodsComponent { +export class ConsumerBusinessActivityGoodsComponent { private readonly route = inject(ActivatedRoute); private readonly breadcrumbService = inject(BreadcrumbService); private readonly businessStore = inject(BusinessActivityStore); - private readonly complexStore = inject(ConsumerComplexStore); pageParams = computed(() => pageParamsUtils(this.route)); businessId = signal(this.pageParams()['businessActivityId']); - complexId = signal(this.pageParams()['complexId']); business = computed(() => this.businessStore.entity()); @@ -33,12 +30,10 @@ export class ConsumerComplexGoodsComponent { setBreadcrumb() { this.breadcrumbService.setItems([ ...this.businessStore.breadcrumbItems(), - ...this.complexStore.breadcrumbItems(), { - title: consumerComplexGoodsNamedRoutes.goods.meta.title, - routerLink: consumerComplexGoodsNamedRoutes.goods.meta.pagePath!( + title: consumerBusinessActivityGoodsNamedRoutes.goods.meta.title, + routerLink: consumerBusinessActivityGoodsNamedRoutes.goods.meta.pagePath!( this.businessId(), - this.complexId(), ), }, ]); diff --git a/src/app/domains/consumer/modules/businessActivities/views/single.component.html b/src/app/domains/consumer/modules/businessActivities/views/single.component.html index bd7dcd6..d300f23 100644 --- a/src/app/domains/consumer/modules/businessActivities/views/single.component.html +++ b/src/app/domains/consumer/modules/businessActivities/views/single.component.html @@ -1,6 +1,8 @@
- + + مدیریت کالاها +
diff --git a/src/app/domains/consumer/modules/businessActivities/views/single.component.ts b/src/app/domains/consumer/modules/businessActivities/views/single.component.ts index 67988e7..4db3856 100644 --- a/src/app/domains/consumer/modules/businessActivities/views/single.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/views/single.component.ts @@ -1,10 +1,12 @@ import { BreadcrumbService } from '@/core/services'; import { AppCardComponent, KeyValueComponent } from '@/shared/components'; import { Component, computed, effect, inject, signal } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, RouterLink } from '@angular/router'; +import { ButtonDirective } from 'primeng/button'; import { Divider } from 'primeng/divider'; import { ConsumerComplexListComponent } from '../components/complexes/list.component'; import { ConsumerBusinessActivityFormComponent } from '../components/form.component'; +import { consumerBusinessActivityGoodsNamedRoutes } from '../constants/routes/goods'; import { BusinessActivityStore } from '../store/businessActivity.store'; @Component({ @@ -16,9 +18,19 @@ import { BusinessActivityStore } from '../store/businessActivity.store'; ConsumerBusinessActivityFormComponent, ConsumerComplexListComponent, Divider, + ButtonDirective, + RouterLink, ], }) export class ConsumerBusinessActivityComponent { + constructor() { + effect(() => { + if (this.business()?.id) { + this.setBreadcrumb(); + } + }); + } + private readonly store = inject(BusinessActivityStore); private readonly route = inject(ActivatedRoute); private readonly breadcrumbService = inject(BreadcrumbService); @@ -30,13 +42,11 @@ export class ConsumerBusinessActivityComponent { readonly business = computed(() => this.store.entity()); readonly businessBreadcrumb = computed(() => this.store.breadcrumbItems()); - constructor() { - effect(() => { - if (this.business()?.id) { - this.setBreadcrumb(); - } - }); - } + readonly goodsPageRoute = computed(() => + this.business() + ? consumerBusinessActivityGoodsNamedRoutes.goods.meta.pagePath!(this.business()!.id) + : '', + ); getData() { this.store.getData(this.businessId()); diff --git a/src/app/domains/consumer/modules/customers/components/form-individual.component.ts b/src/app/domains/consumer/modules/customers/components/form-individual.component.ts index 49790cb..8022cb0 100644 --- a/src/app/domains/consumer/modules/customers/components/form-individual.component.ts +++ b/src/app/domains/consumer/modules/customers/components/form-individual.component.ts @@ -25,18 +25,15 @@ export class ConsumerCustomerIndividualFormComponent extends AbstractForm< initForm = () => { return this.fb.group({ - first_name: [ - this.initialValues?.customer_individual?.first_name || '', - [Validators.required], - ], - last_name: [this.initialValues?.customer_individual?.last_name || '', [Validators.required]], + first_name: [this.initialValues?.individual?.first_name || '', [Validators.required]], + last_name: [this.initialValues?.individual?.last_name || '', [Validators.required]], national_id: [ - this.initialValues?.customer_individual?.national_id || '', + this.initialValues?.individual?.national_id || '', [Validators.required, nationalIdValidator()], ], - economic_code: [this.initialValues?.customer_individual?.economic_code || ''], + economic_code: [this.initialValues?.individual?.economic_code || ''], postal_code: [ - this.initialValues?.customer_individual?.postal_code || '', + this.initialValues?.individual?.postal_code || '', [Validators.required, postalCodeValidator()], ], }); diff --git a/src/app/domains/consumer/modules/customers/components/form-legal.component.ts b/src/app/domains/consumer/modules/customers/components/form-legal.component.ts index 70487a3..61788f2 100644 --- a/src/app/domains/consumer/modules/customers/components/form-legal.component.ts +++ b/src/app/domains/consumer/modules/customers/components/form-legal.component.ts @@ -23,17 +23,14 @@ export class ConsumerCustomerLegalFormComponent extends AbstractForm< private initForm() { const form = this.fb.group({ - company_name: [this.initialValues?.customer_legal?.company_name || '', [Validators.required]], + company_name: [this.initialValues?.legal?.company_name || '', [Validators.required]], registration_number: [ - this.initialValues?.customer_legal?.registration_number || '', - [Validators.required], - ], - economic_code: [ - this.initialValues?.customer_legal?.economic_code || '', + this.initialValues?.legal?.registration_number || '', [Validators.required], ], + economic_code: [this.initialValues?.legal?.economic_code || '', [Validators.required]], postal_code: [ - this.initialValues?.customer_legal?.postal_code || '', + this.initialValues?.legal?.postal_code || '', [Validators.required, postalCodeValidator()], ], }); diff --git a/src/app/domains/consumer/modules/customers/components/list.component.ts b/src/app/domains/consumer/modules/customers/components/list.component.ts index bb82580..3c8497e 100644 --- a/src/app/domains/consumer/modules/customers/components/list.component.ts +++ b/src/app/domains/consumer/modules/customers/components/list.component.ts @@ -33,9 +33,9 @@ export class ConsumerCustomerListComponent extends AbstractList; - customer_legal: Maybe; + individual: Maybe; + legal: Maybe; } export interface ICustomerResponse extends ICustomerRawResponse {} diff --git a/src/app/domains/consumer/modules/customers/store/customer.store.ts b/src/app/domains/consumer/modules/customers/store/customer.store.ts index 95f4ee0..8e224cf 100644 --- a/src/app/domains/consumer/modules/customers/store/customer.store.ts +++ b/src/app/domains/consumer/modules/customers/store/customer.store.ts @@ -38,8 +38,8 @@ export class ConsumerCustomerStore extends EntityStore @if (customer()?.type === "LEGAL") {
- - - - + + + +
} @else if (customer()?.type === "INDIVIDUAL") {
- - - - - + + + + +
}
diff --git a/src/app/domains/partner/modules/accounts/components/form.component.html b/src/app/domains/partner/modules/accounts/components/form.component.html index 79a0dc2..eb59e74 100644 --- a/src/app/domains/partner/modules/accounts/components/form.component.html +++ b/src/app/domains/partner/modules/accounts/components/form.component.html @@ -7,34 +7,10 @@ (onHide)="close()" >
- - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/partner/modules/accounts/components/form.component.ts b/src/app/domains/partner/modules/accounts/components/form.component.ts index 495d941..513fc0b 100644 --- a/src/app/domains/partner/modules/accounts/components/form.component.ts +++ b/src/app/domains/partner/modules/accounts/components/form.component.ts @@ -1,18 +1,17 @@ import { MustMatch, password } from '@/core/validators'; import { AbstractFormDialog } from '@/shared/abstractClasses'; +import { SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IAccountRequest, IAccountResponse } from '../models'; import { AccountsService } from '../services/main.service'; @Component({ selector: 'account-password-form', templateUrl: './form.component.html', - imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, UikitFieldComponent, Password], + imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, SharedPasswordInputComponent], }) export class PartnerAccountPasswordFormComponent extends AbstractFormDialog< IAccountRequest, diff --git a/src/app/domains/partner/modules/consumers/components/accounts/form.component.html b/src/app/domains/partner/modules/consumers/components/accounts/form.component.html index dffb39e..4c9c65b 100644 --- a/src/app/domains/partner/modules/consumers/components/accounts/form.component.html +++ b/src/app/domains/partner/modules/consumers/components/accounts/form.component.html @@ -9,34 +9,10 @@
- - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/partner/modules/consumers/components/accounts/form.component.ts b/src/app/domains/partner/modules/consumers/components/accounts/form.component.ts index 86e659c..8c5b4fe 100644 --- a/src/app/domains/partner/modules/consumers/components/accounts/form.component.ts +++ b/src/app/domains/partner/modules/consumers/components/accounts/form.component.ts @@ -2,13 +2,11 @@ import { MustMatch, password } from '@/core/validators'; // import { CatalogRolesComponent } from '@/shared/catalog/roles'; import { AbstractFormDialog } from '@/shared/abstractClasses'; import { EnumSelectComponent } from '@/shared/apiEnum/select.component'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IConsumerAccountRequest, IConsumerAccountResponse } from '../../models'; import { PartnerConsumerAccountsService } from '../../services/accounts.service'; @@ -20,8 +18,7 @@ import { PartnerConsumerAccountsService } from '../../services/accounts.service' Dialog, InputComponent, FormFooterActionsComponent, - UikitFieldComponent, - Password, + SharedPasswordInputComponent, EnumSelectComponent, ], }) diff --git a/src/app/domains/partner/modules/consumers/components/form.component.html b/src/app/domains/partner/modules/consumers/components/form.component.html index a5c261b..cddace7 100644 --- a/src/app/domains/partner/modules/consumers/components/form.component.html +++ b/src/app/domains/partner/modules/consumers/components/form.component.html @@ -16,34 +16,10 @@ اطلاعات ورود - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + اطلاعات لایسنس اطلاعات ورود - - - - - - - + } diff --git a/src/app/domains/partner/modules/consumers/components/poses/form.component.ts b/src/app/domains/partner/modules/consumers/components/poses/form.component.ts index 507958b..c8973f5 100644 --- a/src/app/domains/partner/modules/consumers/components/poses/form.component.ts +++ b/src/app/domains/partner/modules/consumers/components/poses/form.component.ts @@ -4,13 +4,11 @@ import { AbstractForm } 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 { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Divider } from 'primeng/divider'; -import { Password } from 'primeng/password'; import { IPosRequest, IPosResponse } from '../../models'; import { PartnerPosesService } from '../../services/poses.service'; @@ -24,9 +22,8 @@ import { PartnerPosesService } from '../../services/poses.service'; CatalogDeviceSelectComponent, CatalogProviderSelectComponent, EnumSelectComponent, - UikitFieldComponent, - Password, Divider, + SharedPasswordInputComponent, ], }) export class ConsumerPosFormContentComponent extends AbstractForm { diff --git a/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.html b/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.html index dffb39e..4c9c65b 100644 --- a/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.html +++ b/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.html @@ -9,34 +9,10 @@
- - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.ts b/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.ts index e3c9ce0..fc2ce5d 100644 --- a/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.ts +++ b/src/app/domains/superAdmin/modules/consumers/components/accounts/form.component.ts @@ -2,13 +2,11 @@ import { MustMatch, password } from '@/core/validators'; // import { CatalogRolesComponent } from '@/shared/catalog/roles'; import { AbstractFormDialog } from '@/shared/abstractClasses'; import { EnumSelectComponent } from '@/shared/apiEnum/select.component'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IConsumerAccountRequest, IConsumerAccountResponse } from '../../models'; import { AdminConsumerAccountsService } from '../../services/accounts.service'; @@ -20,8 +18,7 @@ import { AdminConsumerAccountsService } from '../../services/accounts.service'; Dialog, InputComponent, FormFooterActionsComponent, - UikitFieldComponent, - Password, + SharedPasswordInputComponent, EnumSelectComponent, ], }) diff --git a/src/app/domains/superAdmin/modules/consumers/components/form.component.html b/src/app/domains/superAdmin/modules/consumers/components/form.component.html index 4187dec..db9e098 100644 --- a/src/app/domains/superAdmin/modules/consumers/components/form.component.html +++ b/src/app/domains/superAdmin/modules/consumers/components/form.component.html @@ -14,34 +14,10 @@ اطلاعات ورود - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + اطلاعات لایسنس - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/superAdmin/modules/partners/components/accounts/form.component.ts b/src/app/domains/superAdmin/modules/partners/components/accounts/form.component.ts index 47f1ab5..a2cc6d2 100644 --- a/src/app/domains/superAdmin/modules/partners/components/accounts/form.component.ts +++ b/src/app/domains/superAdmin/modules/partners/components/accounts/form.component.ts @@ -2,13 +2,11 @@ import { MustMatch, password } from '@/core/validators'; // import { CatalogRolesComponent } from '@/shared/catalog/roles'; import { AbstractFormDialog } from '@/shared/abstractClasses'; import { EnumSelectComponent } from '@/shared/apiEnum/select.component'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IPartnerAccountRequest, IPartnerAccountResponse } from '../../models'; import { AdminPartnerAccountsService } from '../../services/accounts.service'; @@ -20,8 +18,7 @@ import { AdminPartnerAccountsService } from '../../services/accounts.service'; Dialog, InputComponent, FormFooterActionsComponent, - UikitFieldComponent, - Password, + SharedPasswordInputComponent, EnumSelectComponent, ], }) diff --git a/src/app/domains/superAdmin/modules/partners/components/form.component.html b/src/app/domains/superAdmin/modules/partners/components/form.component.html index 5ca97fd..0c18700 100644 --- a/src/app/domains/superAdmin/modules/partners/components/form.component.html +++ b/src/app/domains/superAdmin/modules/partners/components/form.component.html @@ -13,34 +13,10 @@ اطلاعات ورود - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + } diff --git a/src/app/domains/superAdmin/modules/partners/components/form.component.ts b/src/app/domains/superAdmin/modules/partners/components/form.component.ts index ea3bd2e..e168cc7 100644 --- a/src/app/domains/superAdmin/modules/partners/components/form.component.ts +++ b/src/app/domains/superAdmin/modules/partners/components/form.component.ts @@ -1,13 +1,11 @@ import { MustMatch } from '@/core/validators'; import { AbstractFormDialog } from '@/shared/abstractClasses'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, computed, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; import { Divider } from 'primeng/divider'; -import { Password } from 'primeng/password'; import { IPartnerRequest, IPartnerResponse } from '../models'; import { PartnersService } from '../services/main.service'; @@ -20,8 +18,7 @@ import { PartnersService } from '../services/main.service'; InputComponent, FormFooterActionsComponent, Divider, - UikitFieldComponent, - Password, + SharedPasswordInputComponent, ], }) export class GuildFormComponent extends AbstractFormDialog { diff --git a/src/app/domains/superAdmin/modules/providers/components/form.component.html b/src/app/domains/superAdmin/modules/providers/components/form.component.html index d8891d1..6963472 100644 --- a/src/app/domains/superAdmin/modules/providers/components/form.component.html +++ b/src/app/domains/superAdmin/modules/providers/components/form.component.html @@ -14,34 +14,10 @@ اطلاعات ورود - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + } diff --git a/src/app/domains/superAdmin/modules/providers/components/form.component.ts b/src/app/domains/superAdmin/modules/providers/components/form.component.ts index 1e72cbe..ea99c1b 100644 --- a/src/app/domains/superAdmin/modules/providers/components/form.component.ts +++ b/src/app/domains/superAdmin/modules/providers/components/form.component.ts @@ -1,13 +1,11 @@ import { MustMatch } from '@/core/validators'; import { AbstractFormDialog } from '@/shared/abstractClasses'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, computed, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; import { Divider } from 'primeng/divider'; -import { Password } from 'primeng/password'; import { IProviderRequest, IProviderResponse } from '../models'; import { ProvidersService } from '../services/main.service'; @@ -20,8 +18,7 @@ import { ProvidersService } from '../services/main.service'; InputComponent, FormFooterActionsComponent, Divider, - UikitFieldComponent, - Password, + SharedPasswordInputComponent, ], }) export class ProviderFormComponent extends AbstractFormDialog { diff --git a/src/app/domains/superAdmin/modules/users/components/accounts/form.component.html b/src/app/domains/superAdmin/modules/users/components/accounts/form.component.html index babb102..ba914bf 100644 --- a/src/app/domains/superAdmin/modules/users/components/accounts/form.component.html +++ b/src/app/domains/superAdmin/modules/users/components/accounts/form.component.html @@ -9,34 +9,10 @@
- - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + diff --git a/src/app/domains/superAdmin/modules/users/components/accounts/form.component.ts b/src/app/domains/superAdmin/modules/users/components/accounts/form.component.ts index 3e65475..6b2d1ac 100644 --- a/src/app/domains/superAdmin/modules/users/components/accounts/form.component.ts +++ b/src/app/domains/superAdmin/modules/users/components/accounts/form.component.ts @@ -2,13 +2,11 @@ import { MustMatch, password } from '@/core/validators'; // import { CatalogRolesComponent } from '@/shared/catalog/roles'; import { AbstractFormDialog } from '@/shared/abstractClasses'; import { EnumSelectComponent } from '@/shared/apiEnum/select.component'; -import { InputComponent } from '@/shared/components'; +import { InputComponent, SharedPasswordInputComponent } from '@/shared/components'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { UikitFieldComponent } from '@/uikit'; import { Component, inject, Input } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Dialog } from 'primeng/dialog'; -import { Password } from 'primeng/password'; import { IAccountRequest, IAccountResponse } from '../../models'; import { AdminUserAccountsService } from '../../services/accounts.service'; @@ -20,9 +18,8 @@ import { AdminUserAccountsService } from '../../services/accounts.service'; Dialog, InputComponent, FormFooterActionsComponent, - UikitFieldComponent, - Password, EnumSelectComponent, + SharedPasswordInputComponent, ], }) export class UserAccountFormComponent extends AbstractFormDialog< diff --git a/src/app/domains/superAdmin/modules/users/components/form.component.html b/src/app/domains/superAdmin/modules/users/components/form.component.html index de59214..3c42c1e 100644 --- a/src/app/domains/superAdmin/modules/users/components/form.component.html +++ b/src/app/domains/superAdmin/modules/users/components/form.component.html @@ -10,36 +10,7 @@ - - - diff --git a/src/app/modules/auth/pages/modifyLoginInfo/modify-login-info.component.html b/src/app/modules/auth/pages/modifyLoginInfo/modify-login-info.component.html index c5e79a0..fa6cb4c 100644 --- a/src/app/modules/auth/pages/modifyLoginInfo/modify-login-info.component.html +++ b/src/app/modules/auth/pages/modifyLoginInfo/modify-login-info.component.html @@ -11,37 +11,10 @@ [invalid]="infoForm.get('username')?.touched && infoForm.get('username')?.invalid" /> - - - - - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. - - - - - - + +
+ + + + + diff --git a/src/app/shared/components/changePasswordFormDialog/change-password-form-dialog.component.ts b/src/app/shared/components/changePasswordFormDialog/change-password-form-dialog.component.ts new file mode 100644 index 0000000..431d090 --- /dev/null +++ b/src/app/shared/components/changePasswordFormDialog/change-password-form-dialog.component.ts @@ -0,0 +1,54 @@ +import { MustMatch, password } from '@/core/validators'; +import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog'; +import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; +import { Component, EventEmitter, Output, input } from '@angular/core'; +import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; +import { Dialog } from 'primeng/dialog'; +import { SharedPasswordInputComponent } from '../passwordInput/password-input.component'; + +export interface IChangePasswordSubmitPayload { + password: string; + confirmPassword: string; +} + +@Component({ + selector: 'shared-change-password-form-dialog', + templateUrl: './change-password-form-dialog.component.html', + imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, SharedPasswordInputComponent], +}) +export class ChangePasswordFormDialogComponent extends AbstractDialog { + title = input(''); + loading = input(false); + + @Output() onSubmit = new EventEmitter(); + + private readonly fb = new FormBuilder(); + + form = this.fb.group( + { + password: ['', [Validators.required, password()]], + confirmPassword: ['', [Validators.required]], + }, + { + validators: [MustMatch('password', 'confirmPassword')], + }, + ); + + get dialogHeader() { + return this.title() ? `تغییر گذرواژه‌ی ${this.title()}` : 'تغییر گذرواژه'; + } + + submit() { + this.form.markAllAsTouched(); + if (this.form.invalid) { + return; + } + + this.onSubmit.emit(this.form.getRawValue() as IChangePasswordSubmitPayload); + } + + override close() { + this.form.reset(); + super.close(); + } +} diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts index e3870c1..74de5f4 100644 --- a/src/app/shared/components/index.ts +++ b/src/app/shared/components/index.ts @@ -1,8 +1,10 @@ // export * from './abstract-select.component'; export * from './breadcrumb.component'; export * from './card-data.component'; +export * from './changePasswordFormDialog/change-password-form-dialog.component'; export * from './inlineConfirmation/inline-confirmation.component'; export * from './inlineEdit/inline-edit.component'; export * from './input/input.component'; export * from './key-value.component/key-value.component'; +export * from './passwordInput/password-input.component'; export * from './table-action-row.component'; diff --git a/src/app/shared/components/passwordInput/password-input.component.html b/src/app/shared/components/passwordInput/password-input.component.html index 865b9a6..0fe40a0 100644 --- a/src/app/shared/components/passwordInput/password-input.component.html +++ b/src/app/shared/components/passwordInput/password-input.component.html @@ -1,28 +1,30 @@ - + - رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد. + {{ hint }} - + diff --git a/src/app/shared/components/passwordInput/password-input.component.ts b/src/app/shared/components/passwordInput/password-input.component.ts index b6967cb..1db804f 100644 --- a/src/app/shared/components/passwordInput/password-input.component.ts +++ b/src/app/shared/components/passwordInput/password-input.component.ts @@ -1,6 +1,6 @@ import { UikitFieldComponent } from '@/uikit'; import { Component, Input } from '@angular/core'; -import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; +import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { Password } from 'primeng/password'; @Component({ @@ -11,5 +11,8 @@ import { Password } from 'primeng/password'; export class SharedPasswordInputComponent { @Input({ required: true }) passwordControl = new FormControl(''); @Input({ required: true }) confirmPasswordControl = new FormControl(''); - @Input({ required: true }) formGroup!: FormGroup; + @Input() hint: string = + 'رمز باید حداقل ۸ کاراکتر بوده و شامل حداقل یک حرف بزرگ، یک حرف کوچک، یک عدد و یک کاراکتر ویژه باشد.'; + @Input() fluid: boolean = true; + @Input() size: 'small' | 'large' = 'small'; }