Skip to content

Commit

Permalink
feat: request fresh membership
Browse files Browse the repository at this point in the history
Reimplements this: 6190cd8
  • Loading branch information
mkarajohn committed Feb 20, 2024
1 parent 88de548 commit e52fefa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/providers/Toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -68,7 +69,10 @@ function AuthenticationWrapper({ children }: { children: ReactNode }) {
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 @@ -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"
Expand Down

0 comments on commit e52fefa

Please sign in to comment.