Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

858 B
Raw Blame
import { watch, type Ref } from 'vue'
import { useCollaborationStore } from '@/stores/collaboration.store'
import { useGoalListsStore } from '@/stores/goal-lists.store'
import { useKanbanStore } from '@/stores/kanban.store'
import { useTagsStore } from '@/stores/tag.store'

export function useProjectDataLoader(projectId: Ref<number>) {
  const collaborationStore = useCollaborationStore()
  const goalListsStore = useGoalListsStore()
  const kanbanStore = useKanbanStore()
  const tagsStore = useTagsStore()

  tagsStore.fetchAllTags()
  collaborationStore.fetchAllCollaborationUsers()

  watch(projectId, (id) => {
    if (id > 0) {
      Promise.all([
        kanbanStore.fetchStatuses(id),
        collaborationStore.fetchCollaborationUsersForGoal(id).catch(() => null),
        goalListsStore.fetchLists(id),
      ])
    }
  }, { immediate: true })
}