diff --git a/src/app/domains/pos/modules/about/views/root.component.ts b/src/app/domains/pos/modules/about/views/root.component.ts index 7ea7bec..0469251 100644 --- a/src/app/domains/pos/modules/about/views/root.component.ts +++ b/src/app/domains/pos/modules/about/views/root.component.ts @@ -1,11 +1,9 @@ import { brandingConfig } from '@/branding/branding.config'; import { Component, computed, signal } from '@angular/core'; -import { ButtonDirective } from 'primeng/button'; @Component({ selector: 'pos-about-page', templateUrl: './root.component.html', - imports: [ButtonDirective], }) export class PosAboutPageComponent { // private readonly swUpdate = inject(SwUpdate); diff --git a/src/app/domains/pos/modules/configs/components/print/form.component.html b/src/app/domains/pos/modules/configs/components/print/form.component.html index fc7ddd9..59b2474 100644 --- a/src/app/domains/pos/modules/configs/components/print/form.component.html +++ b/src/app/domains/pos/modules/configs/components/print/form.component.html @@ -1,30 +1,32 @@ -
- - - - - - - - - - - - - - +@if (!loading()) { + + + + + + + + + + + + + + + - - + + +} diff --git a/src/app/domains/pos/modules/configs/components/print/form.component.ts b/src/app/domains/pos/modules/configs/components/print/form.component.ts index c9469dc..4e2e962 100644 --- a/src/app/domains/pos/modules/configs/components/print/form.component.ts +++ b/src/app/domains/pos/modules/configs/components/print/form.component.ts @@ -1,7 +1,7 @@ import { AbstractForm } from '@/shared/abstractClasses'; import { AppCheckboxComponent } from '@/shared/components/checkbox/checkbox.component'; import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component'; -import { Component, inject } from '@angular/core'; +import { Component, inject, signal } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { IPosConfigPrintRequestPayload, IPosConfigPrintResponse } from './models'; import { PosConfigPrintService } from './services/main.service'; @@ -17,6 +17,8 @@ export class PosConfigPrintFormComponent extends AbstractForm< > { private readonly service = inject(PosConfigPrintService); + loading = signal(true); + initForm = () => { const form = this.fb.group({ business_name: [true, []], @@ -40,8 +42,18 @@ export class PosConfigPrintFormComponent extends AbstractForm< form = this.initForm(); - submitForm() { + override async ngOnInit() { + this.loading.set(true); + const initialValues = await this.service.get(); + console.log('initialValues', initialValues); + + this.form.patchValue(initialValues); + this.loading.set(false); + } + + override submitForm() { const formValue = this.form.value as IPosConfigPrintRequestPayload; + this.toastService.success({ text: 'تغییرات با موفقیت اعمال شد.' }); return this.service.submit(formValue); } } diff --git a/src/app/shared/abstractClasses/abstract-form.ts b/src/app/shared/abstractClasses/abstract-form.ts index ff7007d..7468ea6 100644 --- a/src/app/shared/abstractClasses/abstract-form.ts +++ b/src/app/shared/abstractClasses/abstract-form.ts @@ -21,7 +21,7 @@ export abstract class AbstractForm< @Output() onClose = new EventEmitter(); protected readonly fb = inject(FormBuilder); - private readonly toastService = inject(ToastService); + protected readonly toastService = inject(ToastService); constructor() {} abstract form: ReturnType; diff --git a/src/app/shared/components/checkbox/checkbox.component.html b/src/app/shared/components/checkbox/checkbox.component.html index 17e9989..fccfd05 100644 --- a/src/app/shared/components/checkbox/checkbox.component.html +++ b/src/app/shared/components/checkbox/checkbox.component.html @@ -1,6 +1,14 @@
- + {{ label }}
diff --git a/src/app/shared/components/checkbox/checkbox.component.ts b/src/app/shared/components/checkbox/checkbox.component.ts index 3562985..1baa1a9 100644 --- a/src/app/shared/components/checkbox/checkbox.component.ts +++ b/src/app/shared/components/checkbox/checkbox.component.ts @@ -2,12 +2,11 @@ import { Maybe } from '@/core'; import { UikitLabelComponent } from '@/uikit'; import { Component, Input } from '@angular/core'; import { FormControl } from '@angular/forms'; -import { Checkbox } from 'primeng/checkbox'; @Component({ selector: 'app-checkbox', templateUrl: 'checkbox.component.html', - imports: [Checkbox, UikitLabelComponent], + imports: [UikitLabelComponent], }) export class AppCheckboxComponent { @Input({ required: true }) control!: FormControl>; @@ -17,4 +16,14 @@ export class AppCheckboxComponent { @Input() size?: 'small' | 'large'; @Input() showErrors = true; @Input() hint?: string; + + get checked() { + return this.control.value === 'true' || this.control.value === true; + } + + onChange(checked: boolean) { + this.control.setValue(checked ? 'true' : 'false'); + this.control.markAsDirty(); + this.control.markAsTouched(); + } } diff --git a/src/app/shared/components/invoices/sale-invoice-full-response.model.ts b/src/app/shared/components/invoices/sale-invoice-full-response.model.ts index a6be113..691595e 100644 --- a/src/app/shared/components/invoices/sale-invoice-full-response.model.ts +++ b/src/app/shared/components/invoices/sale-invoice-full-response.model.ts @@ -22,7 +22,73 @@ export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {} interface Item { id: string; - good: ISummary; + good_id: string; + service_id: null; + quantity: string; + measure_unit_code: string; + measure_unit_text: string; + sku_code: string; + unit_price: string; + discount: string; + total_amount: string; + notes?: string; + payload: Payload; + good_snapshot: Goodsnapshot; + good: GoodSummary; +} +interface GoodSummary { + name: string; + barcode?: string; + image_url?: string; + category: Category; +} + +interface Category { + id: string; + name: string; + description?: string; + image_url?: string; + is_default_guild_good: boolean; + guild_id: string; + created_at: string; + updated_at: string; +} + +interface Goodsnapshot { + good: Good; +} + +interface Good { + id: string; + sku: Sku; + name: string; + barcode?: string; + category: ISummary; + image_url: string; + local_sku?: string; + measure_unit: MeasureUnit; + pricing_model: string; + base_sale_price: string; +} + +interface MeasureUnit { + id: string; + code: string; + name: string; +} + +interface Sku { + id: string; + VAT: string; + code: string; + name: string; +} + +interface Payload { + karat: string; + wages: number; + profit: number; + commission: number; } interface Payment { diff --git a/src/app/shared/components/invoices/sale-invoice-single-view.component.html b/src/app/shared/components/invoices/sale-invoice-single-view.component.html index e833fe9..0af213e 100644 --- a/src/app/shared/components/invoices/sale-invoice-single-view.component.html +++ b/src/app/shared/components/invoices/sale-invoice-single-view.component.html @@ -9,7 +9,7 @@