Skip to content

Commit

Permalink
Merge pull request #253 from Black-Dot-2024/fix/RF25-crear-tarea
Browse files Browse the repository at this point in the history
fix(tasks): do not create task if error
  • Loading branch information
dembA7 authored Jun 6, 2024
2 parents 38c3b3a + de07057 commit e4dd867
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/app/services/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ async function createTask(newTask: BareboneTask): Promise<Task | null> {
throw new Error('Worked hours must be lower than or equal to 1000');
}

const createdTask = await TaskRepository.createTask(task);
if (!createdTask) {
throw new Error('Task already exists');
}

if (newTask.endDate && project.endDate && !dateSmallerOrEqualThanOther(newTask.endDate, project.endDate))
throw new Error("Task's end date cannot be after the project's end date");

Expand All @@ -135,6 +130,11 @@ async function createTask(newTask: BareboneTask): Promise<Task | null> {
if (newTask.startDate && project.endDate && !dateSmallerOrEqualThanOther(newTask.startDate, project.endDate))
throw new Error("Task's start date cannot be after the project's end date");

const createdTask = await TaskRepository.createTask(task);
if (!createdTask) {
throw new Error('Task already exists');
}

if (newTask.idEmployee) {
const employee = await EmployeeRepository.findById(newTask.idEmployee);
if (!employee) {
Expand Down

0 comments on commit e4dd867

Please sign in to comment.