From 5203e7f21d84e0f2ca5384ce24b922c4e4e2cc6d Mon Sep 17 00:00:00 2001 From: Johnny Bouder Date: Tue, 17 Dec 2024 07:19:19 -0500 Subject: [PATCH] Fix issues. --- src/components/header/header.test.tsx | 2 +- .../protected-route/protected-route.test.tsx | 2 +- src/hooks/use-auth.test.tsx | 2 +- src/hooks/use-auth.ts | 2 +- src/main.tsx | 2 +- .../dashboard-bar-chart/dashboard-bar-chart.test.tsx | 2 +- .../dashboard-pie-chart/dashboard-pie-chart.test.tsx | 2 +- .../dashboard-table/dashboard-table.test.tsx | 2 +- src/pages/dashboard/dashboard.test.tsx | 2 +- src/pages/details/details.test.tsx | 2 +- src/pages/home/home.test.tsx | 2 +- src/pages/search-results/search-results.test.tsx | 2 +- src/pages/sign-in/sign-in.test.tsx | 2 +- src/store.ts | 11 ++--------- 14 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/components/header/header.test.tsx b/src/components/header/header.test.tsx index 69a8575..dd5cf96 100644 --- a/src/components/header/header.test.tsx +++ b/src/components/header/header.test.tsx @@ -2,8 +2,8 @@ import { act, fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; -import { AuthProvider } from 'react-oidc-context'; import { Provider } from 'jotai'; +import { AuthProvider } from 'react-oidc-context'; import * as useAuthMock from '../../hooks/use-auth'; import { User } from '../../types/user'; import { Header } from './header'; diff --git a/src/components/protected-route/protected-route.test.tsx b/src/components/protected-route/protected-route.test.tsx index 9168e07..be74dd4 100644 --- a/src/components/protected-route/protected-route.test.tsx +++ b/src/components/protected-route/protected-route.test.tsx @@ -1,8 +1,8 @@ import { User } from '@src/types/user'; import { act, render } from '@testing-library/react'; +import { Provider } from 'jotai'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import * as useAuthMock from '../../hooks/use-auth'; import { ProtectedRoute } from './protected-route'; diff --git a/src/hooks/use-auth.test.tsx b/src/hooks/use-auth.test.tsx index fc0197d..a35b066 100644 --- a/src/hooks/use-auth.test.tsx +++ b/src/hooks/use-auth.test.tsx @@ -1,7 +1,7 @@ import keycloak from '@src/utils/keycloak'; import { act, renderHook } from '@testing-library/react'; -import { AuthProvider } from 'react-oidc-context'; import { Provider } from 'jotai'; +import { AuthProvider } from 'react-oidc-context'; import useAuth from './use-auth'; interface ContextWrapperProps { diff --git a/src/hooks/use-auth.ts b/src/hooks/use-auth.ts index 42d0e50..a8d841e 100644 --- a/src/hooks/use-auth.ts +++ b/src/hooks/use-auth.ts @@ -1,7 +1,7 @@ import { getSignInRedirectUrl } from '@src/utils/auth'; +import { useAtom } from 'jotai'; import { useEffect, useState } from 'react'; import { useAuth as useKeycloakAuth } from 'react-oidc-context'; -import { useAtom } from 'jotai'; import { userData } from '../data/user'; import { currentUserState, signedInState } from '../store'; import { User } from '../types/user'; diff --git a/src/main.tsx b/src/main.tsx index 6cfeabb..0de4433 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,8 +1,8 @@ +import { Provider } from 'jotai'; import React from 'react'; import ReactDOM from 'react-dom/client'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import { App } from './App.tsx'; import './styles.scss'; import keycloak from './utils/keycloak.ts'; diff --git a/src/pages/dashboard/dashboard-bar-chart/dashboard-bar-chart.test.tsx b/src/pages/dashboard/dashboard-bar-chart/dashboard-bar-chart.test.tsx index 31c8135..bd0d24b 100644 --- a/src/pages/dashboard/dashboard-bar-chart/dashboard-bar-chart.test.tsx +++ b/src/pages/dashboard/dashboard-bar-chart/dashboard-bar-chart.test.tsx @@ -1,7 +1,7 @@ import { mockData } from '@src/data/spacecraft'; import { act, render } from '@testing-library/react'; -import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'jotai'; +import { BrowserRouter } from 'react-router-dom'; import { DashboardBarChart } from './dashboard-bar-chart'; describe('DashboardBarChart', () => { diff --git a/src/pages/dashboard/dashboard-pie-chart/dashboard-pie-chart.test.tsx b/src/pages/dashboard/dashboard-pie-chart/dashboard-pie-chart.test.tsx index 7bd93a3..f521d10 100644 --- a/src/pages/dashboard/dashboard-pie-chart/dashboard-pie-chart.test.tsx +++ b/src/pages/dashboard/dashboard-pie-chart/dashboard-pie-chart.test.tsx @@ -1,7 +1,7 @@ import { mockData } from '@src/data/spacecraft'; import { act, render } from '@testing-library/react'; -import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'jotai'; +import { BrowserRouter } from 'react-router-dom'; import { DashboardPieChart } from './dashboard-pie-chart'; describe('DashboardPieChart', () => { diff --git a/src/pages/dashboard/dashboard-table/dashboard-table.test.tsx b/src/pages/dashboard/dashboard-table/dashboard-table.test.tsx index 725522e..d277f1d 100644 --- a/src/pages/dashboard/dashboard-table/dashboard-table.test.tsx +++ b/src/pages/dashboard/dashboard-table/dashboard-table.test.tsx @@ -1,7 +1,7 @@ import { mockData } from '@src/data/spacecraft'; import { act, render } from '@testing-library/react'; -import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'jotai'; +import { BrowserRouter } from 'react-router-dom'; import { DashboardTable } from './dashboard-table'; describe('DashboardTable', () => { diff --git a/src/pages/dashboard/dashboard.test.tsx b/src/pages/dashboard/dashboard.test.tsx index 7717ba1..d9a6109 100644 --- a/src/pages/dashboard/dashboard.test.tsx +++ b/src/pages/dashboard/dashboard.test.tsx @@ -3,9 +3,9 @@ import axios from '@src/utils/axios'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { act, render } from '@testing-library/react'; import MockAdapter from 'axios-mock-adapter'; +import { Provider } from 'jotai'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import * as useAuthMock from '../../hooks/use-auth'; import { User } from '../../types/user'; import { Dashboard } from './dashboard'; diff --git a/src/pages/details/details.test.tsx b/src/pages/details/details.test.tsx index 38b73d3..266d446 100644 --- a/src/pages/details/details.test.tsx +++ b/src/pages/details/details.test.tsx @@ -3,9 +3,9 @@ import axios from '@src/utils/axios'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, waitFor } from '@testing-library/react'; import MockAdapter from 'axios-mock-adapter'; +import { Provider } from 'jotai'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import * as useAuthMock from '../../hooks/use-auth'; import { User } from '../../types/user'; import { Details } from './details'; diff --git a/src/pages/home/home.test.tsx b/src/pages/home/home.test.tsx index 427dc41..1bc41da 100644 --- a/src/pages/home/home.test.tsx +++ b/src/pages/home/home.test.tsx @@ -1,7 +1,7 @@ import { act, render } from '@testing-library/react'; +import { Provider } from 'jotai'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import * as useAuthMock from '../../hooks/use-auth'; import { User } from '../../types/user'; import { Home } from './home'; diff --git a/src/pages/search-results/search-results.test.tsx b/src/pages/search-results/search-results.test.tsx index 3070ec3..9120f98 100644 --- a/src/pages/search-results/search-results.test.tsx +++ b/src/pages/search-results/search-results.test.tsx @@ -4,9 +4,9 @@ import axios from '@src/utils/axios'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { act, render } from '@testing-library/react'; import MockAdapter from 'axios-mock-adapter'; +import { Provider } from 'jotai'; import { AuthProvider } from 'react-oidc-context'; import { BrowserRouter } from 'react-router-dom'; -import { Provider } from 'jotai'; import * as useAuthMock from '../../hooks/use-auth'; import { SearchResults } from './search-results'; diff --git a/src/pages/sign-in/sign-in.test.tsx b/src/pages/sign-in/sign-in.test.tsx index 315f967..2f53844 100644 --- a/src/pages/sign-in/sign-in.test.tsx +++ b/src/pages/sign-in/sign-in.test.tsx @@ -2,8 +2,8 @@ import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; -import { AuthProvider } from 'react-oidc-context'; import { Provider } from 'jotai'; +import { AuthProvider } from 'react-oidc-context'; import * as useAuthMock from '../../hooks/use-auth'; import { User } from '../../types/user'; import { SignIn } from './sign-in'; diff --git a/src/store.ts b/src/store.ts index 9f4392a..f224778 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,14 +1,7 @@ import { User } from '@src/types/user'; import { atom } from 'jotai'; -const signedInState = atom({ - key: 'signedIn', - default: false, -}); - -const currentUserState = atom({ - key: 'currentUser', - default: undefined, -}); +const signedInState = atom(false); +const currentUserState = atom(undefined); export { currentUserState, signedInState };