mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 19:52:15 +01:00
upgrade inertia v2; add prefetching; migrate queries to tanstack query
vue
This commit is contained in:
@@ -16,10 +16,12 @@ import { TimeEntryCalendar } from '@/packages/ui/src';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { useTimeEntriesStore } from '@/utils/useTimeEntries';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { getUserTimezone } from '@/packages/ui/src/utils/settings';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import { canCreateProjects } from '@/utils/permissions';
|
||||
@@ -98,14 +100,10 @@ async function createClient(body: CreateClientBody): Promise<Client | undefined>
|
||||
return await useClientsStore().createClient(body);
|
||||
}
|
||||
|
||||
const projectStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectStore);
|
||||
const taskStore = useTasksStore();
|
||||
const { tasks } = storeToRefs(taskStore);
|
||||
const clientStore = useClientsStore();
|
||||
const { clients } = storeToRefs(clientStore);
|
||||
const tagsStore = useTagsStore();
|
||||
const { tags } = storeToRefs(tagsStore);
|
||||
const { projects } = useProjectsQuery();
|
||||
const { tasks } = useTasksQuery();
|
||||
const { clients } = useClientsQuery();
|
||||
const { tags } = useTagsQuery();
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
@@ -4,26 +4,21 @@ import AppLayout from '@/Layouts/AppLayout.vue';
|
||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import { UserCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import ClientTable from '@/Components/Common/Client/ClientTable.vue';
|
||||
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
||||
import PageTitle from '@/Components/Common/PageTitle.vue';
|
||||
import { canCreateClients } from '@/utils/permissions';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
onMounted(() => {
|
||||
useClientsStore().fetchClients();
|
||||
});
|
||||
const { clients } = useClientsQuery();
|
||||
|
||||
const activeTab = ref<'active' | 'archived'>('active');
|
||||
|
||||
const createClient = ref(false);
|
||||
|
||||
const { clients } = storeToRefs(useClientsStore());
|
||||
|
||||
const shownClients = computed(() => {
|
||||
return clients.value.filter((client) => {
|
||||
if (activeTab.value === 'active') {
|
||||
|
||||
@@ -3,9 +3,8 @@ import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
||||
import AppLayout from '@/Layouts/AppLayout.vue';
|
||||
import { FolderIcon, PlusIcon } from '@heroicons/vue/16/solid';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import { computed, onMounted, ref, inject, type ComputedRef } from 'vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, ref, inject, type ComputedRef } from 'vue';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import {
|
||||
ChevronRightIcon,
|
||||
CheckCircleIcon,
|
||||
@@ -20,18 +19,18 @@ import CardTitle from '@/packages/ui/src/CardTitle.vue';
|
||||
import Card from '@/Components/Common/Card.vue';
|
||||
import ProjectMemberTable from '@/Components/Common/ProjectMember/ProjectMemberTable.vue';
|
||||
import ProjectMemberCreateModal from '@/Components/Common/ProjectMember/ProjectMemberCreateModal.vue';
|
||||
import { useProjectMembersStore } from '@/utils/useProjectMembers';
|
||||
import { useProjectMembersQuery } from '@/utils/useProjectMembersQuery';
|
||||
import { canCreateProjects, canCreateTasks, canViewProjectMembers } from '@/utils/permissions';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import ProjectEditModal from '@/Components/Common/Project/ProjectEditModal.vue';
|
||||
import { Badge } from '@/packages/ui/src';
|
||||
import { formatCents } from '../packages/ui/src/utils/money';
|
||||
import { getOrganizationCurrencyString } from '../utils/money';
|
||||
import type { Organization } from '@/packages/api/src';
|
||||
|
||||
const { projects } = storeToRefs(useProjectsStore());
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
|
||||
@@ -42,20 +41,16 @@ const createTask = ref(false);
|
||||
const createProjectMember = ref(false);
|
||||
const projectId = route()?.params?.project as string;
|
||||
|
||||
const { projectMembers } = storeToRefs(useProjectMembersStore());
|
||||
|
||||
onMounted(() => {
|
||||
if (canViewProjectMembers()) {
|
||||
useProjectMembersStore().fetchProjectMembers(projectId);
|
||||
}
|
||||
useTasksStore().fetchTasks();
|
||||
});
|
||||
// TanStack Query automatically fetches project members when component mounts
|
||||
const { projectMembers } = canViewProjectMembers()
|
||||
? useProjectMembersQuery(projectId)
|
||||
: { projectMembers: computed(() => []) };
|
||||
|
||||
const showEditProjectModal = ref(false);
|
||||
|
||||
const activeTab = ref<'active' | 'done'>('active');
|
||||
|
||||
const { tasks } = storeToRefs(useTasksStore());
|
||||
const { tasks } = useTasksQuery();
|
||||
|
||||
const shownTasks = computed(() => {
|
||||
return tasks.value.filter((task) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
||||
import AppLayout from '@/Layouts/AppLayout.vue';
|
||||
import { FolderIcon, PlusIcon } from '@heroicons/vue/16/solid';
|
||||
import { FolderIcon, PlusIcon } from '@heroicons/vue/24/outline';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import ProjectTable from '@/Components/Common/Project/ProjectTable.vue';
|
||||
import type {
|
||||
@@ -15,6 +15,7 @@ import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue
|
||||
import PageTitle from '@/Components/Common/PageTitle.vue';
|
||||
import { canCreateProjects } from '@/utils/permissions';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import type { CreateClientBody, Client, CreateProjectBody, Project } from '@/packages/api/src';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
@@ -29,8 +30,7 @@ import { NO_CLIENT_ID } from '@/Components/Common/Project/constants';
|
||||
|
||||
// Fetch data using TanStack Query
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
const { clients } = storeToRefs(useClientsStore());
|
||||
const { clients } = useClientsQuery();
|
||||
const { organization } = storeToRefs(useOrganizationStore());
|
||||
|
||||
// Table state persisted in localStorage
|
||||
|
||||
@@ -36,15 +36,18 @@ import MemberMultiselectDropdown from '@/Components/Common/Member/MemberMultisel
|
||||
import TaskMultiselectDropdown from '@/Components/Common/Task/TaskMultiselectDropdown.vue';
|
||||
import SelectDropdown from '@/packages/ui/src/Input/SelectDropdown.vue';
|
||||
import ClientMultiselectDropdown from '@/Components/Common/Client/ClientMultiselectDropdown.vue';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useSessionStorage } from '@vueuse/core';
|
||||
import TimeEntryRow from '@/packages/ui/src/TimeEntry/TimeEntryRow.vue';
|
||||
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
import {
|
||||
PaginationEllipsis,
|
||||
PaginationFirst,
|
||||
@@ -88,7 +91,7 @@ const roundingEnabled = ref<boolean>(false);
|
||||
const roundingType = ref<TimeEntryRoundingType>('nearest');
|
||||
const roundingMinutes = ref<number>(15);
|
||||
|
||||
const { members } = storeToRefs(useMembersStore());
|
||||
const { members } = useMembersQuery();
|
||||
const pageLimit = 15;
|
||||
|
||||
// Watch rounding enabled state to trigger updates
|
||||
@@ -126,7 +129,7 @@ const { setActiveState, startLiveTimer } = currentTimeEntryStore;
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
const { createTimeEntry, updateTimeEntry, updateTimeEntries } = useTimeEntriesStore();
|
||||
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
const { tags } = useTagsQuery();
|
||||
|
||||
const { data: timeEntryResponse } = useQuery<TimeEntryResponse>({
|
||||
queryKey: ['timeEntry', 'detailed-report'],
|
||||
@@ -160,12 +163,9 @@ onMounted(async () => {
|
||||
await updateFilteredTimeEntries();
|
||||
});
|
||||
|
||||
const projectStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectStore);
|
||||
const taskStore = useTasksStore();
|
||||
const { tasks } = storeToRefs(taskStore);
|
||||
const clientStore = useClientsStore();
|
||||
const { clients } = storeToRefs(clientStore);
|
||||
const { projects } = useProjectsQuery();
|
||||
const { tasks } = useTasksQuery();
|
||||
const { clients } = useClientsQuery();
|
||||
|
||||
const selectedTimeEntries = ref<TimeEntry[]>([]);
|
||||
|
||||
|
||||
@@ -17,16 +17,19 @@ import { useElementVisibility } from '@vueuse/core';
|
||||
import { ClockIcon } from '@heroicons/vue/20/solid';
|
||||
import LoadingSpinner from '@/packages/ui/src/LoadingSpinner.vue';
|
||||
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import TimeEntryGroupedTable from '@/packages/ui/src/TimeEntry/TimeEntryGroupedTable.vue';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import TimeEntryMassActionRow from '@/packages/ui/src/TimeEntry/TimeEntryMassActionRow.vue';
|
||||
import type { UpdateMultipleTimeEntriesChangeset } from '@/packages/api/src';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { canCreateProjects } from '@/utils/permissions';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
|
||||
const timeEntriesStore = useTimeEntriesStore();
|
||||
const { timeEntries, allTimeEntriesLoaded } = storeToRefs(timeEntriesStore);
|
||||
@@ -43,7 +46,6 @@ const isLoadMoreVisible = useElementVisibility(loadMoreContainer);
|
||||
const currentTimeEntryStore = useCurrentTimeEntryStore();
|
||||
const { currentTimeEntry } = storeToRefs(currentTimeEntryStore);
|
||||
const { setActiveState } = currentTimeEntryStore;
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
|
||||
async function startTimeEntry(timeEntry: Omit<CreateTimeEntryBody, 'member_id'>) {
|
||||
if (currentTimeEntry.value.id) {
|
||||
@@ -70,12 +72,11 @@ onMounted(async () => {
|
||||
await timeEntriesStore.fetchTimeEntries();
|
||||
});
|
||||
|
||||
const projectStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectStore);
|
||||
const taskStore = useTasksStore();
|
||||
const { tasks } = storeToRefs(taskStore);
|
||||
const clientStore = useClientsStore();
|
||||
const { clients } = storeToRefs(clientStore);
|
||||
const { projects } = useProjectsQuery();
|
||||
const { tasks } = useTasksQuery();
|
||||
const { clients } = useClientsQuery();
|
||||
|
||||
const { tags } = useTagsQuery();
|
||||
|
||||
async function createTag(name: string) {
|
||||
return await useTagsStore().createTag(name);
|
||||
|
||||
Reference in New Issue
Block a user