Skip to content

Commit

Permalink
fix: Token refetch error. Ranamed refetch queryKey.
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Nov 15, 2023
1 parent e7cac87 commit 46cdd3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import { EdsDataGrid } from '@equinor/eds-data-grid-react';
import { useQuery } from '@tanstack/react-query';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { AnalogueModelsService } from '../api/generated';
import { AnalogueModelsService, OpenAPI } from '../api/generated';
import { useAccessToken } from '../hooks/useAccessToken';
import { AreaCoordinates } from './AreaCoordinates/AreaCoordinates';
import * as Styled from './Table.styled';

export const Table = ({ refetch }: { refetch: number }) => {
export const Table = ({ refetchKey }: { refetchKey: number }) => {
const { instance, accounts } = useMsal();
const token = useAccessToken(instance, accounts[0]);
if (token) OpenAPI.TOKEN = token;
const navigate = useNavigate();

const [toggle, setToggle] = useState<boolean>(false);
const [activeModel, setActiveModel] = useState<string>();
const { isLoading, data } = useQuery({
queryKey: ['analogue-models', refetch],
queryKey: ['analogue-models', refetchKey],
queryFn: () => AnalogueModelsService.getApiAnalogueModels(),
enabled: !!token,
});

const navigate = useNavigate();

if (isLoading || !data?.success) return <p>Loading...</p>;

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Browse/Browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const Browse = () => {
<div className="btn-div">
<Button onClick={toggleDialog}>Add new model</Button>
</div>
<Table refetch={refetch} />
<Table refetchKey={refetch} />
</Styled.BrowseWrapper>
<AddModelDialog
isOpen={isAddModelDialog}
Expand Down

0 comments on commit 46cdd3e

Please sign in to comment.