forked from Yadro/time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectFactory.ts
More file actions
27 lines (25 loc) · 765 Bytes
/
ProjectFactory.ts
File metadata and controls
27 lines (25 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import AbstractFactory from '../../base/AbstractFactory';
import ProjectModel, {
DEFAULT_PROJECT_ID,
DEFAULT_PROJECTS,
IJsonProjectItem,
} from './models/ProjectModel';
import { Features } from '../../config';
export default class ProjectFactory extends AbstractFactory {
createProjects(projectItems: IJsonProjectItem[]): ProjectModel[] {
if (Features.myDay) {
const hasMyDay = projectItems.find(
(p) => p.key === DEFAULT_PROJECT_ID.MyDay
);
if (!hasMyDay) {
const myDayProj = DEFAULT_PROJECTS.find(
(p) => p.key === DEFAULT_PROJECT_ID.MyDay
);
if (myDayProj) {
projectItems.unshift(myDayProj);
}
}
}
return this.createList(ProjectModel, projectItems);
}
}