Commit 2861ccc4 authored by RAHUL RATHORE's avatar RAHUL RATHORE
Browse files

fix: product & carrier translate fixes

parent 8b4904ff
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -11,9 +11,9 @@
	<form-wizard
		class="form-horizontal"
		[formGroup]="form"
		[doneText]="buttonDone"
		[nextText]="buttonNext"
		[previousText]="buttonPrevious"
		[doneText]="'BUTTON_DONE' | translate"
		[nextText]="'BUTTON_NEXT' | translate"
		[previousText]="'BUTTON_PREV' | translate"
	>
		<wizard-step
			[title]="'CARRIERS_VIEW.CREATE.BASIC_INFO' | translate"
+1 −29
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ import { BasicInfoFormComponent } from '../forms';
import { LocationFormComponent } from '../../forms/location';

import { getDummyImage } from '@modules/server.common/utils';
import { TranslateService } from '@ngx-translate/core';

@Component({
	selector: 'ea-carrier-mutation',
@@ -47,30 +46,13 @@ export class CarrierMutationComponent implements AfterViewInit {
		google.maps.places.PlaceGeometry | google.maps.GeocoderGeometry
	>();

	public BUTTON_DONE: string = 'BUTTON_DONE';
	public BUTTON_NEXT: string = 'BUTTON_NEXT';
	public BUTTON_PREV: string = 'BUTTON_PREV';

	constructor(
		private toasterService: ToasterService,
		private readonly activeModal: NgbActiveModal,
		private readonly formBuilder: FormBuilder,
		protected carrierRouter: CarrierRouter,
		private readonly _translateService: TranslateService
		protected carrierRouter: CarrierRouter
	) {}

	get buttonDone() {
		return this._translate(this.BUTTON_DONE);
	}

	get buttonNext() {
		return this._translate(this.BUTTON_NEXT);
	}

	get buttonPrevious() {
		return this._translate(this.BUTTON_PREV);
	}

	ngAfterViewInit(): void {
		if (this.locationForm) {
			this.locationForm.setDefaultCoords();
@@ -135,14 +117,4 @@ export class CarrierMutationComponent implements AfterViewInit {
	cancel() {
		this.activeModal.dismiss('canceled');
	}

	private _translate(key: string): string {
		let translationResult = '';

		this._translateService.get(key).subscribe((res) => {
			translationResult = res;
		});

		return translationResult;
	}
}
+3 −3
Original line number Diff line number Diff line
@@ -7,9 +7,9 @@
<div>
	<form-wizard
		[formGroup]="form"
		[doneText]="buttonDone"
		[nextText]="buttonNext"
		[previousText]="buttonPrevious"
		[doneText]="'BUTTON_DONE' | translate"
		[nextText]="'BUTTON_NEXT' | translate"
		[previousText]="'BUTTON_PREV' | translate"
		[nbSpinner]="loading"
		#formWizard
		class="form-horizontal"
+7 −32
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { BasicInfoFormComponent } from '../forms';
import { IProductCreateObject } from '@modules/server.common/interfaces/IProduct';
import { ProductsService } from '../../../@core/data/products.service';
import { firstValueFrom } from 'rxjs';
import { first } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';
import { NotifyService } from '@app/@core/services/notify/notify.service';
@@ -19,9 +20,6 @@ export class ProductCreateComponent implements OnInit {

	public loading: boolean;
	public productsCategories: any;
	public BUTTON_DONE: string = 'BUTTON_DONE';
	public BUTTON_NEXT: string = 'BUTTON_NEXT';
	public BUTTON_PREVIOUS: string = 'BUTTON_PREVIOUS';

	readonly form: FormGroup = this._formBuilder.group({
		basicInfo: BasicInfoFormComponent.buildForm(this._formBuilder),
@@ -41,31 +39,18 @@ export class ProductCreateComponent implements OnInit {
		this.basicInfoForm.productCategories = this.productsCategories;
	}

	get buttonDone() {
		return this._translate(this.BUTTON_DONE);
	}

	get buttonNext() {
		return this._translate(this.BUTTON_NEXT);
	}

	get buttonPrevious() {
		return this._translate(this.BUTTON_PREVIOUS);
	}

	async createProduct() {
		if (this.basicInfo.valid) {
			const productCreateObject: IProductCreateObject = await this.basicInfoForm.setupProductCreateObject();

			try {
				this.loading = true;
				await this._productsService
					.create(productCreateObject)
					.pipe(first())
					.toPromise();
				await firstValueFrom(
					this._productsService.create(productCreateObject).pipe(first())
				).finally(() => {
					this.loading = false;
				const message = `Product ${productCreateObject.title[0].value} is created`;
				})

				const message = `Product ${productCreateObject.title[0].value} is created`;
				this._notifyService.success(message);
				this.cancelModal();
			} catch (error) {
@@ -77,16 +62,6 @@ export class ProductCreateComponent implements OnInit {
		}
	}

	private _translate(key: string): string {
		let translationResult = '';

		this._translateService.get(key).subscribe((res) => {
			translationResult = res;
		});

		return translationResult;
	}

	public cancelModal() {
		this._activeModal.dismiss('canceled');
	}
+3 −5
Original line number Diff line number Diff line
import { NgModule } from '@angular/core';
import { ThemeModule } from '../../../@theme/theme.module';
import { TranslateModule } from '@ngx-translate/core';
import { FormWizardModule } from '@ever-co/angular2-wizard';
import { ProductCreateComponent } from './product-create.component';
import { ProductFormsModule } from '../forms';
import { NbSpinnerModule } from '@nebular/theme';
import { TranslateModule } from '@app/@shared/translate/translate.module';

@NgModule({
	imports: [
		ThemeModule,
		FormWizardModule,
		TranslateModule.forChild(),

		TranslateModule,
		ProductFormsModule,
		NbSpinnerModule,
	],
	exports: [ProductCreateComponent],
	declarations: [ProductCreateComponent],
	entryComponents: [ProductCreateComponent],
	declarations: [ProductCreateComponent]
})
export class ProductCreateModule {}
Loading