Move delete and get by id tasks to generated client

pull/10616/head
Brandon Farmer 2018-11-20 13:57:25 -08:00
parent 4f8ae2ba5a
commit 90506ed51c
2 changed files with 13 additions and 26 deletions

View File

@ -196,16 +196,9 @@ export const updateTaskStatus = (task: Task) => async dispatch => {
}
}
export const deleteTask = (task: Task) => async (
dispatch,
getState: GetStateFunc
) => {
export const deleteTask = (task: Task) => async dispatch => {
try {
const {
links: {tasks: url},
} = getState()
await deleteTaskAPI(url, task.id)
await deleteTaskAPI(task.id)
dispatch(populateTasks())
} catch (e) {
@ -248,12 +241,9 @@ export const selectTaskByID = (id: string) => async (
getState: GetStateFunc
): Promise<void> => {
try {
const {
orgs,
links: {tasks: url},
} = getState()
const {orgs} = getState()
const task = await getTask(url, id)
const task = await getTask(id)
const org = orgs.find(org => org.id === task.organizationId)
return dispatch(setCurrentTask({...task, organization: org}))

View File

@ -1,5 +1,3 @@
import AJAX from 'src/utils/ajax'
import {Task, TasksApi} from 'src/api'
const getBasePath = () => {
@ -43,22 +41,21 @@ export const updateTaskStatus = async (
export const getUserTasks = async (user): Promise<Task[]> => {
const api = createTaskAPI()
const {data} = await api.tasksGet('', user.id)
const after = ''
const {data} = await api.tasksGet(after, user.id)
return data.tasks
}
export const getTask = async (url, id): Promise<Task> => {
const completeUrl = `${url}/${id}`
const {
data: {task},
} = await AJAX({url: completeUrl})
export const getTask = async (id): Promise<Task> => {
const api = createTaskAPI()
const {data} = await api.tasksTaskIDGet(id)
return task
return data
}
export const deleteTask = (url: string, taskID: string) => {
const completeUrl = `${url}/${taskID}`
export const deleteTask = (taskID: string) => {
const api = createTaskAPI()
return AJAX({url: completeUrl, method: 'DELETE'})
return api.tasksTaskIDDelete(taskID)
}