Skip to content

Commit

Permalink
Merge pull request #120 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Feb 26, 2025
2 parents 12053d9 + 94ea962 commit d0c9231
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/api/ApiCall.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export function ApiGetCall(props) {
bulkRequest = false,
toast = false,
onResult,
staleTime = 600000, // 10 minutes
refetchOnWindowFocus = false,
} = props;
const queryClient = useQueryClient();
const dispatch = useDispatch();
Expand Down Expand Up @@ -93,8 +95,8 @@ export function ApiGetCall(props) {
return response.data;
}
},
staleTime: 600000, // 10 minutes
refetchOnWindowFocus: false,
staleTime: staleTime,
refetchOnWindowFocus: refetchOnWindowFocus,
retry: retryFn,
});
return queryInfo;
Expand Down
3 changes: 3 additions & 0 deletions src/components/CippComponents/CippSettingsSideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const CippSettingsSideBar = (props) => {

const currentUser = ApiGetCall({
url: "/.auth/me",
queryKey: "authmecipp",
staleTime: 120000,
refetchOnWindowFocus: true,
});

const saveSettingsPost = ApiPostCall({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const CippIntegrationSettings = ({ children }) => {
Tenant: selectedTenant.label,
IntegrationName: selectedCompany.label,
IntegrationId: selectedCompany.value,
TenantDomain: selectedTenant.addedFields.defaultDomainName,
};

setTableData([...tableData, newRowData]);
Expand All @@ -109,6 +110,7 @@ const CippIntegrationSettings = ({ children }) => {
newTableData.push({
TenantId: tenant.customerId,
Tenant: tenant.displayName,
TenantDomain: tenant.defaultDomainName,
IntegrationName: matchingCompany.name,
IntegrationId: matchingCompany.value,
});
Expand Down Expand Up @@ -237,7 +239,7 @@ const CippIntegrationSettings = ({ children }) => {
reportTitle={`${extension.id}-tenant-map`}
data={tableData}
simple={false}
simpleColumns={["Tenant", "IntegrationName"]}
simpleColumns={["IntegrationName", "Tenant", "TenantDomain"]}
isFetching={mappings.isFetching}
refreshFunction={() => mappings.refetch()}
/>
Expand Down
6 changes: 4 additions & 2 deletions src/components/PrivateRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export const PrivateRoute = ({ children, routeType }) => {
const {
data: profile,
error,
isFetching,
isLoading,
} = ApiGetCall({
url: "/.auth/me",
queryKey: "authmecipp",
refetchOnWindowFocus: true,
staleTime: 120000, // 2 minutes
});

if (isFetching) {
if (isLoading) {
return "Loading...";
}

Expand Down
1 change: 1 addition & 0 deletions src/contexts/settings-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const initialSettings = {
paletteMode: "light",
pinNav: true,
currentTenant: null,
showDevtools: false,
};

const initialState = {
Expand Down
7 changes: 3 additions & 4 deletions src/layouts/account-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import SunIcon from "@heroicons/react/24/outline/SunIcon";
import {
Avatar,
Box,
FormControlLabel,
List,
ListItem,
ListItemButton,
Expand All @@ -18,10 +17,8 @@ import {
Popover,
Stack,
SvgIcon,
Switch,
Typography,
useMediaQuery,
IconButton,
} from "@mui/material";
import { usePopover } from "../hooks/use-popover";
import { paths } from "../paths";
Expand All @@ -42,7 +39,9 @@ export const AccountPopover = (props) => {

const orgData = ApiGetCall({
url: "/.auth/me",
queryKey: "me",
queryKey: "authmecipp",
staleTime: 120000,
refetchOnWindowFocus: true,
});

const handleLogout = useCallback(async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/layouts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export const Layout = (props) => {
const currentRole = ApiGetCall({
url: "/.auth/me",
queryKey: "authmecipp",
staleTime: 120000,
refetchOnWindowFocus: true,
});
const [hideSidebar, setHideSidebar] = useState(false);

Expand Down
4 changes: 2 additions & 2 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ const App = (props) => {
/>
</RTL>
</ThemeProvider>
{settings?.showDevtools && (
{settings.isInitialized && settings?.showDevtools === true ? (
<React.Suspense fallback={null}>
<ReactQueryDevtoolsProduction />
</React.Suspense>
)}
) : null}
</>
);
}}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/unauthenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { useState, useEffect } from "react";
const Page = () => {
const orgData = ApiGetCall({
url: "/.auth/me",
queryKey: "me",
queryKey: "authmecipp",
staleTime: 120000,
refetchOnWindowFocus: true,
});
const blockedRoles = ["anonymous", "authenticated"];
const [userRoles, setUserRoles] = useState([]);
Expand Down

0 comments on commit d0c9231

Please sign in to comment.