Skip to content

Commit

Permalink
feat: set up react-query in App component
Browse files Browse the repository at this point in the history
  • Loading branch information
yumincho committed May 16, 2024
1 parent f791542 commit b2e5f9a
Showing 1 changed file with 53 additions and 46 deletions.
99 changes: 53 additions & 46 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import EventBannerPage from './pages/EventBannerPage';

import ReactGA from 'react-ga4';

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

const trackingId = 'G-8NSY19J0T3';
ReactGA.initialize([
{
Expand Down Expand Up @@ -168,6 +171,7 @@ class App extends Component {

render() {
const { popupOpen, doNotShowAgain } = this.state;
const queryClient = new QueryClient();

Check warning on line 174 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L174

Added line #L174 was not covered by tests

const parseObject = (object) => {
if (typeof object === 'object') {
Expand Down Expand Up @@ -200,52 +204,55 @@ class App extends Component {
};

return (
<Provider store={store}>
<>
<Header />
<Routes>
<Route exact path="/dictionary" element={<DictionaryPage />} />
<Route exact path="/planner" element={<PlannerPage />} />
<Route exact path="/timetable" element={<TimetablePage />} />
<Route exact path="/timetable/syllabus" element={<SyllabusPage />} />
<Route exact path="/write-reviews" element={<WriteReviewsPage />} />
<Route exact path="/account" element={<AccountPage />} />
<Route exact path="/eventBanner" element={<EventBannerPage />} />
<Route exact path="/credits" element={<CreditPage />} />
<Route exact path="/licenses" element={<LicensePage />} />
<Route exact path="/privacy" element={<PrivacyPage />} />
{/* Temporary test page for axiom */}
<Route exact path="/test" element={<TestPage />} />
<Route exact path="/error/:message" element={<ErrorPage />} />
<Route exact path="/" element={<MainPage />} />
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</>
<section>
<BannerPopup
popupOpen={popupOpen}
setPopupOpen={(state) => this.setState({ popupOpen: state })}>
<CampaignPopupImage closePopup={() => this.setState({ popupOpen: false })} />
<PopupMenu
onClose={() => {
ReactGA.event({
category: 'Campaign',
action: 'popup-close',
});
this.setState({ popupOpen: false });
}}
onDoNotShow={() => {
ReactGA.event({
category: 'Campaign',
action: 'popup-do-not-show',
});
this._setDoNotShow(true);
this.setState({ popupOpen: false });
}}
/>
</BannerPopup>
</section>
</Provider>
<QueryClientProvider client={queryClient}>
<Provider store={store}>
<>
<Header />
<Routes>
<Route exact path="/dictionary" element={<DictionaryPage />} />
<Route exact path="/planner" element={<PlannerPage />} />
<Route exact path="/timetable" element={<TimetablePage />} />
<Route exact path="/timetable/syllabus" element={<SyllabusPage />} />
<Route exact path="/write-reviews" element={<WriteReviewsPage />} />
<Route exact path="/account" element={<AccountPage />} />
<Route exact path="/eventBanner" element={<EventBannerPage />} />
<Route exact path="/credits" element={<CreditPage />} />
<Route exact path="/licenses" element={<LicensePage />} />
<Route exact path="/privacy" element={<PrivacyPage />} />
{/* Temporary test page for axiom */}
<Route exact path="/test" element={<TestPage />} />
<Route exact path="/error/:message" element={<ErrorPage />} />
<Route exact path="/" element={<MainPage />} />
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</>
<section>
<BannerPopup
popupOpen={popupOpen}
setPopupOpen={(state) => this.setState({ popupOpen: state })}>
<CampaignPopupImage closePopup={() => this.setState({ popupOpen: false })} />

Check warning on line 233 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L232-L233

Added lines #L232 - L233 were not covered by tests
<PopupMenu
onClose={() => {
ReactGA.event({

Check warning on line 236 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L235-L236

Added lines #L235 - L236 were not covered by tests
category: 'Campaign',
action: 'popup-close',
});
this.setState({ popupOpen: false });

Check warning on line 240 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L240

Added line #L240 was not covered by tests
}}
onDoNotShow={() => {
ReactGA.event({

Check warning on line 243 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L242-L243

Added lines #L242 - L243 were not covered by tests
category: 'Campaign',
action: 'popup-do-not-show',
});
this._setDoNotShow(true);
this.setState({ popupOpen: false });

Check warning on line 248 in src/App.jsx

View check run for this annotation

Codecov / codecov/patch

src/App.jsx#L247-L248

Added lines #L247 - L248 were not covered by tests
}}
/>
</BannerPopup>
</section>
</Provider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}
}
Expand Down

0 comments on commit b2e5f9a

Please sign in to comment.