diff --git a/src/context/auth-context.tsx b/src/context/auth-context.tsx index 2fd23d4..e01b0a3 100644 --- a/src/context/auth-context.tsx +++ b/src/context/auth-context.tsx @@ -1,5 +1,6 @@ import React, { createContext, useEffect, useCallback } from 'react'; import { getOAuthLogoutUrl, getOAuthOrigin } from '../constants/'; +import { useAuthData } from '@deriv-com/api-hooks'; type MessageEvent = { data: 'logout_complete' | 'logout_error'; @@ -12,13 +13,14 @@ type OAuth2ContextValue = { type OAuth2ProviderProps = { children: React.ReactNode; - logout: () => Promise; oauthUrl: string; }; export const OAuth2Context = createContext(undefined); -export const OAuth2Provider: React.FC = ({ children, logout, oauthUrl }) => { +export const OAuth2Provider: React.FC = ({ children, oauthUrl }) => { + const { logout } = useAuthData(); + const WSLogoutAndRedirect = useCallback(async () => { await logout(); window.open(oauthUrl, '_self'); diff --git a/src/main.tsx b/src/main.tsx index 4bbf491..f610940 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,10 +1,16 @@ import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import App from './App'; import './index.css'; +import { AppDataProvider } from '@deriv-com/api-hooks'; createRoot(document.getElementById('root')!).render( - + + + + + );