mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
update query keys to include org id, preventing stale data after organization switch
This commit is contained in:
@@ -37,7 +37,7 @@ const pageLimit = 15;
|
|||||||
const currentPage = ref(1);
|
const currentPage = ref(1);
|
||||||
|
|
||||||
const { data: reportsResponse } = useQuery<ReportIndexResponse>({
|
const { data: reportsResponse } = useQuery<ReportIndexResponse>({
|
||||||
queryKey: ['reports', currentPage],
|
queryKey: computed(() => ['reports', getCurrentOrganizationId(), currentPage.value]),
|
||||||
enabled: !!getCurrentOrganizationId(),
|
enabled: !!getCurrentOrganizationId(),
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getReports({
|
api.getReports({
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ function prefetchProjects(queryClient: QueryClient) {
|
|||||||
if (!organizationId) return;
|
if (!organizationId) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['projects'],
|
queryKey: ['projects', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getProjects({
|
api.getProjects({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -166,7 +166,7 @@ function prefetchTasks(queryClient: QueryClient) {
|
|||||||
if (!organizationId) return;
|
if (!organizationId) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['tasks'],
|
queryKey: ['tasks', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getTasks({
|
api.getTasks({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -181,7 +181,7 @@ function prefetchTags(queryClient: QueryClient) {
|
|||||||
if (!organizationId) return;
|
if (!organizationId) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['tags'],
|
queryKey: ['tags', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getTags({
|
api.getTags({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -195,7 +195,7 @@ function prefetchClients(queryClient: QueryClient) {
|
|||||||
if (!organizationId || !canViewClients()) return;
|
if (!organizationId || !canViewClients()) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['clients'],
|
queryKey: ['clients', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getClients({
|
api.getClients({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -210,7 +210,7 @@ function prefetchMembers(queryClient: QueryClient) {
|
|||||||
if (!organizationId || !canViewMembers()) return;
|
if (!organizationId || !canViewMembers()) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['members'],
|
queryKey: ['members', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getMembers({
|
api.getMembers({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -224,7 +224,7 @@ function prefetchReports(queryClient: QueryClient) {
|
|||||||
if (!organizationId) return;
|
if (!organizationId) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['reports', 1],
|
queryKey: ['reports', organizationId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getReports({
|
api.getReports({
|
||||||
params: { organization: organizationId },
|
params: { organization: organizationId },
|
||||||
@@ -276,7 +276,7 @@ function prefetchProjectMembers(queryClient: QueryClient, projectId: string) {
|
|||||||
if (!organizationId || !canViewMembers()) return;
|
if (!organizationId || !canViewMembers()) return;
|
||||||
|
|
||||||
queryClient.prefetchQuery({
|
queryClient.prefetchQuery({
|
||||||
queryKey: ['projectMembers', projectId],
|
queryKey: ['projectMembers', organizationId, projectId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getProjectMembers({
|
api.getProjectMembers({
|
||||||
params: { organization: organizationId, project: projectId },
|
params: { organization: organizationId, project: projectId },
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function useClientsQuery() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['clients'],
|
queryKey: computed(() => ['clients', getCurrentOrganizationId()]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (!organizationId) throw new Error('No organization');
|
if (!organizationId) throw new Error('No organization');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function useMembersQuery() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['members'],
|
queryKey: computed(() => ['members', getCurrentOrganizationId()]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (!organizationId) throw new Error('No organization');
|
if (!organizationId) throw new Error('No organization');
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export function useProjectMembersQuery(projectId: Ref<string | null> | string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['projectMembers', projectIdValue],
|
queryKey: computed(() => ['projectMembers', getCurrentOrganizationId(), projectIdValue.value]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
const pid = projectIdValue.value;
|
const pid = projectIdValue.value;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function useProjectsQuery() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['projects'],
|
queryKey: computed(() => ['projects', getCurrentOrganizationId()]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (!organizationId) throw new Error('No organization');
|
if (!organizationId) throw new Error('No organization');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function useTagsQuery() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['tags'],
|
queryKey: computed(() => ['tags', getCurrentOrganizationId()]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (!organizationId) throw new Error('No organization');
|
if (!organizationId) throw new Error('No organization');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function useTasksQuery() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['tasks'],
|
queryKey: computed(() => ['tasks', getCurrentOrganizationId()]),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (!organizationId) throw new Error('No organization');
|
if (!organizationId) throw new Error('No organization');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function useTimeEntriesReportQuery(
|
|||||||
filterParams: Ref<Record<string, unknown>> | ComputedRef<Record<string, unknown>>
|
filterParams: Ref<Record<string, unknown>> | ComputedRef<Record<string, unknown>>
|
||||||
) {
|
) {
|
||||||
return useQuery<TimeEntryResponse>({
|
return useQuery<TimeEntryResponse>({
|
||||||
queryKey: computed(() => ['timeEntries', 'detailed-report', unref(filterParams)]),
|
queryKey: computed(() => ['timeEntries', 'detailed-report', getCurrentOrganizationId(), unref(filterParams)]),
|
||||||
enabled: computed(() => !!getCurrentOrganizationId()),
|
enabled: computed(() => !!getCurrentOrganizationId()),
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.getTimeEntries({
|
api.getTimeEntries({
|
||||||
|
|||||||
Reference in New Issue
Block a user