diff --git a/package.json b/package.json index e53661fa..c95de8bd 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@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", "polished": "^4.2.2", "react-error-boundary": "^3.1.4", diff --git a/src/providers/Toolbox/Toolbox.tsx b/src/providers/Toolbox/Toolbox.tsx index b3149d39..55e63c67 100644 --- a/src/providers/Toolbox/Toolbox.tsx +++ b/src/providers/Toolbox/Toolbox.tsx @@ -1,5 +1,6 @@ import { Button, Loader } from '@orfium/ictinus'; import * as Sentry from '@sentry/browser'; +import dayjs from 'dayjs'; import { ReactNode, useEffect, useState } from 'react'; import { ErrorBoundary } from 'react-error-boundary'; import { config } from '../../config'; @@ -45,7 +46,7 @@ export function Toolbox({ children }: ToolboxProps) { * This is the main component that is wrapped in the authentication. */ function AuthenticationWrapper({ children }: { children: ReactNode }) { - const { isLoading, isAuthenticated, getAccessTokenSilently, logout, loginWithRedirect } = + const { user, isLoading, isAuthenticated, getAccessTokenSilently, logout, loginWithRedirect } = useAuthentication(); const { organizations, selectedOrganization } = useOrganizations(); const { setOrganizations, setSelectedOrganization } = useOrganization(); @@ -70,7 +71,10 @@ function AuthenticationWrapper({ children }: { children: ReactNode }) { const requestInstance = orfiumIdBaseInstance.createRequest({ 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(); diff --git a/yarn.lock b/yarn.lock index 021d20cd..de480714 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3828,6 +3828,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"