Skip to content

Commit b8f23e6

Browse files
refactor: TTL-887 import constants from a shared file
1 parent ae5b22f commit b8f23e6

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ import { DATE_FORMAT, DATE_FORMAT_YEAR } from 'src/environments/environment';
2727
import { TechnologiesComponent } from '../technologies/technologies.component';
2828
import { MatDatepicker } from '@angular/material/datepicker';
2929
import { Observable } from 'rxjs';
30-
31-
const INTERNAL_APP_STRING = 'ioet';
32-
const PROJECT_NAME_TO_SKIP = ['English Lessons', 'Safari Books'];
33-
const EMPTY_FIELDS_ERROR_MESSAGE = 'Make sure to add a description and/or ticket number when working on an internal app.';
30+
import { EMPTY_FIELDS_ERROR_MESSAGE } from '../../messages';
31+
import { INTERNAL_APP_STRING, PROJECT_NAME_TO_SKIP } from 'src/app/modules/shared/internal-app-constants';
3432

3533
type Merged = TechnologyState & ProjectState & ActivityState & EntryState;
3634
@Component({
@@ -122,8 +120,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
122120
});
123121
}
124122

125-
onClearedComponent({term}) {
126-
const isSearchEmpty = (term === '');
123+
onClearedComponent({ term }) {
124+
const isSearchEmpty = term === '';
127125
if (isSearchEmpty) {
128126
this.isTechnologiesDisabled = true;
129127
this.entryForm.patchValue({
@@ -172,7 +170,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
172170
projectWithSearchField.search_field = `${project.customer.name} - ${project.name}`;
173171
this.listRecentProjects.push(projectWithSearchField);
174172
});
175-
}else{
173+
} else {
176174
this.listRecentProjects = this.listProjects;
177175
}
178176
this.listProjectsShowed = this.listRecentProjects;
@@ -335,7 +333,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
335333
}
336334

337335
onSubmit() {
338-
339336
const emptyValue = '';
340337
const { project_name, uri, description } = this.entryForm.value;
341338
const areEmptyValues = [uri, description].every(item => item === emptyValue);

src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import { formatDate } from '@angular/common';
1616
import { getTimeEntriesDataSource } from '../../store/entry.selectors';
1717
import { DATE_FORMAT } from 'src/environments/environment';
1818
import { Subscription } from 'rxjs';
19-
20-
21-
const INTERNAL_APP_STRING = 'ioet';
22-
const PROJECT_NAME_TO_SKIP = ['English Lessons', 'Safari Books'];
23-
const EMPTY_FIELDS_ERROR_MESSAGE = 'Make sure to add a description and/or ticket number when working on an internal app.';
19+
import { EMPTY_FIELDS_ERROR_MESSAGE } from 'src/app/modules/shared/messages';
20+
import { INTERNAL_APP_STRING, PROJECT_NAME_TO_SKIP } from 'src/app/modules/shared/internal-app-constants';
2421

2522
type Merged = TechnologyState & ProjectState & ActivityState;
2623

@@ -144,7 +141,6 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
144141
const dataToUse = ds.data.find((item) => item.project_id === this.activeEntry.project_id);
145142
customerName = dataToUse.customer_name;
146143
projectName = dataToUse.project_name;
147-
148144
});
149145
return this.requiredFieldsForInternalAppExist(customerName, projectName) && this.entryForm.valid;
150146
}
@@ -209,10 +205,14 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
209205

210206
requiredFieldsForInternalAppExist(customerName, projectName) {
211207
const emptyValue = '';
212-
const areEmptyValues = [this.entryForm.value.uri, this.entryForm.value.description].every(item => item === emptyValue);
213-
214-
const isInternalApp = customerName.includes('ioet');
215-
const canSkipDescriptionAndURI = PROJECT_NAME_TO_SKIP.some(projectNameItem => projectName.includes(projectNameItem));
208+
const areEmptyValues = [this.entryForm.value.uri, this.entryForm.value.description].every(
209+
(item) => item === emptyValue
210+
);
211+
212+
const isInternalApp = customerName.includes(INTERNAL_APP_STRING);
213+
const canSkipDescriptionAndURI = PROJECT_NAME_TO_SKIP.some((projectNameItem) =>
214+
projectName.includes(projectNameItem)
215+
);
216216

217217
if (isInternalApp && areEmptyValues && !canSkipDescriptionAndURI) {
218218
this.toastrService.error(EMPTY_FIELDS_ERROR_MESSAGE);

0 commit comments

Comments
 (0)