Skip to content

Commit

Permalink
fix: some queryClient behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonardoD committed Nov 15, 2024
1 parent 6c78e4f commit 2100639
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DeleteOrganizations = ({ organizations, callback, dialog: isDialog }: Prop
onSuccess: () => {
for (const organization of organizations) {
queryClient.invalidateQueries({
queryKey: ['organizations', organization.id],
queryKey: ['organization', organization.id],
});
deleteMenuItem(organization.id);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/organizations/organization-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const organizationTabs: PageNavTab[] = [

export const organizationQueryOptions = (idOrSlug: string) =>
queryOptions({
queryKey: ['organizations', idOrSlug],
queryKey: ['organization', idOrSlug],
queryFn: () => getOrganization(idOrSlug),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const OrganizationsTable = () => {
// Map (updated) query data to rows
useMapQueryDataToRows<Organization>({ queryResult, setSelectedRows, setRows, selectedRows, setTotalCount });

const mutateQuery = useMutateQueryData(['organizations', 'list'], (item) => ['organizations', item.id], ['update', 'delete']);
const mutateQuery = useMutateQueryData(['organizations', 'list']);

// Build columns
const [columns, setColumns] = useColumns(mutateQuery.update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ type FormValues = z.infer<typeof formSchema>;

export const useUpdateOrganizationMutation = (idOrSlug: string) => {
return useMutation<Organization, DefaultError, UpdateOrganizationParams>({
mutationKey: ['organizations', 'update', idOrSlug],
mutationKey: ['organization', 'update', idOrSlug],
mutationFn: (params) => updateOrganization(idOrSlug, params),
onSuccess: (updatedOrganization) => {
queryClient.setQueryData(['organizations', idOrSlug], updatedOrganization);
queryClient.setQueryData(['organization', idOrSlug], updatedOrganization);
queryClient.invalidateQueries({
queryKey: ['organizations'],
queryKey: ['organization'],
});
},
gcTime: 1000 * 10,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/system/requests-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const requestsQueryOptions = ({
const offset = rowsLength;

return infiniteQueryOptions({
queryKey: ['requests', q, sort, order],
queryKey: ['requests', 'list', q, sort, order],
initialPageParam: 0,
retry: 1,
refetchOnWindowFocus: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/users/users-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const UsersTable = () => {
return rows.filter((row) => selectedRows.has(row.id));
}, [selectedRows, rows]);

const mutateQuery = useMutateQueryData(['users', 'list'], (item) => ['user', item.id], ['update', 'delete']);
const mutateQuery = useMutateQueryData(['users', 'list'], (item) => ['user', item.id], ['update']);

// Build columns
const [columns, setColumns] = useColumns(mutateQuery.update);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/routes/organizations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const OrganizationMembersRoute = createRoute({
},
component: () => {
const { idOrSlug } = useParams({ from: OrganizationMembersRoute.id });
const organization: OrganizationType | undefined = queryClient.getQueryData(['organizations', idOrSlug]);
const organization: OrganizationType | undefined = queryClient.getQueryData(['organization', idOrSlug]);

if (!organization) return;
return (
Expand All @@ -77,7 +77,7 @@ export const OrganizationAttachmentsRoute = createRoute({
loaderDeps: ({ search: { q, sort, order } }) => ({ q, sort, order }),
component: () => {
const { idOrSlug } = useParams({ from: OrganizationAttachmentsRoute.id });
const organization: OrganizationType | undefined = queryClient.getQueryData(['organizations', idOrSlug]);
const organization: OrganizationType | undefined = queryClient.getQueryData(['organization', idOrSlug]);

if (!organization) return;
return (
Expand All @@ -94,7 +94,7 @@ export const OrganizationSettingsRoute = createRoute({
getParentRoute: () => OrganizationRoute,
component: () => {
const { idOrSlug } = useParams({ from: OrganizationSettingsRoute.id });
const organization: OrganizationType | undefined = queryClient.getQueryData(['organizations', idOrSlug]);
const organization: OrganizationType | undefined = queryClient.getQueryData(['organization', idOrSlug]);
if (!organization) return;
return (
<Suspense>
Expand Down

0 comments on commit 2100639

Please sign in to comment.