Skip to content

Commit

Permalink
fix: token expire
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Nov 20, 2023
1 parent 46cdd3e commit cd933fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMsal } from '@azure/msal-react';
import { Button, Table, Typography } from '@equinor/eds-core-react';
import { useQuery } from '@tanstack/react-query';
import { useParams } from 'react-router-dom';
import { OpenAPI } from '../../../api/generated';
import { AnalogueModelsService } from '../../../api/generated/services/AnalogueModelsService';
import { useAccessToken } from '../../../hooks/useAccessToken';

Expand All @@ -12,6 +13,7 @@ export const ModelMetadataView = () => {
const { modelId } = useParams();
const { instance, accounts } = useMsal();
const token = useAccessToken(instance, accounts[0]);
if (token) OpenAPI.TOKEN = token;

const { isLoading, data } = useQuery({
queryKey: ['analogue-models', modelId],
Expand All @@ -21,9 +23,6 @@ export const ModelMetadataView = () => {
});
if (isLoading || !data?.success) return <p>Loading ...</p>;

// TODO
// Map rows to model data

return (
<div className="metadata-view">
<Typography variant="h3">Description and metadata</Typography>
Expand Down
7 changes: 6 additions & 1 deletion src/features/ModelView/ModelSourceView/ModelSourceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import { useMsal } from '@azure/msal-react';
import { Table, Typography } from '@equinor/eds-core-react';
import { useQuery } from '@tanstack/react-query';
import { useParams } from 'react-router-dom';
import { AnalogueModelsService, UploadList } from '../../../api/generated';
import {
AnalogueModelsService,
OpenAPI,
UploadList,
} from '../../../api/generated';
import { useAccessToken } from '../../../hooks/useAccessToken';

export const ModelSourceView = () => {
const { modelId } = useParams();
const { instance, accounts } = useMsal();
const token = useAccessToken(instance, accounts[0]);
if (token) OpenAPI.TOKEN = token;

const { isLoading, data } = useQuery({
queryKey: ['analogue-models', modelId],
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ModelPages/Model/Model.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMsal } from '@azure/msal-react';
import { useQuery } from '@tanstack/react-query';
import { Outlet, useParams } from 'react-router-dom';
import { AnalogueModelsService } from '../../../api/generated';
import { AnalogueModelsService, OpenAPI } from '../../../api/generated';
import { ModelNameFrame } from '../../../features/ModelView/ModelNameFrame/ModelNameFrame';
import { ModelNavigationBar } from '../../../features/ModelView/ModelNavigationBar/ModelNavigationBar';
import { useAccessToken } from '../../../hooks/useAccessToken';
Expand All @@ -11,6 +11,7 @@ export const Model = () => {
const { modelId } = useParams<{ modelId: string }>();
const { instance, accounts } = useMsal();
const token = useAccessToken(instance, accounts[0]);
if (token) OpenAPI.TOKEN = token;

const { data, isLoading } = useQuery({
queryKey: ['analogue-models', modelId],
Expand Down

0 comments on commit cd933fb

Please sign in to comment.