Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORV2-2692 Fixing User management and Vehicle query - data refresh #1576

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const ManageProfilesDashboard = React.memo(() => {
queryKey: ["companyInfo"],
queryFn: getCompanyInfo,
placeholderData: keepPreviousData,
staleTime: FIVE_MINUTES,
refetchInterval: FIVE_MINUTES
});

const navigate = useNavigate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export const EditUserDashboard = React.memo(() => {
queryKey: ["userByuserGUID", userGUID],
queryFn: () => getCompanyUserByUserGUID(userGUID as string),
retry: false,
refetchOnWindowFocus: false,
enabled: true,
staleTime: Infinity,
gcTime: 0 // Disable saving in cache - Always fetch for latest data.
});

const onClickBreadcrumb = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box } from "@mui/material";
import { useQuery } from "@tanstack/react-query";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { RowSelectionState } from "@tanstack/table-core";
import { useCallback, useContext, useEffect, useState } from "react";
import { useAuth } from "react-oidc-context";
Expand All @@ -14,7 +14,6 @@ import { SnackBarContext } from "../../../App";
import { DeleteConfirmationDialog } from "../../../common/components/dialog/DeleteConfirmationDialog";
import { NoRecordsFound } from "../../../common/components/table/NoRecordsFound";
import { TrashButton } from "../../../common/components/buttons/TrashButton";
import { ONE_HOUR } from "../../../common/constants/constants";
import {
defaultTableInitialStateOptions,
defaultTableOptions,
Expand All @@ -41,7 +40,9 @@ export const UserManagement = () => {
const query = useQuery({
queryKey: ["companyUsers"],
queryFn: getCompanyUsers,
staleTime: ONE_HOUR,
placeholderData: keepPreviousData,
refetchOnWindowFocus: false,
retry: 1,
});
const { data, isError, isLoading } = query;
const { setSnackBar } = useContext(SnackBarContext);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/features/manageVehicles/hooks/vehicles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export const useVehicleByIdQuery = (
refetchOnMount: "always", // always fetch when component is mounted
refetchOnWindowFocus: false, // prevent unnecessary multiple queries on page showing up in foreground
enabled: Boolean(companyId) && Boolean(vehicleId), // does not perform the query at all if company or vehicle id is empty
gcTime: 0, // Do not store in cache - Refetch always
});
};
Loading