Skip to content

Commit

Permalink
feat: add fresh=true to request fresh membership
Browse files Browse the repository at this point in the history
  • Loading branch information
panvourtsis committed Nov 17, 2023
1 parent f5d5b16 commit 6190cd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"@auth0/auth0-spa-js": "^2.1.2",
"axios": "^0.21.4",
"axios-mock-adapter": "^1.19.0",
"dayjs": "^1.11.10",
"jwt-decode": "^3.1.2",
"react-error-boundary": "^3.1.4",
"zustand": "^4.0.0-rc.1",
"react-router-dom": "^5.3.1"
"react-router-dom": "^5.3.1",
"zustand": "^4.0.0-rc.1"
},
"devDependencies": {
"@amanda-mitchell/semantic-release-npm-multiple": "^3.5.0",
Expand Down
8 changes: 6 additions & 2 deletions src/authentication/Authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Sentry from '@sentry/browser';
import React, { useEffect, useState } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

import dayjs from 'dayjs';
import { orfiumIdBaseInstance } from '../request';
import useOrganization, { Organization } from '../store/useOrganization';
import { Box, LoadingContent, Wrapper } from './Authentication.style';
Expand Down Expand Up @@ -43,7 +44,7 @@ Authentication.TopBar = TopBar;
* This is the main component that is wrapped on the authentication.
*/
const AuthenticationWrapper: React.FunctionComponent = ({ children }) => {
const { isLoading, isAuthenticated, getAccessTokenSilently, logout, loginWithRedirect } =
const { isLoading, isAuthenticated, getAccessTokenSilently, logout, loginWithRedirect, user } =
useAuthentication();
const { organizations, setOrganizations, setSelectedOrganization, selectedOrganization } =
useOrganization();
Expand All @@ -66,7 +67,10 @@ const AuthenticationWrapper: React.FunctionComponent = ({ children }) => {
const requestInstance = orfiumIdBaseInstance.createRequest<Organization[]>({
method: 'get',
url: '/memberships/',
params: config.productCode ? { product_code: config.productCode } : undefined,
params: {
...(config.productCode ? { product_code: config.productCode } : {}),
fresh: dayjs(user?.updated_at).isAfter(dayjs().subtract(1, 'minute')) || undefined,
},
});
const data = await requestInstance.request();

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3786,6 +3786,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

dayjs@^1.11.10:
version "1.11.10"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0"
integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==

dayjs@^1.8.34:
version "1.11.6"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.6.tgz#2e79a226314ec3ec904e3ee1dd5a4f5e5b1c7afb"
Expand Down

0 comments on commit 6190cd8

Please sign in to comment.