Skip to content
Prev Previous commit
Next Next commit
refactor: TTL-887 import constants from a shared file
  • Loading branch information
Santiago220991 committed May 31, 2023
commit b8f23e6c0034325cb759a076d7a87fac0763c5ae
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ import { DATE_FORMAT, DATE_FORMAT_YEAR } from 'src/environments/environment';
import { TechnologiesComponent } from '../technologies/technologies.component';
import { MatDatepicker } from '@angular/material/datepicker';
import { Observable } from 'rxjs';

const INTERNAL_APP_STRING = 'ioet';
const PROJECT_NAME_TO_SKIP = ['English Lessons', 'Safari Books'];
const EMPTY_FIELDS_ERROR_MESSAGE = 'Make sure to add a description and/or ticket number when working on an internal app.';
import { EMPTY_FIELDS_ERROR_MESSAGE } from '../../messages';
import { INTERNAL_APP_STRING, PROJECT_NAME_TO_SKIP } from 'src/app/modules/shared/internal-app-constants';

type Merged = TechnologyState & ProjectState & ActivityState & EntryState;
@Component({
Expand Down Expand Up @@ -122,8 +120,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});
}

onClearedComponent({term}) {
const isSearchEmpty = (term === '');
onClearedComponent({ term }) {
const isSearchEmpty = term === '';
if (isSearchEmpty) {
this.isTechnologiesDisabled = true;
this.entryForm.patchValue({
Expand Down Expand Up @@ -172,7 +170,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
projectWithSearchField.search_field = `${project.customer.name} - ${project.name}`;
this.listRecentProjects.push(projectWithSearchField);
});
}else{
} else {
this.listRecentProjects = this.listProjects;
}
this.listProjectsShowed = this.listRecentProjects;
Expand Down Expand Up @@ -335,7 +333,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
}

onSubmit() {

const emptyValue = '';
const { project_name, uri, description } = this.entryForm.value;
const areEmptyValues = [uri, description].every(item => item === emptyValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ import { formatDate } from '@angular/common';
import { getTimeEntriesDataSource } from '../../store/entry.selectors';
import { DATE_FORMAT } from 'src/environments/environment';
import { Subscription } from 'rxjs';


const INTERNAL_APP_STRING = 'ioet';
const PROJECT_NAME_TO_SKIP = ['English Lessons', 'Safari Books'];
const EMPTY_FIELDS_ERROR_MESSAGE = 'Make sure to add a description and/or ticket number when working on an internal app.';
import { EMPTY_FIELDS_ERROR_MESSAGE } from 'src/app/modules/shared/messages';
import { INTERNAL_APP_STRING, PROJECT_NAME_TO_SKIP } from 'src/app/modules/shared/internal-app-constants';

type Merged = TechnologyState & ProjectState & ActivityState;

Expand Down Expand Up @@ -144,7 +141,6 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
const dataToUse = ds.data.find((item) => item.project_id === this.activeEntry.project_id);
customerName = dataToUse.customer_name;
projectName = dataToUse.project_name;

});
return this.requiredFieldsForInternalAppExist(customerName, projectName) && this.entryForm.valid;
}
Expand Down Expand Up @@ -209,10 +205,14 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {

requiredFieldsForInternalAppExist(customerName, projectName) {
const emptyValue = '';
const areEmptyValues = [this.entryForm.value.uri, this.entryForm.value.description].every(item => item === emptyValue);

const isInternalApp = customerName.includes('ioet');
const canSkipDescriptionAndURI = PROJECT_NAME_TO_SKIP.some(projectNameItem => projectName.includes(projectNameItem));
const areEmptyValues = [this.entryForm.value.uri, this.entryForm.value.description].every(
(item) => item === emptyValue
);

const isInternalApp = customerName.includes(INTERNAL_APP_STRING);
const canSkipDescriptionAndURI = PROJECT_NAME_TO_SKIP.some((projectNameItem) =>
projectName.includes(projectNameItem)
);

if (isInternalApp && areEmptyValues && !canSkipDescriptionAndURI) {
this.toastrService.error(EMPTY_FIELDS_ERROR_MESSAGE);
Expand Down