# Reject task

### Input parameters

* ```
  taskId
  ```
* ```
  rejectionReason
  ```

### How to call from app

HTTP request to: /reject-task/TASKID

<pre><code>import { httpsCallable } from 'firebase/functions';

<strong>await httpsCallable(functions, 'rejectTask')({ 
</strong>    taskId: task.id,
    rejectionReason: currentTask.rejectionReason,
})
</code></pre>

### Logic

1. The frontend (app.tasksource.io) calls the API (/reject-task/TASK-ID)

2. ~~<mark style="color:green;">get developer document in DB (users/uid)</mark>~~&#x20;
   1. ~~<mark style="color:green;">remove the</mark> <mark style="color:green;"></mark><mark style="color:green;">**ProjectId**</mark> <mark style="color:green;"></mark><mark style="color:green;">to the</mark> <mark style="color:green;"></mark><mark style="color:green;">**thirdPartyProjects**</mark> <mark style="color:green;"></mark><mark style="color:green;">array</mark>~~
   2. ~~<mark style="color:green;">Then remove  the</mark> <mark style="color:green;"></mark><mark style="color:green;">**taskId**</mark> <mark style="color:green;"></mark><mark style="color:green;">to the</mark> <mark style="color:green;"></mark><mark style="color:green;">**assignedTasks**</mark> <mark style="color:green;"></mark><mark style="color:green;">array</mark>~~

3. Remove developer from project members (projects/{projectId}/members) array if no other task with same projectId found

4. the backend should now set a field in the task document (acceptedByDeveloper = false) as well as , rejectionReason: rejectionReason

5. Send First Email:

   * to\_email\_adress = email\_of\_assigned\_person
   * template\_name = "tasks-rejected-by-developer->developer"
   * data = {taskData: taskData, taskId: taskId, rejectionReason: rejectionReason}

6. Send Second Email:
   * to\_email\_adress = email\_of\_task\_creator
   * template\_name = "tasks-rejected-by-developer->creator"
   * data = {taskData: taskData, taskId: taskId, rejectionReason: rejectionReason}

5\. If task was assogned to pool (assignToPool = true) call api endpoint submit task&#x20;

6\. if assignToPool = false set task to draft status again.&#x20;
