Commit 9d00e81b authored by Ermolaev Timur's avatar Ermolaev Timur

#17 Реализовал задачи в фикстуре

parent 402aad11
......@@ -40,7 +40,45 @@ Data Source has been initialized!
await user.save();
users.push(user)
}
const tasks = []
type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C";
const priorities:priorityType[] = ["A", "B" , "C"]
const accomplish:taskFinishType[] = ["opened", "done" , "failed"]
for (let i = 0; i < 15; i++) {
if (i <= 10) {
const newTask = new Task();
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));
newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15));
newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8)));
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = faker.helpers.arrayElement(accomplish);
newTask.priority = faker.helpers.arrayElement(priorities);
await newTask.save();
tasks.push(newTask)
} else {
const newTask = new Task();
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));
newTask.dateTimeDue = null;
newTask.dateTimeStart = null;
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = accomplish[0];
newTask.priority = faker.helpers.arrayElement(priorities);
await newTask.save();
tasks.push(newTask)
}
}
console.log(`
==========================
Fixtures done!
==========================
`)
})
......
......@@ -14,6 +14,7 @@ const tasksReduсer = (state = initialState, action) => {
const newArr = []
action.tasks.forEach((task)=>{
if (task.dateTimeStart && task.dateTimeDue) {
if (new Date(task.dateTimeDue).getTime() - new Date(task.dateTimeStart).getTime() < (4 * 3600000)) {
const dateStart = task.dateTimeStart.split('T')[0]
const timeStart = task.dateTimeStart.split('T')[1]
const timeEnd = task.dateTimeDue.split('T')[1]
......@@ -35,6 +36,7 @@ const tasksReduсer = (state = initialState, action) => {
}
} )
}
}
})
return {...state, loading: false, tasks: newArr};
case FETCH_TASKS_FAILURE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment