Commit 66985194 authored by RAHUL RATHORE's avatar RAHUL RATHORE
Browse files

fix: replaced underscore with lodash

parent 7fd971e4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
import { Injectable } from '@angular/core';
import { IProductCreateObject } from '@modules/server.common/interfaces/IProduct';
import * as faker from 'faker';
import * as _ from 'lodash';
import { random } from 'underscore';
import { IProductsCategory } from '@modules/server.common/interfaces/IProductsCategory';
import { images } from '@modules/server.common/data/image-urls';
import { productNames } from '@modules/server.common/data/food-product-names';
@@ -415,7 +415,7 @@ export default class FakeDataProducts {

	private async _getImage() {
		try {
			const url = images.food[_.random(0, images.food.length - 1)];
			const url = images.food[random(0, images.food.length - 1)];

			const img: HTMLImageElement = await this._getImageMeta(url);

@@ -450,6 +450,6 @@ export default class FakeDataProducts {
	}

	private _getRandomProductName(): string {
		return productNames[_.random(0, productNames.length - 1)];
		return productNames[random(0, productNames.length - 1)];
	}
}
+7 −7
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import { IWarehouseRegistrationInput } from '@modules/server.common/routers/IWar
import { getFakeImg } from '@modules/server.common/utils';
import { environment } from 'environments/environment';
import * as faker from 'faker';
import * as _ from 'lodash';
import { random } from 'underscore';
// import { _appIdRandomProviderFactory } from '@angular/core/src/application_tokens';

const NEED_DEFAULT_SETTINGS_MESSAGE =
@@ -244,11 +244,11 @@ export default class FakeDataWarehouses {
		const currentYear = now.getFullYear();
		const startYear = currentYear - yearsRange;

		const storeYear = _.random(startYear, currentYear);
		const storeMonth = _.random(11);
		const storeDate = _.random(31);
		const storeHours = _.random(23);
		const storeMinutes = _.random(59);
		const storeYear = random(startYear, currentYear);
		const storeMonth = random(11);
		const storeDate = random(31);
		const storeHours = random(23);
		const storeMinutes = random(59);

		const storeCreatedAt = new Date(
			storeYear,
@@ -260,7 +260,7 @@ export default class FakeDataWarehouses {

		if (storeCreatedAt > now) {
			const diff = storeCreatedAt.getTime() - now.getTime();
			storeCreatedAt.setTime(now.getTime() - _.random(diff));
			storeCreatedAt.setTime(now.getTime() - random(diff));
		}

		return storeCreatedAt;
+2 −2
Original line number Diff line number Diff line
import { Injectable } from '@angular/core';
import { IWarehouseProductCreateObject } from '@modules/server.common/interfaces/IWarehouseProduct';
import * as faker from 'faker';
import * as _ from 'lodash';
import { random } from 'underscore';

enum IsDeliveryTakeawayStatus {
	Takeaway = 0,
@@ -55,7 +55,7 @@ export default class FakeDataWarehousesProducts {

				return {
					product: id,
					initialPrice: price + _.random(20),
					initialPrice: price + random(20),
					price,
					isCarrierRequired: true,
					isManufacturing: true,
+3 −3
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ import {
	Validators,
} from '@angular/forms';
import { ICarrierCreateObject } from '@modules/server.common/interfaces/ICarrier';
import * as _ from 'lodash';
import { isEmpty, pick } from 'underscore';
import { FormHelpers } from '../../../forms/helpers';
import * as isUrl from 'is-url';
import { TranslateService } from '@ngx-translate/core';
@@ -119,7 +119,7 @@ export class BasicInfoFormComponent implements OnInit, AfterViewInit {
					(control: AbstractControl) => {
						const imageUrl = control.value;

						if (!isUrl(imageUrl) && !_.isEmpty(imageUrl)) {
						if (!isUrl(imageUrl) && !isEmpty(imageUrl)) {
							return { invalidImageUrl: true };
						}

@@ -149,7 +149,7 @@ export class BasicInfoFormComponent implements OnInit, AfterViewInit {
	setValue<T extends CarrierBasicInfo>(basicInfo: T) {
		FormHelpers.deepMark(this.form, 'dirty');

		this.form.setValue(_.pick(basicInfo, Object.keys(this.getValue())));
		this.form.setValue(pick(basicInfo, Object.keys(this.getValue())));
	}

	getPassword(): string {
+3 −3
Original line number Diff line number Diff line
import { FormArray, FormGroup } from '@angular/forms';
import { capitalize } from 'lodash';
import * as _ from 'underscore.string';

export class FormHelpers {
	/**
@@ -15,11 +15,11 @@ export class FormHelpers {
		markAs: 'touched' | 'untouched' | 'dirty' | 'pristine' | 'pending',
		opts = { onlySelf: false }
	): void {
		Object.values(formGroup.controls).map((c) => {
		Object.values(formGroup.controls).forEach((c) => {
			if (c instanceof FormGroup || c instanceof FormArray) {
				FormHelpers.deepMark(c, markAs, opts);
			} else {
				c[`markAs${capitalize(markAs)}`](opts);
				c[`markAs${_.capitalize(markAs)}`](opts);
			}
		});
	}
Loading