Skip to content

Commit

Permalink
feat: request fresh membership (#122)
Browse files Browse the repository at this point in the history
## Description

<!-- Write and explain of the changes introduced by this PR for the reviewers to fully understand -->

## Screenshot

<!-- Provide a screenshot or gif of the change to demonstrate it -->

## Test Plan

<!-- Explain what you tested and why -->

<!--
  Have any questions? Check out the contributing doc for more
-->
  • Loading branch information
mkarajohn authored Mar 13, 2024
2 parents 4c5b769 + fa574d0 commit 736f66e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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 736f66e

Please sign in to comment.