-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2120 from ever-co/feat/static-build-support-8
Feat/Next-Frontend APIs
- Loading branch information
Showing
12 changed files
with
195 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,86 @@ | ||
import { kanbanBoardState } from "@app/stores/kanban"; | ||
import { useTaskStatus } from "./useTaskStatus"; | ||
import { useRecoilState } from "recoil"; | ||
import { useEffect, useState } from "react"; | ||
import { ITaskStatusItemList, ITeamTask } from "@app/interfaces"; | ||
import { useTeamTasks } from "./useTeamTasks"; | ||
import { kanbanBoardState } from '@app/stores/kanban'; | ||
import { useTaskStatus } from './useTaskStatus'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useEffect, useState } from 'react'; | ||
import { ITaskStatusItemList, ITeamTask } from '@app/interfaces'; | ||
import { useTeamTasks } from './useTeamTasks'; | ||
|
||
export function useKanban() { | ||
const [loading, setLoading] = useState<boolean>(true); | ||
|
||
const [loading, setLoading] = useState<boolean>(true); | ||
|
||
const [kanbanBoard, setKanbanBoard] = useRecoilState(kanbanBoardState); | ||
const [kanbanBoard, setKanbanBoard] = useRecoilState(kanbanBoardState); | ||
|
||
const taskStatusHook = useTaskStatus(); | ||
const taskStatusHook = useTaskStatus(); | ||
|
||
const { tasks, tasksFetching, updateTask } = useTeamTasks(); | ||
const { tasks, tasksFetching, updateTask } = useTeamTasks(); | ||
|
||
/** | ||
* format data for kanban board | ||
*/ | ||
useEffect(()=> { | ||
if(!taskStatusHook.loading && !tasksFetching) { | ||
let kanban = {}; | ||
/** | ||
* format data for kanban board | ||
*/ | ||
useEffect(() => { | ||
if (!taskStatusHook.loading && !tasksFetching) { | ||
let kanban = {}; | ||
|
||
const getTasksByStatus = (status: string | undefined) => { | ||
return tasks.filter((task: ITeamTask)=> { | ||
return task.status === status | ||
}) | ||
} | ||
const getTasksByStatus = (status: string | undefined) => { | ||
return tasks.filter((task: ITeamTask) => { | ||
return task.status === status; | ||
}); | ||
}; | ||
|
||
taskStatusHook.taskStatus.map((taskStatus: ITaskStatusItemList,)=> { | ||
kanban = { | ||
...kanban, | ||
[taskStatus.name ? taskStatus.name : ''] : getTasksByStatus(taskStatus.name) | ||
} | ||
}); | ||
setKanbanBoard(kanban) | ||
setLoading(false) | ||
} | ||
},[taskStatusHook.loading, tasksFetching]) | ||
taskStatusHook.taskStatus.map((taskStatus: ITaskStatusItemList) => { | ||
kanban = { | ||
...kanban, | ||
[taskStatus.name ? taskStatus.name : '']: getTasksByStatus(taskStatus.name) | ||
}; | ||
}); | ||
setKanbanBoard(kanban); | ||
setLoading(false); | ||
} | ||
}, [taskStatusHook.loading, tasksFetching]); | ||
|
||
/** | ||
* collapse or show kanban column | ||
*/ | ||
const toggleColumn = (column: string, status: boolean) => { | ||
const columnData = taskStatusHook.taskStatus.filter((taskStatus: ITaskStatusItemList,)=> { | ||
return taskStatus.name === column | ||
}); | ||
/** | ||
* collapse or show kanban column | ||
*/ | ||
const toggleColumn = (column: string, status: boolean) => { | ||
const columnData = taskStatusHook.taskStatus.filter((taskStatus: ITaskStatusItemList) => { | ||
return taskStatus.name === column; | ||
}); | ||
|
||
const columnId = columnData[0].id; | ||
const columnId = columnData[0].id; | ||
|
||
taskStatusHook.editTaskStatus(columnId, { | ||
isCollapsed: status | ||
}); | ||
} | ||
}; | ||
|
||
const isColumnCollapse = (column: string) => { | ||
const columnData = taskStatusHook.taskStatus.filter((taskStatus: ITaskStatusItemList,)=> { | ||
return taskStatus.name === column | ||
}); | ||
const isColumnCollapse = (column: string) => { | ||
const columnData = taskStatusHook.taskStatus.filter((taskStatus: ITaskStatusItemList) => { | ||
return taskStatus.name === column; | ||
}); | ||
|
||
return columnData[0].isCollapsed | ||
} | ||
return columnData[0].isCollapsed; | ||
}; | ||
|
||
const reorderStatus = (itemStatus: string, index: number) => { | ||
taskStatusHook.taskStatus.filter((status: ITaskStatusItemList)=> { | ||
return status.name === itemStatus | ||
}).map((status: ITaskStatusItemList)=> { | ||
taskStatusHook.editTaskStatus(status.id, { | ||
order: index | ||
}); | ||
}) | ||
} | ||
const reorderStatus = (itemStatus: string, index: number) => { | ||
taskStatusHook.taskStatus | ||
.filter((status: ITaskStatusItemList) => { | ||
return status.name === itemStatus; | ||
}) | ||
.map((status: ITaskStatusItemList) => { | ||
taskStatusHook.editTaskStatus(status.id, { | ||
order: index | ||
}); | ||
}); | ||
}; | ||
|
||
return { | ||
data: kanbanBoard, | ||
isLoading: loading, | ||
columns: taskStatusHook.taskStatus, | ||
updateKanbanBoard: setKanbanBoard, | ||
updateTaskStatus: updateTask, | ||
toggleColumn, | ||
isColumnCollapse, | ||
reorderStatus | ||
} | ||
} | ||
return { | ||
data: kanbanBoard, | ||
isLoading: loading, | ||
columns: taskStatusHook.taskStatus, | ||
updateKanbanBoard: setKanbanBoard, | ||
updateTaskStatus: updateTask, | ||
toggleColumn, | ||
isColumnCollapse, | ||
reorderStatus | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { IUser } from '@app/interfaces'; | ||
import api from '../axios'; | ||
import { post, put } from '../axios'; | ||
|
||
export function savePersonalSettingsAPI(id: string, data: any) { | ||
return api.post<IUser>(`/user/${id}`, { ...data }); | ||
return post<IUser>(`/user/${id}`, { ...data }); | ||
} | ||
|
||
// update/delete profile avatar for user setting | ||
export function updateUserAvatarAPI(id: string, body: Partial<IUser>) { | ||
return api.put<IUser>(`/user/${id}`, body); | ||
return put<IUser>(`/user/${id}`, body); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.