Skip to content

Commit

Permalink
Racing-car-game: migrate to sails.js (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
vraja-nayaka authored Sep 13, 2024
1 parent 057f8fd commit f80c9ca
Show file tree
Hide file tree
Showing 40 changed files with 898 additions and 1,013 deletions.
17 changes: 1 addition & 16 deletions frontend/apps/racing-car-game/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useEffect } from 'react';
import { Route, Routes } from 'react-router-dom';
import { useSetAtom } from 'jotai';
import { useAccount, useApi } from '@gear-js/react-hooks';
import { ErrorTrackingRoutes } from '@dapps-frontend/error-tracking';
import { Container, Footer } from '@dapps-frontend/ui';
Expand All @@ -12,31 +10,18 @@ import { LOGIN, PLAY, START } from '@/App.routes';
import styles from './App.module.scss';
import 'babel-polyfill';
import { useLoginByParams } from './hooks';
import { CURRENT_GAME, IS_CURRENT_GAME_READ_ATOM } from './atoms';
import { ProtectedRoute } from './features/Auth/components';
import { useAccountAvailableBalance, useAccountAvailableBalanceSync } from './features/Wallet/hooks';
import { LoginPage } from './pages/LoginPage';
import { ApiLoader } from './components/ApiLoader';
import { useGameState } from './features/Game/hooks';
import { useAuth, useAuthSync } from './features/Auth/hooks';
import '@gear-js/vara-ui/dist/style.css';

function AppComponent() {
const { isApiReady } = useApi();
const { isAccountReady, account } = useAccount();
const { state: game, isStateRead } = useGameState();
const { isAccountReady } = useAccount();
const { isAvailableBalanceReady } = useAccountAvailableBalance();
const { isAuthReady } = useAuth();
const setCurrentGame = useSetAtom(CURRENT_GAME);
const setIsCurrentRead = useSetAtom(IS_CURRENT_GAME_READ_ATOM);

useEffect(() => {
if (isAccountReady && account?.decodedAddress && isStateRead) {
setCurrentGame(game.Game);
setIsCurrentRead(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [account?.decodedAddress, isAccountReady, isStateRead]);

const isAppReady = isApiReady && isAccountReady && isAvailableBalanceReady && isAuthReady;

Expand Down
1 change: 1 addition & 0 deletions frontend/apps/racing-car-game/src/app/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sails';
2 changes: 2 additions & 0 deletions frontend/apps/racing-car-game/src/app/utils/sails/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './sails';
export * from './lib';
Loading

0 comments on commit f80c9ca

Please sign in to comment.