update pos consumer

This commit is contained in:
2026-03-29 18:07:10 +03:30
parent 1e2f94261e
commit c10623bc3f
86 changed files with 2935 additions and 385 deletions
@@ -0,0 +1,16 @@
<p-dialog [(visible)]="visible" header="اطلاعات مشتری" [modal]="true" [style]="{ width: '560px' }">
<div class="card p-2! flex justify-center">
<p-selectbutton [options]="customerTypes" [(ngModel)]="selectedCustomerType" optionValue="value">
<ng-template #item let-item>
<span class="text-sm">{{ item.label }}</span>
</ng-template>
</p-selectbutton>
</div>
@if (selectedCustomerType() === "UNKNOWN") {
<pos-customer-unknown-form (onSubmit)="onSubmitCustomer()" (onClose)="close()" />
} @else if (selectedCustomerType() === "INDIVIDUAL") {
<pos-customer-individual-form (onSubmit)="onSubmitCustomer()" (onClose)="close()" />
} @else if (selectedCustomerType() === "LEGAL") {
<pos-customer-legal-form (onSubmit)="onSubmitCustomer()" (onClose)="close()" />
}
</p-dialog>
@@ -0,0 +1,53 @@
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { Component, EventEmitter, inject, Output, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { Dialog } from 'primeng/dialog';
import { SelectButton } from 'primeng/selectbutton';
import { PosLandingStore } from '../../store/main.store';
import { CustomerIndividualFormComponent } from './individual/form.component';
import { CustomerLegalFormComponent } from './legal/form.component';
import { CustomerUnknownFormComponent } from './unknown/form.component';
@Component({
selector: 'pos-order-customer-dialog',
templateUrl: './customer-dialog.component.html',
imports: [
Dialog,
CustomerIndividualFormComponent,
FormsModule,
CustomerLegalFormComponent,
SelectButton,
CustomerUnknownFormComponent,
],
})
export class PosOrderCustomerDialogComponent extends AbstractDialog {
@Output() onSubmit = new EventEmitter<any>();
private readonly store = inject(PosLandingStore);
customerTypes = [
{
label: 'بدون اطلاعات خریدار (نوع دوم)',
value: 'UNKNOWN',
},
{
label: 'خریدار حقیقی (نوع اول)',
value: 'INDIVIDUAL',
},
{
label: 'خریدار حقوقی (نوع اول)',
value: 'LEGAL',
},
] as {
label: string;
value: CustomerType;
}[];
selectedCustomerType = signal<CustomerType>(this.store.customer().type);
onSubmitCustomer() {
this.close();
this.onSubmit.emit();
}
}
@@ -0,0 +1,14 @@
<form [formGroup]="form" (submit)="submit()">
<app-input [control]="form.controls.first_name" name="first_name" label="نام" />
<app-input [control]="form.controls.last_name" name="last_name" label="نام خانوادگی" />
<app-input [control]="form.controls.national_id" name="national_id" label="کد ملی" type="nationalId" />
<app-input
[control]="form.controls.economic_code"
name="economic_code"
label="کد اقتصادی"
type="number"
maxlength="11"
/>
<app-form-footer-actions submitLabel="ثبت مشتری و ادامه" (onCancel)="close()" (onSubmit)="submit()" />
</form>
@@ -0,0 +1,61 @@
import { postalCodeValidator } from '@/core/validators';
import { nationalIdValidator } from '@/core/validators/national-id.validator';
import { AbstractForm } from '@/shared/abstractClasses';
import { InputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { IIndividualCustomer } from '../../../models/customer';
import { PosLandingStore } from '../../../store/main.store';
@Component({
selector: 'pos-customer-individual-form',
templateUrl: './form.component.html',
imports: [ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
})
export class CustomerIndividualFormComponent extends AbstractForm<
IIndividualCustomer,
IIndividualCustomer
> {
private readonly store = inject(PosLandingStore);
override showSuccessMessage = false;
form = this.fb.group({
first_name: [
this.store.customer().info?.customerIndividuals?.first_name || '',
[Validators.required],
],
last_name: [
this.store.customer().info?.customerIndividuals?.last_name || '',
[Validators.required],
],
national_id: [
this.store.customer().info?.customerIndividuals?.national_id || '',
[Validators.required, nationalIdValidator()],
],
economic_code: [
this.store.customer().info?.customerIndividuals?.economic_code || '',
[Validators.required],
],
postal_code: [
this.store.customer().info?.customerIndividuals?.postal_code || '',
[postalCodeValidator()],
],
});
override submitForm() {
return new Observable<IIndividualCustomer>((observer) => {
const info = this.form.value as IIndividualCustomer;
this.store.setCustomer({
customer_id: '',
type: CustomerType.INDIVIDUAL,
info: {
customerIndividuals: info,
},
});
return observer.next(info);
});
}
}
@@ -0,0 +1,14 @@
<form [formGroup]="form" (submit)="submit()">
<app-input [control]="form.controls.company_name" name="company_name" label="نام مجموعه" />
<app-input [control]="form.controls.registration_number" name="registration_number" label="شماره ثبت" />
<app-input
[control]="form.controls.economic_code"
name="economic_code"
label="کد اقتصادی"
type="number"
maxlength="11"
/>
<app-input [control]="form.controls.postal_code" name="postal_code" label="کد پستی" type="postalCode" />
<app-form-footer-actions submitLabel="ثبت مشتری و ادامه" (onCancel)="close()" (onSubmit)="submit()" />
</form>
@@ -0,0 +1,54 @@
import { postalCodeValidator } from '@/core/validators';
import { AbstractForm } from '@/shared/abstractClasses';
import { InputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { ILegalCustomer } from '../../../models/customer';
import { PosLandingStore } from '../../../store/main.store';
@Component({
selector: 'pos-customer-legal-form',
templateUrl: './form.component.html',
imports: [ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
})
export class CustomerLegalFormComponent extends AbstractForm<ILegalCustomer, ILegalCustomer> {
private readonly store = inject(PosLandingStore);
override showSuccessMessage = false;
form = this.fb.group({
company_name: [
this.store.customer().info?.customerLegals?.company_name || '',
[Validators.required],
],
registration_number: [
this.store.customer().info?.customerLegals?.registration_number || '',
[Validators.required],
],
economic_code: [
this.store.customer().info?.customerLegals?.economic_code || '',
[Validators.required],
],
postal_code: [
this.store.customer().info?.customerLegals?.postal_code || '',
[postalCodeValidator()],
],
});
override submitForm() {
return new Observable<ILegalCustomer>((observer) => {
const info = this.form.value as ILegalCustomer;
this.store.setCustomer({
customer_id: '',
type: CustomerType.LEGAL,
info: {
customerLegals: info,
},
});
return observer.next(info);
});
}
}
@@ -0,0 +1,5 @@
<form [formGroup]="form" (submit)="submit()">
<app-input [control]="form.controls.national_id" name="national_id" label="شماره ملی" type="nationalId" />
<app-input [control]="form.controls.name" name="name" label="نام" />
<app-form-footer-actions submitLabel="ثبت بدون اطلاعات خریدار و ادامه" (onCancel)="close()" />
</form>
@@ -0,0 +1,42 @@
import { nationalIdValidator } from '@/core/validators/national-id.validator';
import { AbstractForm } from '@/shared/abstractClasses';
import { InputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { CustomerType } from '@/shared/localEnum/constants/customerTypes';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { Observable } from 'rxjs';
import { IUnknownCustomer } from '../../../models/customer';
import { PosLandingStore } from '../../../store/main.store';
@Component({
selector: 'pos-customer-unknown-form',
templateUrl: './form.component.html',
imports: [ReactiveFormsModule, InputComponent, FormFooterActionsComponent],
})
export class CustomerUnknownFormComponent extends AbstractForm<IUnknownCustomer, IUnknownCustomer> {
private readonly store = inject(PosLandingStore);
override showSuccessMessage = false;
form = this.fb.group({
national_id: [
this.store?.customer().info?.customerUnknown?.national_id || '',
[nationalIdValidator()],
],
name: [this.store?.customer().info?.customerUnknown?.name || ''],
});
override submitForm() {
return new Observable<IUnknownCustomer>((observer) => {
const info = this.form.value as IUnknownCustomer;
this.store.setCustomer({
customer_id: '',
type: CustomerType.UNKNOWN,
info: {
customerUnknown: info,
},
});
return observer.next(info);
});
}
}