From bfc369794e72ec5dd9c81bf81a533dc303240308 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Wed, 14 Jan 2026 19:41:07 +0100 Subject: [PATCH] remove redundant projects pinia store after tanstack query migration --- resources/js/utils/useProjects.ts | 44 +++---------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/resources/js/utils/useProjects.ts b/resources/js/utils/useProjects.ts index 62d415cf..180addb8 100644 --- a/resources/js/utils/useProjects.ts +++ b/resources/js/utils/useProjects.ts @@ -1,43 +1,14 @@ import { defineStore } from 'pinia'; import { api } from '@/packages/api/src'; -import { computed, ref } from 'vue'; -import type { - CreateProjectBody, - Project, - ProjectResponse, - UpdateProjectBody, -} from '@/packages/api/src'; +import type { CreateProjectBody, UpdateProjectBody } from '@/packages/api/src'; import { getCurrentOrganizationId } from '@/utils/useUser'; import { useNotificationsStore } from '@/utils/notification'; import { useQueryClient } from '@tanstack/vue-query'; export const useProjectsStore = defineStore('projects', () => { - const projectResponse = ref(null); const { handleApiRequestNotifications } = useNotificationsStore(); const queryClient = useQueryClient(); - function invalidateProjectsQuery() { - queryClient.invalidateQueries({ queryKey: ['projects'] }); - } - async function fetchProjects() { - const organization = getCurrentOrganizationId(); - if (organization) { - projectResponse.value = await handleApiRequestNotifications( - () => - api.getProjects({ - params: { - organization: organization, - }, - queries: { - archived: 'all', - }, - }), - undefined, - 'Failed to fetch projects' - ); - } - } - async function createProject(projectBody: CreateProjectBody) { const organization = getCurrentOrganizationId(); @@ -53,8 +24,7 @@ export const useProjectsStore = defineStore('projects', () => { 'Failed to create project' ); - await fetchProjects(); - invalidateProjectsQuery(); + queryClient.invalidateQueries({ queryKey: ['projects'] }); return response['data']; } } @@ -73,8 +43,7 @@ export const useProjectsStore = defineStore('projects', () => { 'Project deleted successfully', 'Failed to delete project' ); - await fetchProjects(); - invalidateProjectsQuery(); + queryClient.invalidateQueries({ queryKey: ['projects'] }); } } @@ -92,16 +61,11 @@ export const useProjectsStore = defineStore('projects', () => { 'Project updated successfully', 'Failed to update project' ); - await fetchProjects(); - invalidateProjectsQuery(); + queryClient.invalidateQueries({ queryKey: ['projects'] }); } } - const projects = computed(() => projectResponse.value?.data || []); - return { - projects, - fetchProjects, createProject, deleteProject, updateProject,