feat: add new form field components for company details and consumer management
- Implemented CompanyNameComponent, DescriptionComponent, DeviceIdComponent, EconomicCodeComponent, EmailComponent, FirstNameComponent, FiscalCodeComponent, GuildIdComponent, LastNameComponent, LegalNameComponent, LicenseStartsAtComponent, MobileComponent, MobileNumberComponent, ModelComponent, NameComponent, NationalCodeComponent, NationalIdComponent, PartnerTokenComponent, PosTypeComponent, PostalCodeComponent, ProviderIdComponent, QuantityComponent, RegistrationCodeComponent, RegistrationNumberComponent, SerialNumberComponent, SetOffComponent, SkuComponent, TerminalComponent, UnitPriceComponent, UsernameComponent. - Added field control configurations for new fields in the form. - Updated routing and branding configurations for TIS tenant. - Created consumer type models for handling individual and legal consumer data.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { NativeBridgeService } from '@/core/services';
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
||||
import {
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
import { PriceMaskDirective } from '@/shared/directives';
|
||||
import { UikitEmptyStateComponent } from '@/uikit';
|
||||
import { getGoodUnitTypeProperties } from '@/utils';
|
||||
import { Component, EventEmitter, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Component, EventEmitter, inject, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Badge } from 'primeng/badge';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
@@ -34,6 +35,8 @@ export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
||||
],
|
||||
})
|
||||
export class ConsumerSaleInvoiceSharedComponent {
|
||||
private readonly nativeBridge = inject(NativeBridgeService);
|
||||
|
||||
@Input({ required: true }) loading!: boolean;
|
||||
@Input() invoice?: Maybe<ISaleInvoiceFullResponse>;
|
||||
@Input() variant: TConsumerSaleInvoice = 'full';
|
||||
@@ -43,6 +46,14 @@ export class ConsumerSaleInvoiceSharedComponent {
|
||||
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
||||
|
||||
printInvoice = () => {
|
||||
if (this.nativeBridge.isEnabled()) {
|
||||
const result = this.nativeBridge.print({
|
||||
invoiceId: this.invoice?.id,
|
||||
code: this.invoice?.code,
|
||||
});
|
||||
if (result.success) return;
|
||||
}
|
||||
|
||||
window.print();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
header="اطلاعات لایسنس"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -22,4 +22,4 @@
|
||||
<app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرمافزار'" />
|
||||
</div>
|
||||
} -->
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||
import { KeyValueComponent } from '@/shared/components';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { Message } from 'primeng/message';
|
||||
import { ConsumerStore } from '../store/main.store';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-license-info-dialog',
|
||||
templateUrl: './license-info-dialog.component.html',
|
||||
imports: [Dialog, KeyValueComponent, Message],
|
||||
imports: [SharedDialogComponent],
|
||||
})
|
||||
export class ConsumerLicenseInfoDialogComponent extends AbstractDialog {
|
||||
private readonly store = inject(ConsumerStore);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
header="ویرایش گذرواژه"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -14,4 +14,4 @@
|
||||
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -4,14 +4,14 @@ import { SharedPasswordInputComponent } 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 { IAccountRequest, IAccountResponse } from '../models';
|
||||
import { AccountsService } from '../services/main.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'account-password-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, SharedPasswordInputComponent],
|
||||
imports: [ReactiveFormsModule, SharedDialogComponent, FormFooterActionsComponent, SharedPasswordInputComponent],
|
||||
})
|
||||
export class ConsumerAccountPasswordFormComponent extends AbstractFormDialog<
|
||||
IAccountRequest,
|
||||
|
||||
@@ -54,7 +54,7 @@ export class ConsumerAccountPermissionListComponent {
|
||||
submit() {
|
||||
const dataToSet: IPermissionRequest = {};
|
||||
const posPermissions = this.permissions()
|
||||
?.poses.filter((pos) => pos.hasAccess)
|
||||
?.poses?.filter((pos) => pos.hasAccess)
|
||||
.map((pos) => pos.id);
|
||||
const complexPermissions = this.permissions()
|
||||
?.complexes?.filter((complex) => complex.hasAccess)
|
||||
|
||||
+11
-2
@@ -3,12 +3,15 @@ export interface IAccountRawResponse {
|
||||
role: string;
|
||||
created_at: string;
|
||||
account: Account;
|
||||
pos: PosComplex;
|
||||
pos: PosSummary;
|
||||
}
|
||||
export interface IAccountResponse extends IAccountRawResponse {}
|
||||
|
||||
export interface IAccountRequest {
|
||||
name: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
role?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface IAccountPasswordRequest {
|
||||
@@ -20,6 +23,12 @@ interface Account {
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface PosSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
complex: PosComplex;
|
||||
}
|
||||
|
||||
interface PosComplex {
|
||||
name: string;
|
||||
branch_code: string;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import ISummary from '@/core/models/summary';
|
||||
|
||||
export interface IPermissionRawResponse {
|
||||
poses: IPosPermissionResponse[];
|
||||
complexes: IComplexPermissionResponse[];
|
||||
business_activities: ICommonPermissionResponse[];
|
||||
poses?: IPosPermissionResponse[];
|
||||
complexes?: IComplexPermissionResponse[];
|
||||
business_activities?: ICommonPermissionResponse[];
|
||||
// Backend currently returns this key in camelCase for non-operator roles.
|
||||
businessActivities?: ICommonPermissionResponse[];
|
||||
}
|
||||
export interface IPermissionResponse extends IPermissionRawResponse {}
|
||||
|
||||
@@ -17,6 +19,7 @@ interface ICommonPermissionResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
hasAccess: boolean;
|
||||
role?: string | null;
|
||||
}
|
||||
|
||||
interface IComplexPermissionResponse extends ICommonPermissionResponse {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { CONSUMER_PERMISSIONS_API_ROUTES } from '../constants';
|
||||
import { IPermissionRawResponse, IPermissionRequest, IPermissionResponse } from '../models';
|
||||
@@ -11,7 +12,13 @@ export class PermissionsService {
|
||||
private apiRoutes = CONSUMER_PERMISSIONS_API_ROUTES;
|
||||
|
||||
getAll(accountId: string): Observable<IPermissionResponse> {
|
||||
return this.http.get<IPermissionRawResponse>(this.apiRoutes.list(accountId));
|
||||
return this.http.get<IPermissionRawResponse>(this.apiRoutes.list(accountId)).pipe(
|
||||
map((res) => ({
|
||||
poses: res.poses ?? [],
|
||||
complexes: res.complexes ?? [],
|
||||
business_activities: res.business_activities ?? res.businessActivities ?? [],
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
update(accountId: string, data: IPermissionRequest): Observable<IPermissionResponse> {
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
/>
|
||||
|
||||
@if (selectedItemForEdit()) {
|
||||
<account-password-form
|
||||
<shared-change-password-form-dialog
|
||||
[(visible)]="visibleForm"
|
||||
[editMode]="editMode()"
|
||||
[accountId]="selectedItemForEdit()?.id!"
|
||||
[initialValues]="selectedItemForEdit() || undefined"
|
||||
(onSubmit)="refresh()"
|
||||
[title]="selectedItemForEdit()?.account?.username || ''"
|
||||
[loading]="passwordSubmitLoading()"
|
||||
(onSubmit)="updatePassword($event)"
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
||||
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
|
||||
import {
|
||||
ChangePasswordFormDialogComponent,
|
||||
IChangePasswordSubmitPayload,
|
||||
} from '@/shared/components';
|
||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConsumerAccountPasswordFormComponent } from '../components/form.component';
|
||||
import { finalize } from 'rxjs';
|
||||
import { consumerAccountsNamedRoutes } from '../constants';
|
||||
import { IAccountResponse } from '../models';
|
||||
import { AccountsService } from '../services/main.service';
|
||||
@@ -11,11 +15,12 @@ import { AccountsService } from '../services/main.service';
|
||||
@Component({
|
||||
selector: 'consumer-accounts',
|
||||
templateUrl: './list.component.html',
|
||||
imports: [PageDataListComponent, ConsumerAccountPasswordFormComponent],
|
||||
imports: [PageDataListComponent, ChangePasswordFormDialogComponent],
|
||||
})
|
||||
export class ConsumerAccountsComponent extends AbstractList<IAccountResponse> {
|
||||
private readonly service = inject(AccountsService);
|
||||
private readonly router = inject(Router);
|
||||
passwordSubmitLoading = signal(false);
|
||||
|
||||
override setColumns(): void {
|
||||
this.columns = [
|
||||
@@ -48,4 +53,17 @@ export class ConsumerAccountsComponent extends AbstractList<IAccountResponse> {
|
||||
toSinglePage(account: IAccountResponse) {
|
||||
this.router.navigateByUrl(consumerAccountsNamedRoutes.account.meta.pagePath!(account.id));
|
||||
}
|
||||
|
||||
updatePassword(payload: IChangePasswordSubmitPayload) {
|
||||
if (!this.selectedItemForEdit()?.id) return;
|
||||
|
||||
this.passwordSubmitLoading.set(true);
|
||||
this.service
|
||||
.update(this.selectedItemForEdit()!.id, { password: payload.password })
|
||||
.pipe(finalize(() => this.passwordSubmitLoading.set(false)))
|
||||
.subscribe(() => {
|
||||
this.visibleForm.set(false);
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,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 { ConsumerAccountPermissionListComponent } from '../components/permissions/list.component';
|
||||
import { AccountStore } from '../store/account.store';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-account',
|
||||
templateUrl: './single.component.html',
|
||||
imports: [AppCardComponent, KeyValueComponent, ConsumerAccountPermissionListComponent],
|
||||
imports: [AppCardComponent, KeyValueComponent],
|
||||
})
|
||||
export class ConsumerAccountComponent {
|
||||
private readonly store = inject(AccountStore);
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
[header]="preparedTitle"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -7,9 +7,9 @@
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="کد شعبه" [control]="form.controls.branch_code" name="branch_code" />
|
||||
<app-input label="آدرس" [control]="form.controls.address" name="address" />
|
||||
<field-name [control]="form.controls.name" />
|
||||
<field-branch-code [control]="form.controls.branch_code" />
|
||||
<field-address [control]="form.controls.address" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
+19
-7
@@ -1,17 +1,29 @@
|
||||
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import {
|
||||
NameComponent,
|
||||
AddressComponent,
|
||||
BranchCodeComponent,
|
||||
} from '@/shared/components';
|
||||
import { fieldControl } from '@/shared/constants/fields';
|
||||
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 { ReactiveFormsModule } from '@angular/forms';
|
||||
import { IComplexRequest, IComplexResponse } from '../../models';
|
||||
import { ConsumerComplexesService } from '../../services/complexes.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-complex-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
SharedDialogComponent,
|
||||
NameComponent,
|
||||
BranchCodeComponent,
|
||||
AddressComponent,
|
||||
FormFooterActionsComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
||||
IComplexRequest,
|
||||
@@ -24,9 +36,9 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
||||
|
||||
initForm = () => {
|
||||
return this.fb.group({
|
||||
name: [this.initialValues?.name || '', [Validators.required]],
|
||||
branch_code: [this.initialValues?.branch_code || ''],
|
||||
address: [this.initialValues?.address || '', [Validators.required]],
|
||||
name: fieldControl.name(this.initialValues?.name || ''),
|
||||
branch_code: fieldControl.branch_code(this.initialValues?.branch_code || ''),
|
||||
address: fieldControl.address(this.initialValues?.address || ''),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
header="ویرایش فعالیت اقتصادی"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -7,7 +7,10 @@
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input [control]="form.controls.name" name="name" label="عنوان" />
|
||||
<field-name [control]="form.controls.name" />
|
||||
<field-economic-code [control]="form.controls.economic_code" />
|
||||
<field-fiscal-code [control]="form.controls.fiscal_code" />
|
||||
<field-partner-token [control]="form.controls.partner_token" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -1,16 +1,30 @@
|
||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||
import { InputComponent } from '@/shared/components';
|
||||
import {
|
||||
EconomicCodeComponent,
|
||||
FiscalCodeComponent,
|
||||
NameComponent,
|
||||
PartnerTokenComponent,
|
||||
} from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { fieldControl } from '@/shared/constants/fields';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { IBusinessActivityRequest, IBusinessActivityResponse } from '../models';
|
||||
import { BusinessActivitiesService } from '../services/main.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-businessActivity-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, Dialog, FormFooterActionsComponent, InputComponent],
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
SharedDialogComponent,
|
||||
FormFooterActionsComponent,
|
||||
NameComponent,
|
||||
EconomicCodeComponent,
|
||||
FiscalCodeComponent,
|
||||
PartnerTokenComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
||||
IBusinessActivityRequest,
|
||||
@@ -20,7 +34,10 @@ export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
||||
private service = inject(BusinessActivitiesService);
|
||||
|
||||
form = this.fb.group({
|
||||
name: [this.initialValues?.name, [Validators.required]],
|
||||
name: fieldControl.name(this.initialValues?.name || ''),
|
||||
economic_code: fieldControl.economic_code(this.initialValues?.economic_code || ''),
|
||||
fiscal_code: fieldControl.fiscal_code(this.initialValues?.fiscal_code || ''),
|
||||
partner_token: fieldControl.partner_token(this.initialValues?.partner_token || ''),
|
||||
});
|
||||
|
||||
override submitForm(payload: IBusinessActivityRequest) {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
<p-dialog [header]="preparedTitle" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
|
||||
<shared-dialog [header]="preparedTitle" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
|
||||
<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.sku" name="sku" />
|
||||
@@ -14,4 +14,4 @@
|
||||
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
+2
-2
@@ -3,7 +3,6 @@ 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 { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||
import { CatalogGuildGoodCategoriesSelectComponent } from '@/shared/catalog/guildGoodCategories';
|
||||
@@ -12,13 +11,14 @@ import {
|
||||
IConsumerBusinessActivityGoodResponse,
|
||||
} from '../../models/goods_io';
|
||||
import { BusinessActivityGoodsService } from '../../services/goods.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-businessActivity-good-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Dialog,
|
||||
SharedDialogComponent,
|
||||
InputComponent,
|
||||
FormFooterActionsComponent,
|
||||
EnumSelectComponent,
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
[header]="preparedTitle"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -7,19 +7,19 @@
|
||||
(onHide)="close()"
|
||||
>
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<field-name [control]="form.controls.name" />
|
||||
|
||||
<app-enum-select [control]="form.controls.pos_type" type="posType" name="pos_type" />
|
||||
<field-pos-type [control]="form.controls.pos_type" />
|
||||
|
||||
@if (form.controls.pos_type.value === "PSP") {
|
||||
<app-input label="سریال دستگاه" [control]="form.controls.serial_number" name="serial_number" />
|
||||
<catalog-device-select [control]="form.controls.device_id" />
|
||||
<catalog-provider-select [control]="form.controls.provider_id" />
|
||||
<field-serial-number [control]="form.controls.serial_number" />
|
||||
<field-device-id [control]="form.controls.device_id" />
|
||||
<field-provider-id [control]="form.controls.provider_id" />
|
||||
}
|
||||
|
||||
@if (!editMode) {
|
||||
<p-divider align="center"> اطلاعات ورود </p-divider>
|
||||
<app-input label="نام کاربری" [control]="form.controls.username" name="username" [isLtrInput]="true" />
|
||||
<field-username [control]="form.controls.username" />
|
||||
<shared-password-input
|
||||
[passwordControl]="form.controls.password"
|
||||
[confirmPasswordControl]="form.controls.confirmPassword"
|
||||
@@ -28,4 +28,4 @@
|
||||
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
+27
-16
@@ -1,29 +1,37 @@
|
||||
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||
import { MustMatch } from '@/core/validators';
|
||||
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, SharedPasswordInputComponent } from '@/shared/components';
|
||||
import {
|
||||
NameComponent,
|
||||
SharedPasswordInputComponent,
|
||||
DeviceIdComponent,
|
||||
ProviderIdComponent,
|
||||
SerialNumberComponent,
|
||||
PosTypeComponent,
|
||||
UsernameComponent,
|
||||
} from '@/shared/components';
|
||||
import { fieldControl } from '@/shared/constants/fields';
|
||||
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 { Divider } from 'primeng/divider';
|
||||
import { IPosRequest, IPosResponse } from '../../models';
|
||||
import { ConsumerPosesService } from '../../services/poses.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-pos-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Dialog,
|
||||
InputComponent,
|
||||
SharedDialogComponent,
|
||||
NameComponent,
|
||||
FormFooterActionsComponent,
|
||||
CatalogDeviceSelectComponent,
|
||||
CatalogProviderSelectComponent,
|
||||
EnumSelectComponent,
|
||||
DeviceIdComponent,
|
||||
ProviderIdComponent,
|
||||
PosTypeComponent,
|
||||
SerialNumberComponent,
|
||||
UsernameComponent,
|
||||
Divider,
|
||||
SharedPasswordInputComponent,
|
||||
],
|
||||
@@ -37,11 +45,11 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
|
||||
|
||||
initForm = () => {
|
||||
const form = this.fb.group({
|
||||
name: [this.initialValues?.name || '', [Validators.required]],
|
||||
pos_type: [this.initialValues?.pos_type || '', [Validators.required]],
|
||||
serial_number: [this.initialValues?.serial_number || ''],
|
||||
device_id: [this.initialValues?.device?.id || ''],
|
||||
provider_id: [this.initialValues?.provider?.id || ''],
|
||||
name: fieldControl.name(this.initialValues?.name || ''),
|
||||
pos_type: fieldControl.pos_type(this.initialValues?.pos_type || ''),
|
||||
serial_number: fieldControl.serial_number(this.initialValues?.serial_number || ''),
|
||||
device_id: fieldControl.device_id(this.initialValues?.device?.id || ''),
|
||||
provider_id: fieldControl.provider_id(this.initialValues?.provider?.id || ''),
|
||||
username: [''],
|
||||
password: [''],
|
||||
confirmPassword: [''],
|
||||
@@ -82,13 +90,15 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
|
||||
form.removeControl('confirmPassword');
|
||||
form.removeValidators([MustMatch('password', 'confirmPassword')]);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
form.addControl(
|
||||
'username',
|
||||
this.fb.control<string>('', {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
validators: fieldControl.username('')[1],
|
||||
}),
|
||||
);
|
||||
// @ts-ignore
|
||||
form.addControl(
|
||||
'password',
|
||||
this.fb.control<string>('', {
|
||||
@@ -96,6 +106,7 @@ export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IP
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
);
|
||||
// @ts-ignore
|
||||
form.addControl(
|
||||
'confirmPassword',
|
||||
this.fb.control<string>('', {
|
||||
|
||||
@@ -4,6 +4,8 @@ export interface IBusinessActivityRawResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
economic_code: string;
|
||||
fiscal_code: string;
|
||||
partner_token: string;
|
||||
guild: ISummary;
|
||||
created_at: string;
|
||||
license_info: LicenseInfo;
|
||||
@@ -12,6 +14,8 @@ export interface IBusinessActivityResponse extends IBusinessActivityRawResponse
|
||||
|
||||
export interface IBusinessActivityRequest {
|
||||
economic_code: string;
|
||||
fiscal_code: string;
|
||||
partner_token: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
header="ویرایش اطلاعات مشتری"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -21,4 +21,4 @@
|
||||
(onClose)="close()"
|
||||
/>
|
||||
}
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { ICustomerResponse } from '../models';
|
||||
import { ConsumerCustomerIndividualFormComponent } from './form-individual.component';
|
||||
import { ConsumerCustomerLegalFormComponent } from './form-legal.component';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-customer-form-dialog',
|
||||
@@ -14,7 +14,7 @@ import { ConsumerCustomerLegalFormComponent } from './form-legal.component';
|
||||
ConsumerCustomerIndividualFormComponent,
|
||||
ConsumerCustomerLegalFormComponent,
|
||||
ReactiveFormsModule,
|
||||
Dialog,
|
||||
SharedDialogComponent,
|
||||
],
|
||||
})
|
||||
export class ConsumerBusinessActivityFormComponent extends AbstractDialog {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<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.national_code" name="national_code" label="کد ملی" type="nationalId" />
|
||||
<app-input [control]="form.controls.economic_code" name="economic_code" label="کد اقتصادی" maxlength="11" />
|
||||
<app-input [control]="form.controls.postal_code" name="postal_code" label="کد پستی" type="postalCode" />
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export class ConsumerCustomerIndividualFormComponent extends AbstractForm<
|
||||
return this.fb.group({
|
||||
first_name: [this.initialValues?.individual?.first_name || '', [Validators.required]],
|
||||
last_name: [this.initialValues?.individual?.last_name || '', [Validators.required]],
|
||||
national_id: [
|
||||
national_code: [
|
||||
this.initialValues?.individual?.national_id || '',
|
||||
[Validators.required, nationalIdValidator()],
|
||||
],
|
||||
|
||||
+13
-4
@@ -12,12 +12,21 @@ export interface ICustomerResponse extends ICustomerRawResponse {}
|
||||
|
||||
export interface ICustomerRequest {}
|
||||
|
||||
export interface ICustomerIndividualRequest extends CustomerIndividual {
|
||||
is_favorite: boolean;
|
||||
export interface ICustomerIndividualRequest {
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
national_code?: string;
|
||||
postal_code?: string;
|
||||
economic_code?: string;
|
||||
is_favorite?: boolean;
|
||||
}
|
||||
|
||||
export interface ICustomerLegalRequest extends CustomerLegal {
|
||||
is_favorite: boolean;
|
||||
export interface ICustomerLegalRequest {
|
||||
company_name?: string;
|
||||
registration_number?: string;
|
||||
postal_code?: string;
|
||||
economic_code?: string;
|
||||
is_favorite?: boolean;
|
||||
}
|
||||
|
||||
interface CustomerLegal {
|
||||
|
||||
@@ -3,11 +3,11 @@ import ISummary from '@/core/models/summary';
|
||||
export interface IStatisticsSaleInvoicesRawResponse {
|
||||
id: string;
|
||||
code: string;
|
||||
created_date: string;
|
||||
created_at: string;
|
||||
created_date?: string;
|
||||
total_amount: string;
|
||||
pos: Pos;
|
||||
consumer_account: ConsumerAccount;
|
||||
created_at: string;
|
||||
}
|
||||
export interface IStatisticsSaleInvoicesResponse extends IStatisticsSaleInvoicesRawResponse {}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p-dialog
|
||||
<shared-dialog
|
||||
[header]="preparedTitle"
|
||||
[(visible)]="visible"
|
||||
[modal]="true"
|
||||
@@ -10,4 +10,4 @@
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
</shared-dialog>
|
||||
|
||||
@@ -5,14 +5,14 @@ import { InputComponent } from '@/shared/components';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
import { IPosRequest, IPosResponse } from '../models';
|
||||
import { ConsumerPosesService } from '../services/main.service';
|
||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'consumer-pos-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||
imports: [ReactiveFormsModule, SharedDialogComponent, InputComponent, FormFooterActionsComponent],
|
||||
})
|
||||
export class ConsumerPosFormComponent extends AbstractFormDialog<IPosRequest, IPosResponse> {
|
||||
private readonly service = inject(ConsumerPosesService);
|
||||
|
||||
@@ -7,9 +7,13 @@ export interface IPosRawResponse {
|
||||
model?: string;
|
||||
status: string;
|
||||
pos_type: string;
|
||||
created_at?: string;
|
||||
complex: ISummary;
|
||||
device?: ISummary;
|
||||
provider?: ISummary;
|
||||
account?: {
|
||||
username: string;
|
||||
};
|
||||
}
|
||||
export interface IPosResponse extends IPosRawResponse {}
|
||||
|
||||
|
||||
@@ -33,6 +33,6 @@ interface Complex extends ISummary {
|
||||
|
||||
interface Payments {
|
||||
amount: string;
|
||||
paid_at: string;
|
||||
paid_at?: string;
|
||||
payment_method: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user