# Submit task

### Input parameters

* TaskID

### How to call from app

```
import { httpsCallable } from 'firebase/functions';

await httpsCallable(functions, 'submitTask')({ taskId })
```

### Logic

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

2. the API should copy the document with the TASK-ID from (tasks/drafts/all/TASK-ID) to (tasks/submitted/all/TASK-ID)

3. Now it should delete the draft document (tasks/drafts/all/TASK-ID)

4. Update the project document:
   * each task has one project. That document can be found under (projects/projectId)
   * the projectId can be found inside the Task document under "projectId"
   * Now change the databaseStatus of the task inside the project document.
   * See the image below. The Status should associate to the name of the db collection where the task currently is. So the new status should be "submitted"

5. Send email to us:

* to\_email\_adress = "<info@tasksource.io>"
* template\_name = "tasks-submitted->us"
* data = none

2. Send email to developers&#x20;
   * to\_email\_adress = \[ALL developers with one matching skills for task]
   * template\_name = "tasks-submitted->developer"
   * data = {taskData: taskData, taskId: taskId}\
     (used in template as: )

     ```html
     {{taskData.taskName}}
     ```
3. Lastly, it needs to send a response to the frontend that everything worked.

[![Bildschirmfoto 2022-11-08 um 09 39 51](https://user-images.githubusercontent.com/22271360/200452882-5b494f45-ea02-4ed5-848c-7aa848208ad9.png)](https://user-images.githubusercontent.com/22271360/200452882-5b494f45-ea02-4ed5-848c-7aa848208ad9.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tasksource.io/api-documentation/tasks/submit-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
