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 { data: reportsResponse } = useQuery<ReportIndexResponse>({
|
||||
queryKey: ['reports', currentPage],
|
||||
queryKey: computed(() => ['reports', getCurrentOrganizationId(), currentPage.value]),
|
||||
enabled: !!getCurrentOrganizationId(),
|
||||
queryFn: () =>
|
||||
api.getReports({
|
||||
|
||||
@@ -151,7 +151,7 @@ function prefetchProjects(queryClient: QueryClient) {
|
||||
if (!organizationId) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['projects'],
|
||||
queryKey: ['projects', organizationId],
|
||||
queryFn: () =>
|
||||
api.getProjects({
|
||||
params: { organization: organizationId },
|
||||
@@ -166,7 +166,7 @@ function prefetchTasks(queryClient: QueryClient) {
|
||||
if (!organizationId) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['tasks'],
|
||||
queryKey: ['tasks', organizationId],
|
||||
queryFn: () =>
|
||||
api.getTasks({
|
||||
params: { organization: organizationId },
|
||||
@@ -181,7 +181,7 @@ function prefetchTags(queryClient: QueryClient) {
|
||||
if (!organizationId) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['tags'],
|
||||
queryKey: ['tags', organizationId],
|
||||
queryFn: () =>
|
||||
api.getTags({
|
||||
params: { organization: organizationId },
|
||||
@@ -195,7 +195,7 @@ function prefetchClients(queryClient: QueryClient) {
|
||||
if (!organizationId || !canViewClients()) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['clients'],
|
||||
queryKey: ['clients', organizationId],
|
||||
queryFn: () =>
|
||||
api.getClients({
|
||||
params: { organization: organizationId },
|
||||
@@ -210,7 +210,7 @@ function prefetchMembers(queryClient: QueryClient) {
|
||||
if (!organizationId || !canViewMembers()) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['members'],
|
||||
queryKey: ['members', organizationId],
|
||||
queryFn: () =>
|
||||
api.getMembers({
|
||||
params: { organization: organizationId },
|
||||
@@ -224,7 +224,7 @@ function prefetchReports(queryClient: QueryClient) {
|
||||
if (!organizationId) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['reports', 1],
|
||||
queryKey: ['reports', organizationId],
|
||||
queryFn: () =>
|
||||
api.getReports({
|
||||
params: { organization: organizationId },
|
||||
@@ -276,7 +276,7 @@ function prefetchProjectMembers(queryClient: QueryClient, projectId: string) {
|
||||
if (!organizationId || !canViewMembers()) return;
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['projectMembers', projectId],
|
||||
queryKey: ['projectMembers', organizationId, projectId],
|
||||
queryFn: () =>
|
||||
api.getProjectMembers({
|
||||
params: { organization: organizationId, project: projectId },
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useClientsQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['clients'],
|
||||
queryKey: computed(() => ['clients', getCurrentOrganizationId()]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useMembersQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['members'],
|
||||
queryKey: computed(() => ['members', getCurrentOrganizationId()]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
|
||||
@@ -12,7 +12,7 @@ export function useProjectMembersQuery(projectId: Ref<string | null> | string) {
|
||||
});
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['projectMembers', projectIdValue],
|
||||
queryKey: computed(() => ['projectMembers', getCurrentOrganizationId(), projectIdValue.value]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
const pid = projectIdValue.value;
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useProjectsQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['projects'],
|
||||
queryKey: computed(() => ['projects', getCurrentOrganizationId()]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useTagsQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['tags'],
|
||||
queryKey: computed(() => ['tags', getCurrentOrganizationId()]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useTasksQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['tasks'],
|
||||
queryKey: computed(() => ['tasks', getCurrentOrganizationId()]),
|
||||
queryFn: async () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (!organizationId) throw new Error('No organization');
|
||||
|
||||
@@ -7,7 +7,7 @@ export function useTimeEntriesReportQuery(
|
||||
filterParams: Ref<Record<string, unknown>> | ComputedRef<Record<string, unknown>>
|
||||
) {
|
||||
return useQuery<TimeEntryResponse>({
|
||||
queryKey: computed(() => ['timeEntries', 'detailed-report', unref(filterParams)]),
|
||||
queryKey: computed(() => ['timeEntries', 'detailed-report', getCurrentOrganizationId(), unref(filterParams)]),
|
||||
enabled: computed(() => !!getCurrentOrganizationId()),
|
||||
queryFn: () =>
|
||||
api.getTimeEntries({
|
||||
|
||||
Reference in New Issue
Block a user