Move delete and get by id tasks to generated client
parent
4f8ae2ba5a
commit
90506ed51c
|
@ -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}))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue