Skip to content

Commit

Permalink
refactor: type
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jun 14, 2023
1 parent 44c3f58 commit 81140a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions apps/frontend/src/components/task/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Icon } from '@iconify/vue'
import draggable from 'vuedraggable'
import TaskItem from './TaskItem.vue'
import {
TasksSelectorType,
useTaskLeftMenuStatusStore,
useTasksSelectorStore,
useTasksStore,
Expand Down Expand Up @@ -58,11 +59,11 @@ function handleInputChange(event: any) {
}
const shouldShowTodoAdd = computed(() => {
return tasksSelectorStore.currentSelector?.type === 'listProject'
return tasksSelectorStore.currentSelector?.type === TasksSelectorType.listProject
})
const shouldEnabledDrag = computed(() => {
return tasksSelectorStore.currentSelector?.type === 'listProject'
return tasksSelectorStore.currentSelector?.type === TasksSelectorType.listProject
},
)
Expand Down
7 changes: 4 additions & 3 deletions apps/frontend/src/store/__mocks__/listProjects.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { vi } from 'vitest'
import type { ListProject } from '../listProjects'
import { TasksSelectorType } from '../tasksSelector'

export const useListProjectsStore = vi.fn(() => {
return {
findProject() {
findProject(): ListProject {
return {
id: '1',
name: '集草器',
type: 'listProject',
} as ListProject
type: TasksSelectorType.listProject,
}
},
}
})
4 changes: 2 additions & 2 deletions apps/frontend/src/store/tasksSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const useTasksSelectorStore = defineStore('tasksSelectorStore', () => {
if (!currentSelector.value)
return

if (currentSelector.value.type === 'listProject')
if (currentSelector.value.type === TasksSelectorType.listProject)
tasksStore.updateTasks(await loadListProjectTasks(currentSelector.value.id))

else if (currentSelector.value.type === 'smartProject')
else if (currentSelector.value.type === TasksSelectorType.smartProject)
tasksStore.updateTasks(await loadSmartProjectTasks(currentSelector.value.name))
}

Expand Down

0 comments on commit 81140a9

Please sign in to comment.