diff --git a/apps/ligretto-frontend/src/containers/app/AppContainer.tsx b/apps/ligretto-frontend/src/app/AppContainer.tsx similarity index 64% rename from apps/ligretto-frontend/src/containers/app/AppContainer.tsx rename to apps/ligretto-frontend/src/app/AppContainer.tsx index 55290d7e..fc831170 100644 --- a/apps/ligretto-frontend/src/containers/app/AppContainer.tsx +++ b/apps/ligretto-frontend/src/app/AppContainer.tsx @@ -1,10 +1,9 @@ -import React from 'react' import { useSelector } from 'react-redux' -import { useMinTimeLoading } from 'hooks/useMinTimeLoader' -import { Routes } from 'components/routes' +import { useMinTimeLoading } from 'shared/lib/hooks/useMinTimeLoader' +import { LoaderScreen } from 'shared/ui/screens/LoaderScreen' import { isUserLoadingSelector } from 'ducks/auth' -import { LoaderScreen } from 'components/screens/LoaderScreen' +import { Routes } from './routes' export const AppContainer = () => { const isUserLoading = useSelector(isUserLoadingSelector) diff --git a/apps/ligretto-frontend/src/containers/AuthContainer/AuthContainer.tsx b/apps/ligretto-frontend/src/app/AuthContainer.tsx similarity index 78% rename from apps/ligretto-frontend/src/containers/AuthContainer/AuthContainer.tsx rename to apps/ligretto-frontend/src/app/AuthContainer.tsx index 0169d787..11c25cfb 100644 --- a/apps/ligretto-frontend/src/containers/AuthContainer/AuthContainer.tsx +++ b/apps/ligretto-frontend/src/app/AuthContainer.tsx @@ -4,14 +4,14 @@ import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router' import { ThemeProvider } from '@memebattle/ui' -import { MainLayout } from 'components/layouts/main' -import { LigrettoLogo } from 'components/LigrettoLogo' -import { routes } from 'utils/constants' +import { MainLayout } from 'shared/ui/layouts/main' +import { LigrettoLogo } from 'shared/ui/LigrettoLogo' +import { routes } from 'shared/constants' import { getMeRequest } from 'ducks/auth/authActions' import { tokenSelector } from 'ducks/auth' -import { ligrettoAuthTheme } from '../../themes/ligrettoAuth' +import { ligrettoAuthTheme } from './themes/ligrettoAuth' -import { CAS_STATIC_URL, CAS_PARTNER_ID, CAS_URL } from 'config' +import { CAS_STATIC_URL, CAS_PARTNER_ID, CAS_URL } from 'shared/constants/config' export const AuthContainer = () => { const dispatch = useDispatch() diff --git a/apps/ligretto-frontend/src/components/routes/Routes.tsx b/apps/ligretto-frontend/src/app/routes/Routes.tsx similarity index 57% rename from apps/ligretto-frontend/src/components/routes/Routes.tsx rename to apps/ligretto-frontend/src/app/routes/Routes.tsx index 975708dc..423918b0 100644 --- a/apps/ligretto-frontend/src/components/routes/Routes.tsx +++ b/apps/ligretto-frontend/src/app/routes/Routes.tsx @@ -1,15 +1,14 @@ -import React from 'react' import { Routes as ReactRouterRoutes, Route } from 'react-router-dom' import { HomePage } from 'pages/home/HomePage' -import { GamePage } from 'pages/game/GamePage' -import { AuthContainer } from 'containers/AuthContainer' -import { routes } from 'utils/constants' +import { GamePageContainer } from 'pages/game/GamePageContainer' +import { AuthContainer } from '../AuthContainer' +import { routes } from 'shared/constants' export const Routes = () => ( } /> - } /> + } /> } /> ) diff --git a/apps/ligretto-frontend/src/components/routes/index.ts b/apps/ligretto-frontend/src/app/routes/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/routes/index.ts rename to apps/ligretto-frontend/src/app/routes/index.ts diff --git a/apps/ligretto-frontend/src/store/index.ts b/apps/ligretto-frontend/src/app/store/index.ts similarity index 92% rename from apps/ligretto-frontend/src/store/index.ts rename to apps/ligretto-frontend/src/app/store/index.ts index 453cc381..85bd46de 100644 --- a/apps/ligretto-frontend/src/store/index.ts +++ b/apps/ligretto-frontend/src/app/store/index.ts @@ -1,7 +1,7 @@ import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit' import createSagaMiddleware from 'redux-saga' -import { IS_DEV_MODE } from 'config' +import { IS_DEV_MODE } from 'shared/constants/config' import rootSaga from './rootSaga' import { routerMiddleware, createReduxHistory } from './reduxHistoryContext' diff --git a/apps/ligretto-frontend/src/store/reduxHistoryContext.ts b/apps/ligretto-frontend/src/app/store/reduxHistoryContext.ts similarity index 100% rename from apps/ligretto-frontend/src/store/reduxHistoryContext.ts rename to apps/ligretto-frontend/src/app/store/reduxHistoryContext.ts diff --git a/apps/ligretto-frontend/src/store/rootReducer.ts b/apps/ligretto-frontend/src/app/store/rootReducer.ts similarity index 100% rename from apps/ligretto-frontend/src/store/rootReducer.ts rename to apps/ligretto-frontend/src/app/store/rootReducer.ts diff --git a/apps/ligretto-frontend/src/store/rootSaga.ts b/apps/ligretto-frontend/src/app/store/rootSaga.ts similarity index 92% rename from apps/ligretto-frontend/src/store/rootSaga.ts rename to apps/ligretto-frontend/src/app/store/rootSaga.ts index 2a1d3c7f..8e062fee 100644 --- a/apps/ligretto-frontend/src/store/rootSaga.ts +++ b/apps/ligretto-frontend/src/app/store/rootSaga.ts @@ -1,6 +1,6 @@ import { all, fork, takeLatest } from 'redux-saga/effects' -import { socketSaga } from 'middlewares/saga' +import { socketSaga } from 'entities/socket' import { roomsRootSaga } from 'ducks/rooms' import { gameRootSaga } from 'ducks/game' import { usersRootSaga } from 'ducks/users' diff --git a/apps/ligretto-frontend/src/themes/default/index.ts b/apps/ligretto-frontend/src/app/themes/default/index.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/default/index.ts rename to apps/ligretto-frontend/src/app/themes/default/index.ts diff --git a/apps/ligretto-frontend/src/themes/default/palette.ts b/apps/ligretto-frontend/src/app/themes/default/palette.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/default/palette.ts rename to apps/ligretto-frontend/src/app/themes/default/palette.ts diff --git a/apps/ligretto-frontend/src/themes/default/theme.ts b/apps/ligretto-frontend/src/app/themes/default/theme.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/default/theme.ts rename to apps/ligretto-frontend/src/app/themes/default/theme.ts diff --git a/apps/ligretto-frontend/src/themes/ligrettoAuth/index.ts b/apps/ligretto-frontend/src/app/themes/ligrettoAuth/index.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/ligrettoAuth/index.ts rename to apps/ligretto-frontend/src/app/themes/ligrettoAuth/index.ts diff --git a/apps/ligretto-frontend/src/themes/ligrettoAuth/ligrettoAuthTheme.ts b/apps/ligretto-frontend/src/app/themes/ligrettoAuth/ligrettoAuthTheme.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/ligrettoAuth/ligrettoAuthTheme.ts rename to apps/ligretto-frontend/src/app/themes/ligrettoAuth/ligrettoAuthTheme.ts diff --git a/apps/ligretto-frontend/src/themes/ligrettoAuth/palette.ts b/apps/ligretto-frontend/src/app/themes/ligrettoAuth/palette.ts similarity index 100% rename from apps/ligretto-frontend/src/themes/ligrettoAuth/palette.ts rename to apps/ligretto-frontend/src/app/themes/ligrettoAuth/palette.ts diff --git a/apps/ligretto-frontend/src/components/Avatar/getRandomAvatar.spec.ts b/apps/ligretto-frontend/src/components/Avatar/getRandomAvatar.spec.ts deleted file mode 100644 index 05bb3517..00000000 --- a/apps/ligretto-frontend/src/components/Avatar/getRandomAvatar.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { getRandomAvatar } from './getRandomAvatar' - -describe('Avatar:getRandomAvatar', () => { - it.each([ - { id: '1', expected: '/src/components/Avatar/assets/u2.svg' }, - { id: '2', expected: '/src/components/Avatar/assets/u3.svg' }, - { - id: '7', - expected: '/src/components/Avatar/assets/u8.svg', - }, - { id: 'a', expected: '/src/components/Avatar/assets/u2.svg' }, - { id: 'b', expected: '/src/components/Avatar/assets/u3.svg' }, - { id: 'c', expected: '/src/components/Avatar/assets/u4.svg' }, - { id: 'd', expected: '/src/components/Avatar/assets/u5.svg' }, - { id: 'e', expected: '/src/components/Avatar/assets/u6.svg' }, - { id: 'f', expected: '/src/components/Avatar/assets/u7.svg' }, - { id: 'g', expected: '/src/components/Avatar/assets/u8.svg' }, - { id: 'h', expected: '/src/components/Avatar/assets/u1.svg' }, - { id: '', expected: '/src/components/Avatar/assets/u1.svg' }, - { id: undefined, expected: '/src/components/Avatar/assets/u1.svg' }, - ])('Should return correct avatar for ids', ({ id, expected }) => { - expect(getRandomAvatar(id)).toBe(expected) - }) -}) diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardPlace/index.ts b/apps/ligretto-frontend/src/components/blocks/game/CardPlace/index.ts deleted file mode 100644 index f8d43301..00000000 --- a/apps/ligretto-frontend/src/components/blocks/game/CardPlace/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { CardPlace } from './CardPlace' -export type { CardPlaceProps } from './CardPlace' diff --git a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/index.ts b/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/index.ts deleted file mode 100644 index b7cf674a..00000000 --- a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PlayersScoresTable } from './PlayersScoresTable' diff --git a/apps/ligretto-frontend/src/components/blocks/game/index.ts b/apps/ligretto-frontend/src/components/blocks/game/index.ts deleted file mode 100644 index 529bf785..00000000 --- a/apps/ligretto-frontend/src/components/blocks/game/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { Playground } from './playground' -export { Stack } from './stack' diff --git a/apps/ligretto-frontend/src/components/blocks/game/playground/index.ts b/apps/ligretto-frontend/src/components/blocks/game/playground/index.ts deleted file mode 100644 index 4f10641b..00000000 --- a/apps/ligretto-frontend/src/components/blocks/game/playground/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Playground } from './Playground' diff --git a/apps/ligretto-frontend/src/components/blocks/game/stack/index.ts b/apps/ligretto-frontend/src/components/blocks/game/stack/index.ts deleted file mode 100644 index f0536fbb..00000000 --- a/apps/ligretto-frontend/src/components/blocks/game/stack/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Stack } from './Stack' diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsManager/index.ts b/apps/ligretto-frontend/src/components/blocks/home/RoomsManager/index.ts deleted file mode 100644 index 2d50687c..00000000 --- a/apps/ligretto-frontend/src/components/blocks/home/RoomsManager/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { RoomsManager } from './RoomsManager' diff --git a/apps/ligretto-frontend/src/components/blocks/home/UserInfo/index.ts b/apps/ligretto-frontend/src/components/blocks/home/UserInfo/index.ts deleted file mode 100644 index 6e4af5ad..00000000 --- a/apps/ligretto-frontend/src/components/blocks/home/UserInfo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './UserInfo' diff --git a/apps/ligretto-frontend/src/containers/AuthContainer/index.ts b/apps/ligretto-frontend/src/containers/AuthContainer/index.ts deleted file mode 100644 index 0d52cc6c..00000000 --- a/apps/ligretto-frontend/src/containers/AuthContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './AuthContainer' diff --git a/apps/ligretto-frontend/src/containers/CreateRoomContainer/index.ts b/apps/ligretto-frontend/src/containers/CreateRoomContainer/index.ts deleted file mode 100644 index ab35522e..00000000 --- a/apps/ligretto-frontend/src/containers/CreateRoomContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { CreateRoomContainer } from './CreateRoomContainer' diff --git a/apps/ligretto-frontend/src/containers/GamePageContainer/GamePageContainer.tsx b/apps/ligretto-frontend/src/containers/GamePageContainer/GamePageContainer.tsx deleted file mode 100644 index a5d9a957..00000000 --- a/apps/ligretto-frontend/src/containers/GamePageContainer/GamePageContainer.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react' -import { useSelector } from 'react-redux' -import { createSelector } from '@reduxjs/toolkit' -import { GameStatus } from '@memebattle/ligretto-shared' - -import { ScreenCountdown } from 'components/blocks/game/ScreenCountdown' - -import { GameGrid } from 'components/blocks/game/GameGrid' -import { PlaygroundContainer } from 'containers/playground' -import { CardsPanelContainer } from 'containers/CardsPanelContainer' -import { Opponent } from 'components/blocks/game/opponent' -import { gameStatusSelector, isGameLoadedSelector, isPlayerSpectatorSelector, startingDelayInSecSelector, opponentsSelector } from 'ducks/game' -import { GameSettingsModal } from 'components/blocks/game/GameSettingsModal/GameSettingsModal' - -const gamePageContainerSelector = createSelector( - [gameStatusSelector, isGameLoadedSelector, isPlayerSpectatorSelector, startingDelayInSecSelector, opponentsSelector], - (gameStatus, isGameLoaded, isPlayerSpectator, startingDelayInSec, opponents) => ({ - gameStatus, - isGameLoaded, - isPlayerSpectator, - startingDelayInSec, - opponents, - }), -) -export const GamePageContainer = () => { - const { gameStatus, isGameLoaded, isPlayerSpectator, startingDelayInSec, opponents } = useSelector(gamePageContainerSelector) - - if (!isGameLoaded) { - return <>loading - } - - return ( - <> - {gameStatus === GameStatus.Starting && } - } bottomElement={isPlayerSpectator ? null : }> - {opponents.map(opponent => ( - - ))} - - - - ) -} diff --git a/apps/ligretto-frontend/src/containers/GamePageContainer/index.ts b/apps/ligretto-frontend/src/containers/GamePageContainer/index.ts deleted file mode 100644 index 358ba155..00000000 --- a/apps/ligretto-frontend/src/containers/GamePageContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { GamePageContainer } from './GamePageContainer' diff --git a/apps/ligretto-frontend/src/containers/GameSettings/index.ts b/apps/ligretto-frontend/src/containers/GameSettings/index.ts deleted file mode 100644 index 90c90cb0..00000000 --- a/apps/ligretto-frontend/src/containers/GameSettings/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { GameSettingsContainer } from './GameSettingsContainer' diff --git a/apps/ligretto-frontend/src/containers/PlayersScoresTable/index.ts b/apps/ligretto-frontend/src/containers/PlayersScoresTable/index.ts deleted file mode 100644 index 47a98e40..00000000 --- a/apps/ligretto-frontend/src/containers/PlayersScoresTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PlayersScoresTableContainer } from './PlayersScoresTableContainer' diff --git a/apps/ligretto-frontend/src/containers/RoomsListContainer/index.ts b/apps/ligretto-frontend/src/containers/RoomsListContainer/index.ts deleted file mode 100644 index eb0268d8..00000000 --- a/apps/ligretto-frontend/src/containers/RoomsListContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { RoomsListContainer } from './RoomsListContainer' diff --git a/apps/ligretto-frontend/src/containers/SearchRoomsContainer/index.ts b/apps/ligretto-frontend/src/containers/SearchRoomsContainer/index.ts deleted file mode 100644 index edeeeac0..00000000 --- a/apps/ligretto-frontend/src/containers/SearchRoomsContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { RoomsListContainer } from '../RoomsListContainer/RoomsListContainer' diff --git a/apps/ligretto-frontend/src/containers/app/index.ts b/apps/ligretto-frontend/src/containers/app/index.ts deleted file mode 100644 index f4443780..00000000 --- a/apps/ligretto-frontend/src/containers/app/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './AppContainer' diff --git a/apps/ligretto-frontend/src/containers/cards-row/index.ts b/apps/ligretto-frontend/src/containers/cards-row/index.ts deleted file mode 100644 index 21fd5468..00000000 --- a/apps/ligretto-frontend/src/containers/cards-row/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { CardsRowContainer } from './CardsRowContainer' diff --git a/apps/ligretto-frontend/src/containers/main-page/index.ts b/apps/ligretto-frontend/src/containers/main-page/index.ts deleted file mode 100644 index 21ccff3c..00000000 --- a/apps/ligretto-frontend/src/containers/main-page/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './UserInfoContainer' diff --git a/apps/ligretto-frontend/src/containers/playground/index.ts b/apps/ligretto-frontend/src/containers/playground/index.ts deleted file mode 100644 index 116d8c5d..00000000 --- a/apps/ligretto-frontend/src/containers/playground/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PlaygroundContainer } from './PlaygroundContainer' diff --git a/apps/ligretto-frontend/src/containers/stack/index.ts b/apps/ligretto-frontend/src/containers/stack/index.ts deleted file mode 100644 index 481078bb..00000000 --- a/apps/ligretto-frontend/src/containers/stack/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { StackContainer } from './StackContainer' diff --git a/apps/ligretto-frontend/src/ducks/analytics/analytics.ts b/apps/ligretto-frontend/src/ducks/analytics/analytics.ts index e0aab10e..a8c07447 100644 --- a/apps/ligretto-frontend/src/ducks/analytics/analytics.ts +++ b/apps/ligretto-frontend/src/ducks/analytics/analytics.ts @@ -1,4 +1,4 @@ import { Analytics } from '@memebattle/analytics' -import { AMPLITUDE_TOKEN } from 'config' +import { AMPLITUDE_TOKEN } from 'shared/constants/config' export const analytics = new Analytics({ apiKey: AMPLITUDE_TOKEN }) diff --git a/apps/ligretto-frontend/src/ducks/game/sagas.ts b/apps/ligretto-frontend/src/ducks/game/sagas.ts index 3e3b29a1..0cb0ddc8 100644 --- a/apps/ligretto-frontend/src/ducks/game/sagas.ts +++ b/apps/ligretto-frontend/src/ducks/game/sagas.ts @@ -30,9 +30,9 @@ import { import { gameIdSelector, isDndEnabledSelector, playerStatusSelector, selectedCardIndexSelector, selectPlayerCardByIndex } from './selectors' import { STACK_OPEN_DECK_INDEX } from './utils' import { matchPath } from 'react-router-dom' -import { routes } from 'utils/constants' +import { routes } from 'shared/constants' import { LOCATION_CHANGE, push } from 'redux-first-history' -import { socketConnectedAction } from 'middlewares/saga/actions' +import { socketConnectedAction } from 'entities/socket' import { locationSelector } from 'ducks/router' import { connectToRoomAction } from 'ducks/rooms' diff --git a/apps/ligretto-frontend/src/ducks/rooms/sagas.ts b/apps/ligretto-frontend/src/ducks/rooms/sagas.ts index ae240ec6..e501cdc0 100644 --- a/apps/ligretto-frontend/src/ducks/rooms/sagas.ts +++ b/apps/ligretto-frontend/src/ducks/rooms/sagas.ts @@ -13,7 +13,7 @@ import { import { replace, push } from 'redux-first-history' import { generatePath } from 'react-router-dom' -import { routes } from 'utils/constants' +import { routes } from 'shared/constants' import { connectToRoomAction, createRoomAction, getRoomsAction, updateRoomsAction, setErrorRoomsAction, removeRoomAction } from './slice' diff --git a/apps/ligretto-frontend/src/ducks/users/usersSagas.ts b/apps/ligretto-frontend/src/ducks/users/usersSagas.ts index 560418ae..fb40f7d3 100644 --- a/apps/ligretto-frontend/src/ducks/users/usersSagas.ts +++ b/apps/ligretto-frontend/src/ducks/users/usersSagas.ts @@ -3,8 +3,8 @@ import type { SagaIterator } from 'redux-saga' import type { AxiosResponse } from 'axios' import { connectToRoomSuccessAction, userJoinToRoomAction } from '@memebattle/ligretto-shared' -import { getMe, getUsersByIds } from 'api' -import type { GetMeResponse, GetUsersResponse } from 'api' +import { getMe, getUsersByIds } from 'shared/api' +import type { GetMeResponse, GetUsersResponse } from 'shared/api' import { addUser, addUsers } from './usersActions' import type { User } from './usersTypes' diff --git a/apps/ligretto-frontend/src/ducks/users/usersTypes.ts b/apps/ligretto-frontend/src/ducks/users/usersTypes.ts index 13667bcd..c7f59254 100644 --- a/apps/ligretto-frontend/src/ducks/users/usersTypes.ts +++ b/apps/ligretto-frontend/src/ducks/users/usersTypes.ts @@ -1,4 +1,4 @@ -import type { UserModel } from 'api/apiTypes' +import type { UserModel } from 'shared/api/apiTypes' export type User = UserModel & { isLoading?: boolean diff --git a/apps/ligretto-frontend/src/hooks/useAnalytics/index.ts b/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/index.ts similarity index 100% rename from apps/ligretto-frontend/src/hooks/useAnalytics/index.ts rename to apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/index.ts diff --git a/apps/ligretto-frontend/src/hooks/useAnalytics/useAnalytics.ts b/apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/useAnalytics.ts similarity index 100% rename from apps/ligretto-frontend/src/hooks/useAnalytics/useAnalytics.ts rename to apps/ligretto-frontend/src/entities/analytics/model/useAnalytics/useAnalytics.ts diff --git a/apps/ligretto-frontend/src/entities/card/index.ts b/apps/ligretto-frontend/src/entities/card/index.ts new file mode 100644 index 00000000..c0088b1a --- /dev/null +++ b/apps/ligretto-frontend/src/entities/card/index.ts @@ -0,0 +1,5 @@ +export { Card } from './ui/Card' +export { CardPlace } from './ui/CardPlace' +export { CardHotkeyBadge } from './ui/CardHotkeyBadge' +export { CardsStack } from './ui/CardsStack' +export { LigrettoPack } from 'features/player' diff --git a/apps/ligretto-frontend/src/components/blocks/game/Card/Card.stories.tsx b/apps/ligretto-frontend/src/entities/card/ui/Card/Card.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/Card/Card.stories.tsx rename to apps/ligretto-frontend/src/entities/card/ui/Card/Card.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/Card/Card.tsx b/apps/ligretto-frontend/src/entities/card/ui/Card/Card.tsx similarity index 98% rename from apps/ligretto-frontend/src/components/blocks/game/Card/Card.tsx rename to apps/ligretto-frontend/src/entities/card/ui/Card/Card.tsx index 5923cdfb..7def0b2e 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/Card/Card.tsx +++ b/apps/ligretto-frontend/src/entities/card/ui/Card/Card.tsx @@ -3,7 +3,7 @@ import { CardColors } from '@memebattle/ligretto-shared' import { ButtonBase } from '@mui/material' import { Typography, useOnClickOutside } from '@memebattle/ui' import { styled } from '@mui/material/styles' -import type { CardPlaceSize } from 'components/blocks/game/CardPlace/CardPlace' +import type { CardPlaceSize } from '../CardPlace' type CardSize = 'small' | 'medium' | 'large' diff --git a/apps/ligretto-frontend/src/components/blocks/game/Card/index.ts b/apps/ligretto-frontend/src/entities/card/ui/Card/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/Card/index.ts rename to apps/ligretto-frontend/src/entities/card/ui/Card/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/CardHotkeyBadge.stories.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/CardHotkeyBadge.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/CardHotkeyBadge.stories.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/CardHotkeyBadge.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/CardHotkeyBadge.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/CardHotkeyBadge.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/CardHotkeyBadge.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/CardHotkeyBadge.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/index.ts b/apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardHotkeyBadge/index.ts rename to apps/ligretto-frontend/src/entities/card/ui/CardHotkeyBadge/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardPlace/CardPlace.stories.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardPlace/CardPlace.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardPlace/CardPlace.stories.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardPlace/CardPlace.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardPlace/CardPlace.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardPlace/CardPlace.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardPlace/CardPlace.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardPlace/CardPlace.tsx diff --git a/apps/ligretto-frontend/src/entities/card/ui/CardPlace/index.ts b/apps/ligretto-frontend/src/entities/card/ui/CardPlace/index.ts new file mode 100644 index 00000000..57ea76e4 --- /dev/null +++ b/apps/ligretto-frontend/src/entities/card/ui/CardPlace/index.ts @@ -0,0 +1,2 @@ +export { CardPlace } from './CardPlace' +export type { CardPlaceProps, CardPlaceSize } from './CardPlace' diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsRow/CardsRow.stories.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardsRow/CardsRow.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardsRow/CardsRow.stories.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardsRow/CardsRow.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsRow/CardsRow.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardsRow/CardsRow.tsx similarity index 94% rename from apps/ligretto-frontend/src/components/blocks/game/CardsRow/CardsRow.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardsRow/CardsRow.tsx index bab06cdd..9a2bd27a 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/CardsRow/CardsRow.tsx +++ b/apps/ligretto-frontend/src/entities/card/ui/CardsRow/CardsRow.tsx @@ -1,5 +1,4 @@ import type { ReactNode } from 'react' -import React from 'react' import { Stack, useMediaQuery, useTheme } from '@memebattle/ui' export const CardsRow = ({ children }: { children: ReactNode }) => { diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsRow/index.ts b/apps/ligretto-frontend/src/entities/card/ui/CardsRow/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardsRow/index.ts rename to apps/ligretto-frontend/src/entities/card/ui/CardsRow/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/stack/Stack.tsx b/apps/ligretto-frontend/src/entities/card/ui/CardsStack/CardsStack.tsx similarity index 80% rename from apps/ligretto-frontend/src/components/blocks/game/stack/Stack.tsx rename to apps/ligretto-frontend/src/entities/card/ui/CardsStack/CardsStack.tsx index 123c5958..e6db9f65 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/stack/Stack.tsx +++ b/apps/ligretto-frontend/src/entities/card/ui/CardsStack/CardsStack.tsx @@ -1,12 +1,12 @@ import React from 'react' import type { Card as PlayerCard } from '@memebattle/ligretto-shared' import { Hotkey } from 'ducks/game' -import { CardsRow } from 'components/blocks/game/CardsRow' -import { CardPlace } from 'components/blocks/game/CardPlace' -import { Card } from 'components/blocks/game/Card' -import { CardHotkeyBadge } from 'components/blocks/game/CardHotkeyBadge' +import { CardsRow } from '../CardsRow' +import { Card } from '../Card' +import { CardHotkeyBadge } from '../CardHotkeyBadge' +import { CardPlace } from '../CardPlace' -export interface StackProps { +export interface CardsStackProps { stackOpenDeckCard?: PlayerCard stackDeckCards: PlayerCard[] onStackOpenDeckCardClick: () => void @@ -17,7 +17,7 @@ export interface StackProps { isStackOpenDeckDarkened: boolean } -export const Stack: React.FC = ({ +export const CardsStack: React.FC = ({ stackOpenDeckCard, stackDeckCards, onStackOpenDeckCardClick, diff --git a/apps/ligretto-frontend/src/entities/card/ui/CardsStack/index.ts b/apps/ligretto-frontend/src/entities/card/ui/CardsStack/index.ts new file mode 100644 index 00000000..4ed1e62d --- /dev/null +++ b/apps/ligretto-frontend/src/entities/card/ui/CardsStack/index.ts @@ -0,0 +1 @@ +export { CardsStack } from './CardsStack' diff --git a/apps/ligretto-frontend/src/entities/socket/index.ts b/apps/ligretto-frontend/src/entities/socket/index.ts new file mode 100644 index 00000000..e071d378 --- /dev/null +++ b/apps/ligretto-frontend/src/entities/socket/index.ts @@ -0,0 +1,2 @@ +export { socketSaga } from './model/socket-saga' +export { socketConnectedAction } from './model/actions' diff --git a/apps/ligretto-frontend/src/entities/socket/model/actions.ts b/apps/ligretto-frontend/src/entities/socket/model/actions.ts new file mode 100644 index 00000000..6250d374 --- /dev/null +++ b/apps/ligretto-frontend/src/entities/socket/model/actions.ts @@ -0,0 +1,2 @@ +import { createAction } from '@reduxjs/toolkit' +export const socketConnectedAction = createAction('@@socket/SOCKET_CONNECTED') diff --git a/apps/ligretto-frontend/src/middlewares/saga/socket-middleware.ts b/apps/ligretto-frontend/src/entities/socket/model/socket-saga.ts similarity index 96% rename from apps/ligretto-frontend/src/middlewares/saga/socket-middleware.ts rename to apps/ligretto-frontend/src/entities/socket/model/socket-saga.ts index 626ff7e4..b95c9972 100644 --- a/apps/ligretto-frontend/src/middlewares/saga/socket-middleware.ts +++ b/apps/ligretto-frontend/src/entities/socket/model/socket-saga.ts @@ -7,7 +7,7 @@ import type { Socket } from 'socket.io-client' import { LOCAL_STORAGE_TOKEN_KEY } from 'ducks/auth/constants' -import { LIGRETTO_GAMEPLAY_URL } from '../../config' +import { LIGRETTO_GAMEPLAY_URL } from 'shared/constants/config' import { socketConnectedAction } from './actions' function socketChannel(socket: Socket): EventChannel { diff --git a/apps/ligretto-frontend/src/features/create-room/index.ts b/apps/ligretto-frontend/src/features/create-room/index.ts new file mode 100644 index 00000000..f1a7a5b6 --- /dev/null +++ b/apps/ligretto-frontend/src/features/create-room/index.ts @@ -0,0 +1 @@ +export { CreateRoomContainer } from './ui/CreateRoomContainer' diff --git a/apps/ligretto-frontend/src/containers/CreateRoomContainer/utils.ts b/apps/ligretto-frontend/src/features/create-room/model/roomNameValidator.ts similarity index 100% rename from apps/ligretto-frontend/src/containers/CreateRoomContainer/utils.ts rename to apps/ligretto-frontend/src/features/create-room/model/roomNameValidator.ts diff --git a/apps/ligretto-frontend/src/containers/CreateRoomContainer/CreateRoomContainer.tsx b/apps/ligretto-frontend/src/features/create-room/ui/CreateRoomContainer.tsx similarity index 93% rename from apps/ligretto-frontend/src/containers/CreateRoomContainer/CreateRoomContainer.tsx rename to apps/ligretto-frontend/src/features/create-room/ui/CreateRoomContainer.tsx index 4a71ef6d..0e4d096f 100644 --- a/apps/ligretto-frontend/src/containers/CreateRoomContainer/CreateRoomContainer.tsx +++ b/apps/ligretto-frontend/src/features/create-room/ui/CreateRoomContainer.tsx @@ -4,8 +4,8 @@ import type { CreateRoomError } from '@memebattle/ligretto-shared/src/dto' import { createRoomAction, roomsErrorSelector } from 'ducks/rooms' -import { roomNameValidation } from './utils' -import { InputWithButton } from 'components/InputWithButton' +import { roomNameValidation } from '../model/roomNameValidator' +import { InputWithButton } from 'shared/ui/InputWithButton' import { Typography } from '@memebattle/ui' export const CreateRoomContainer = () => { diff --git a/apps/ligretto-frontend/src/features/player-scores-table/index.ts b/apps/ligretto-frontend/src/features/player-scores-table/index.ts new file mode 100644 index 00000000..cc9dff1a --- /dev/null +++ b/apps/ligretto-frontend/src/features/player-scores-table/index.ts @@ -0,0 +1 @@ +export { PlayersScoresTableContainer } from './ui/PlayersScoresTableContainer' diff --git a/apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTable.selectors.ts b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.selectors.ts similarity index 88% rename from apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTable.selectors.ts rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.selectors.ts index 4eb6eaf0..9b957201 100644 --- a/apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTable.selectors.ts +++ b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.selectors.ts @@ -1,11 +1,11 @@ import { createSelector } from '@reduxjs/toolkit' import orderBy from 'lodash/orderBy' -import { buildCasStaticUrl } from 'utils/buildCasStaticUrl' +import { buildCasStaticUrl } from 'shared/api/buildCasStaticUrl' import { gameResultsSelector, playersIdsSelector } from 'ducks/game' import { usersMapSelector } from 'ducks/users' import { currentUserIdSelector } from 'ducks/auth' -import { getRandomAvatar } from 'components/Avatar/getRandomAvatar' +import { getRandomAvatar } from 'shared/ui/Avatar/getRandomAvatar' export const playersSelector = createSelector( [playersIdsSelector, gameResultsSelector, usersMapSelector, currentUserIdSelector], diff --git a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTable.tsx b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.tsx similarity index 98% rename from apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTable.tsx rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.tsx index c8cc112f..39322478 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTable.tsx +++ b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTable.tsx @@ -1,7 +1,7 @@ import type { FC } from 'react' import last from 'lodash/last' import { Box, Grid, Typography, useMediaQuery, useTheme } from '@memebattle/ui' -import { Avatar } from 'components/Avatar' +import { Avatar } from 'shared/ui/Avatar' import { PlayersScoresTableCell } from './PlayersScoresTableCell' import { PlayersScoresTableHead } from './PlayersScoresTableHead' diff --git a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableCell.tsx b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableCell.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableCell.tsx rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableCell.tsx diff --git a/apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTableContainer.tsx b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableContainer.tsx similarity index 78% rename from apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTableContainer.tsx rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableContainer.tsx index 43697a76..4c96e914 100644 --- a/apps/ligretto-frontend/src/containers/PlayersScoresTable/PlayersScoresTableContainer.tsx +++ b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableContainer.tsx @@ -1,7 +1,7 @@ import React from 'react' import { useSelector } from 'react-redux' -import { PlayersScoresTable } from 'components/blocks/game/PlayersScoresTable' +import { PlayersScoresTable } from './PlayersScoresTable' import { playersSelector } from './PlayersScoresTable.selectors' export const PlayersScoresTableContainer = () => { diff --git a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableHead.tsx b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableHead.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableHead.tsx rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableHead.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableRow.tsx b/apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableRow.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/PlayersScoresTable/PlayersScoresTableRow.tsx rename to apps/ligretto-frontend/src/features/player-scores-table/ui/PlayersScoresTableRow.tsx diff --git a/apps/ligretto-frontend/src/features/player/index.ts b/apps/ligretto-frontend/src/features/player/index.ts new file mode 100644 index 00000000..8f84694a --- /dev/null +++ b/apps/ligretto-frontend/src/features/player/index.ts @@ -0,0 +1,3 @@ +export { Opponent } from './ui/Opponent' +export { CardsPanelContainer } from './ui/CardsPanelContainer' +export { LigrettoPack } from './ui/LigrettoPack' diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.stories.tsx b/apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.stories.tsx similarity index 94% rename from apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.stories.tsx rename to apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.stories.tsx index 08c310b7..8f7dced7 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.stories.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.stories.tsx @@ -2,7 +2,7 @@ import { CardsPanel } from './CardsPanel' import type { Meta, StoryFn } from '@storybook/react' import { PlayerStatus } from '@memebattle/ligretto-shared' import { Provider } from 'react-redux' -import { store } from 'store' +import { store } from 'app/store' export default { component: CardsPanel, diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.tsx b/apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.tsx similarity index 72% rename from apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.tsx rename to apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.tsx index de76322f..07eb36ba 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/CardsPanel/CardsPanel.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/CardsPanel/CardsPanel.tsx @@ -1,11 +1,11 @@ import type { FC } from 'react' import { PlayerStatus } from '@memebattle/ligretto-shared' -import { CardsRowContainer } from 'containers/cards-row' -import { StackContainer } from 'containers/stack' -import { LigrettoDeckContainer } from 'containers/ligretto-deck/LigrettoDeckContainer' +import { PlayerCardsStack } from 'features/player/ui/PlayerCardsStack' +import { LigrettoDeckContainer } from '../LigrettoDeckContainer' import { Stack, useMediaQuery, useTheme, Box } from '@memebattle/ui' +import { PlayerRowCardsContainer } from '../PlayerRowCardsContainer' import { Player } from '../Player' export interface CardsPanelProps { @@ -19,12 +19,12 @@ export interface CardsPanelProps { const CardsPanelMobile = () => ( - + - + @@ -42,7 +42,7 @@ export const CardsPanel: FC = ({ player }) => { return ( - {player?.status === PlayerStatus.InGame ? [, , ] : null} + {player?.status === PlayerStatus.InGame ? [, , ] : null} {player ? : null} diff --git a/apps/ligretto-frontend/src/components/blocks/game/CardsPanel/index.ts b/apps/ligretto-frontend/src/features/player/ui/CardsPanel/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/CardsPanel/index.ts rename to apps/ligretto-frontend/src/features/player/ui/CardsPanel/index.ts diff --git a/apps/ligretto-frontend/src/containers/CardsPanelContainer/CardsPanelContainer.tsx b/apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/CardsPanelContainer.tsx similarity index 84% rename from apps/ligretto-frontend/src/containers/CardsPanelContainer/CardsPanelContainer.tsx rename to apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/CardsPanelContainer.tsx index 294e2b30..b7409d7e 100644 --- a/apps/ligretto-frontend/src/containers/CardsPanelContainer/CardsPanelContainer.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/CardsPanelContainer.tsx @@ -2,11 +2,13 @@ import React, { useMemo } from 'react' import { useSelector } from 'react-redux' import { createSelector } from '@reduxjs/toolkit' -import { CardsPanel } from 'components/blocks/game/CardsPanel' import { playerLigrettoDeckCardsSelector, activePlayerSelector, isDndEnabledSelector } from 'ducks/game' -import { buildCasStaticUrl } from 'utils/buildCasStaticUrl' +import { buildCasStaticUrl } from 'shared/api/buildCasStaticUrl' +import { getRandomAvatar } from 'shared/ui/Avatar/getRandomAvatar' + +import { CardsPanel } from '../CardsPanel' + import { usePanelHotkeys } from './usePanelHotkeys' -import { getRandomAvatar } from 'components/Avatar/getRandomAvatar' const cardsPanelContainerSelector = createSelector( [activePlayerSelector, playerLigrettoDeckCardsSelector, isDndEnabledSelector], diff --git a/apps/ligretto-frontend/src/containers/CardsPanelContainer/index.ts b/apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/index.ts similarity index 100% rename from apps/ligretto-frontend/src/containers/CardsPanelContainer/index.ts rename to apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/index.ts diff --git a/apps/ligretto-frontend/src/containers/CardsPanelContainer/usePanelHotkeys.ts b/apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/usePanelHotkeys.ts similarity index 100% rename from apps/ligretto-frontend/src/containers/CardsPanelContainer/usePanelHotkeys.ts rename to apps/ligretto-frontend/src/features/player/ui/CardsPanelContainer/usePanelHotkeys.ts diff --git a/apps/ligretto-frontend/src/containers/ligretto-deck/LigrettoDeckContainer.tsx b/apps/ligretto-frontend/src/features/player/ui/LigrettoDeckContainer.tsx similarity index 92% rename from apps/ligretto-frontend/src/containers/ligretto-deck/LigrettoDeckContainer.tsx rename to apps/ligretto-frontend/src/features/player/ui/LigrettoDeckContainer.tsx index 926d660b..77f3a1cb 100644 --- a/apps/ligretto-frontend/src/containers/ligretto-deck/LigrettoDeckContainer.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/LigrettoDeckContainer.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react' import { useDispatch, useSelector } from 'react-redux' import { isDndEnabledSelector, tapLigrettoDeckCardAction, playerLigrettoDeckCardsSelector } from 'ducks/game' -import { LigrettoPack } from 'components/blocks/game/ligretto-pack' +import { LigrettoPack } from 'entities/card' export const LigrettoDeckContainer = () => { const dispatch = useDispatch() diff --git a/apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/LigrettoPack.module.scss b/apps/ligretto-frontend/src/features/player/ui/LigrettoPack/LigrettoPack.module.scss similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/LigrettoPack.module.scss rename to apps/ligretto-frontend/src/features/player/ui/LigrettoPack/LigrettoPack.module.scss diff --git a/apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/LigrettoPack.tsx b/apps/ligretto-frontend/src/features/player/ui/LigrettoPack/LigrettoPack.tsx similarity index 86% rename from apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/LigrettoPack.tsx rename to apps/ligretto-frontend/src/features/player/ui/LigrettoPack/LigrettoPack.tsx index ae6a5fb4..f938a59e 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/LigrettoPack.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/LigrettoPack/LigrettoPack.tsx @@ -1,12 +1,11 @@ import React from 'react' import { Typography } from '@memebattle/ui' import type { Card as PlayerCards } from '@memebattle/ligretto-shared' -import { CardHotkeyBadge } from 'components/blocks/game/CardHotkeyBadge' -import styles from './LigrettoPack.module.scss' import { Hotkey } from 'ducks/game' -import { CardPlace } from '../CardPlace' -import { Card } from '../Card' +import { CardPlace, Card, CardHotkeyBadge } from 'entities/card' + +import styles from './LigrettoPack.module.scss' interface LigrettoPack { count: number diff --git a/apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/index.ts b/apps/ligretto-frontend/src/features/player/ui/LigrettoPack/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/ligretto-pack/index.ts rename to apps/ligretto-frontend/src/features/player/ui/LigrettoPack/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/opponent/Opponent.tsx b/apps/ligretto-frontend/src/features/player/ui/Opponent/Opponent.tsx similarity index 87% rename from apps/ligretto-frontend/src/components/blocks/game/opponent/Opponent.tsx rename to apps/ligretto-frontend/src/features/player/ui/Opponent/Opponent.tsx index 65b16b9d..e8010954 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/opponent/Opponent.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/Opponent/Opponent.tsx @@ -4,11 +4,10 @@ import type { Card as OpponentCard, UUID } from '@memebattle/ligretto-shared' import { PlayerStatus } from '@memebattle/ligretto-shared' import { Player } from '../Player' -import { Card } from '../Card' +import { Card, CardPlace } from 'entities/card' -import { buildCasStaticUrl } from 'utils/buildCasStaticUrl' -import { getRandomAvatar } from 'components/Avatar/getRandomAvatar' -import { CardPlace } from '../CardPlace' +import { buildCasStaticUrl } from 'shared/api/buildCasStaticUrl' +import { getRandomAvatar } from 'shared/ui/Avatar/getRandomAvatar' export interface OpponentCardsProps { stackOpenDeckCards: OpponentCard[] diff --git a/apps/ligretto-frontend/src/components/blocks/game/opponent/index.ts b/apps/ligretto-frontend/src/features/player/ui/Opponent/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/opponent/index.ts rename to apps/ligretto-frontend/src/features/player/ui/Opponent/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/Player/Player.stories.tsx b/apps/ligretto-frontend/src/features/player/ui/Player/Player.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/Player/Player.stories.tsx rename to apps/ligretto-frontend/src/features/player/ui/Player/Player.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/Player/Player.tsx b/apps/ligretto-frontend/src/features/player/ui/Player/Player.tsx similarity index 98% rename from apps/ligretto-frontend/src/components/blocks/game/Player/Player.tsx rename to apps/ligretto-frontend/src/features/player/ui/Player/Player.tsx index 9096403b..15fa1619 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/Player/Player.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/Player/Player.tsx @@ -2,10 +2,10 @@ import React from 'react' import History from '@mui/icons-material/History' import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline' import { PlayerStatus } from '@memebattle/ligretto-shared' - -import { Avatar } from 'components/Avatar' import { styled } from '@mui/material/styles' +import { Avatar } from 'shared/ui/Avatar' + import { useMediaQuery, useTheme } from '@memebattle/ui' interface CalcPlayerHeightParams { diff --git a/apps/ligretto-frontend/src/components/blocks/game/Player/index.ts b/apps/ligretto-frontend/src/features/player/ui/Player/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/Player/index.ts rename to apps/ligretto-frontend/src/features/player/ui/Player/index.ts diff --git a/apps/ligretto-frontend/src/containers/stack/StackContainer.selector.ts b/apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.selector.ts similarity index 90% rename from apps/ligretto-frontend/src/containers/stack/StackContainer.selector.ts rename to apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.selector.ts index e8182f03..25c37cdc 100644 --- a/apps/ligretto-frontend/src/containers/stack/StackContainer.selector.ts +++ b/apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.selector.ts @@ -2,7 +2,7 @@ import { createSelector } from '@reduxjs/toolkit' import { isDndEnabledSelector, playerStackDeckCardsSelector, playerStackOpenDeckCardsSelector, selectedCardIndexSelector } from 'ducks/game' -export const stackContainerSelector = createSelector( +export const playerCardsStackSelector = createSelector( [playerStackOpenDeckCardsSelector, playerStackDeckCardsSelector, isDndEnabledSelector, selectedCardIndexSelector], (stackOpenDeckCards, stackDeckCards, isDndEnabled, selectedCardIndex) => ({ stackOpenDeckCard: stackOpenDeckCards?.[stackOpenDeckCards.length - 1], diff --git a/apps/ligretto-frontend/src/containers/stack/StackContainer.tsx b/apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.tsx similarity index 84% rename from apps/ligretto-frontend/src/containers/stack/StackContainer.tsx rename to apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.tsx index a289cc96..ccb851c4 100644 --- a/apps/ligretto-frontend/src/containers/stack/StackContainer.tsx +++ b/apps/ligretto-frontend/src/features/player/ui/PlayerCardsStack/PlayerCardsStack.tsx @@ -1,13 +1,13 @@ import React, { useCallback } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { Stack } from 'components/blocks/game' +import { CardsStack } from 'entities/card' import { setSelectedCardIndexAction, STACK_OPEN_DECK_INDEX, tapStackDeckCardAction, tapStackOpenDeckCardAction } from 'ducks/game' -import { stackContainerSelector } from './StackContainer.selector' +import { playerCardsStackSelector } from './PlayerCardsStack.selector' -export const StackContainer = () => { +export const PlayerCardsStack = () => { const dispatch = useDispatch() - const { stackDeckCards, stackOpenDeckCard, isDndEnabled, selectedCardIndex } = useSelector(stackContainerSelector) + const { stackDeckCards, stackOpenDeckCard, isDndEnabled, selectedCardIndex } = useSelector(playerCardsStackSelector) const handleStackOpenDeckCardClick = useCallback(() => { dispatch(tapStackOpenDeckCardAction()) @@ -26,7 +26,7 @@ export const StackContainer = () => { } return ( - ({ playerCards, @@ -17,9 +15,9 @@ const CardsRowContainerSelector = createSelector( }), ) -export const CardsRowContainer = () => { +export const PlayerRowCardsContainer = () => { const dispatch = useDispatch() - const { playerCards, isDndEnabled, selectedCardIndex } = useSelector(CardsRowContainerSelector) + const { playerCards, isDndEnabled, selectedCardIndex } = useSelector(PlayerRowCardsContainerSelector) const hotkeys = useMemo(() => [Hotkey.q, Hotkey.w, Hotkey.e, Hotkey.r, Hotkey.t], []) diff --git a/apps/ligretto-frontend/src/features/player/ui/PlayerRowCardsContainer/index.ts b/apps/ligretto-frontend/src/features/player/ui/PlayerRowCardsContainer/index.ts new file mode 100644 index 00000000..6971b2a7 --- /dev/null +++ b/apps/ligretto-frontend/src/features/player/ui/PlayerRowCardsContainer/index.ts @@ -0,0 +1 @@ +export { PlayerRowCardsContainer } from './PlayerRowCardsContainer' diff --git a/apps/ligretto-frontend/src/features/playground/index.ts b/apps/ligretto-frontend/src/features/playground/index.ts new file mode 100644 index 00000000..efcda660 --- /dev/null +++ b/apps/ligretto-frontend/src/features/playground/index.ts @@ -0,0 +1 @@ +export { PlaygroundContainer } from './ui/PlaygroundContainer' diff --git a/apps/ligretto-frontend/src/components/blocks/game/playground/Playground.tsx b/apps/ligretto-frontend/src/features/playground/ui/Playground.tsx similarity index 85% rename from apps/ligretto-frontend/src/components/blocks/game/playground/Playground.tsx rename to apps/ligretto-frontend/src/features/playground/ui/Playground.tsx index 4148aae7..b2cf419e 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/playground/Playground.tsx +++ b/apps/ligretto-frontend/src/features/playground/ui/Playground.tsx @@ -1,9 +1,9 @@ import React, { useMemo } from 'react' import type { CardsDeck, Card } from '@memebattle/ligretto-shared' import last from 'lodash/last' -import { CardPlace } from '../CardPlace' -import { TableCards } from '../TableCards' -import { Card as CardComponent } from '../Card' +import { CardPlace } from 'entities/card/ui/CardPlace' +import { TableCards } from './TableCards' +import { Card as CardComponent } from 'entities/card/ui/Card' export interface PlaygroundProps { cardsDecks: Array diff --git a/apps/ligretto-frontend/src/containers/playground/PlaygroundContainer.tsx b/apps/ligretto-frontend/src/features/playground/ui/PlaygroundContainer.tsx similarity index 94% rename from apps/ligretto-frontend/src/containers/playground/PlaygroundContainer.tsx rename to apps/ligretto-frontend/src/features/playground/ui/PlaygroundContainer.tsx index d01426f1..49ae0abf 100644 --- a/apps/ligretto-frontend/src/containers/playground/PlaygroundContainer.tsx +++ b/apps/ligretto-frontend/src/features/playground/ui/PlaygroundContainer.tsx @@ -2,7 +2,7 @@ import React, { useCallback } from 'react' import { useDispatch, useSelector } from 'react-redux' import { createSelector } from '@reduxjs/toolkit' -import { Playground } from 'components/blocks/game' +import { Playground } from './Playground' import { playgroundDecksSelector, tapPlaygroundCardAction } from 'ducks/game' const PlaygroundContainerSelector = createSelector([playgroundDecksSelector], playgroundDecks => ({ diff --git a/apps/ligretto-frontend/src/components/blocks/game/TableCards/TableCards.stories.tsx b/apps/ligretto-frontend/src/features/playground/ui/TableCards/TableCards.stories.tsx similarity index 86% rename from apps/ligretto-frontend/src/components/blocks/game/TableCards/TableCards.stories.tsx rename to apps/ligretto-frontend/src/features/playground/ui/TableCards/TableCards.stories.tsx index d9ba9e38..a18abbcb 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/TableCards/TableCards.stories.tsx +++ b/apps/ligretto-frontend/src/features/playground/ui/TableCards/TableCards.stories.tsx @@ -1,5 +1,5 @@ import { TableCards } from './TableCards' -import { CardPlace } from '../CardPlace' +import { CardPlace } from 'entities/card' export default { title: 'Ligretto / TableCards', diff --git a/apps/ligretto-frontend/src/components/blocks/game/TableCards/TableCards.tsx b/apps/ligretto-frontend/src/features/playground/ui/TableCards/TableCards.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/TableCards/TableCards.tsx rename to apps/ligretto-frontend/src/features/playground/ui/TableCards/TableCards.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/TableCards/index.ts b/apps/ligretto-frontend/src/features/playground/ui/TableCards/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/TableCards/index.ts rename to apps/ligretto-frontend/src/features/playground/ui/TableCards/index.ts diff --git a/apps/ligretto-frontend/src/features/search-rooms/index.ts b/apps/ligretto-frontend/src/features/search-rooms/index.ts new file mode 100644 index 00000000..735d9f51 --- /dev/null +++ b/apps/ligretto-frontend/src/features/search-rooms/index.ts @@ -0,0 +1,2 @@ +export { SearchRoomsContainer } from './ui/SearchRoomsContainer' +export { RoomsListContainer } from './ui/RoomsListContainer' diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsList/RoomsList.stories.tsx b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/RoomsList.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/home/RoomsList/RoomsList.stories.tsx rename to apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/RoomsList.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsList/RoomsList.tsx b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/RoomsList.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/home/RoomsList/RoomsList.tsx rename to apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/RoomsList.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsList/assets/cat.svg b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/assets/cat.svg similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/home/RoomsList/assets/cat.svg rename to apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/assets/cat.svg diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsList/index.ts b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/home/RoomsList/index.ts rename to apps/ligretto-frontend/src/features/search-rooms/ui/RoomsList/index.ts diff --git a/apps/ligretto-frontend/src/containers/RoomsListContainer/RoomsListContainer.tsx b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsListContainer.tsx similarity index 79% rename from apps/ligretto-frontend/src/containers/RoomsListContainer/RoomsListContainer.tsx rename to apps/ligretto-frontend/src/features/search-rooms/ui/RoomsListContainer.tsx index 95120733..7b5e3fc6 100644 --- a/apps/ligretto-frontend/src/containers/RoomsListContainer/RoomsListContainer.tsx +++ b/apps/ligretto-frontend/src/features/search-rooms/ui/RoomsListContainer.tsx @@ -1,10 +1,10 @@ import React, { useMemo } from 'react' import { useSelector } from 'react-redux' -import type { RoomsListProps } from 'components/blocks/home/RoomsList' -import { RoomsList as RoomsListComponent } from 'components/blocks/home/RoomsList' +import type { RoomsListProps } from './RoomsList' +import { RoomsList as RoomsListComponent } from './RoomsList' import { useNavigate, generatePath } from 'react-router' -import { routes } from 'utils/constants' +import { routes } from 'shared/constants' import { foundRoomsSelector } from 'ducks/rooms' export const RoomsListContainer = () => { diff --git a/apps/ligretto-frontend/src/containers/SearchRoomsContainer/SearchRoomsContainer.tsx b/apps/ligretto-frontend/src/features/search-rooms/ui/SearchRoomsContainer.tsx similarity index 96% rename from apps/ligretto-frontend/src/containers/SearchRoomsContainer/SearchRoomsContainer.tsx rename to apps/ligretto-frontend/src/features/search-rooms/ui/SearchRoomsContainer.tsx index 9922e704..cbc76f0d 100644 --- a/apps/ligretto-frontend/src/containers/SearchRoomsContainer/SearchRoomsContainer.tsx +++ b/apps/ligretto-frontend/src/features/search-rooms/ui/SearchRoomsContainer.tsx @@ -4,7 +4,7 @@ import { createSelector } from '@reduxjs/toolkit' import { isLoadingSelector, searchSelector } from 'ducks/rooms/selectors' import { setSearchRoomsAction } from 'ducks/rooms' -import { InputWithButton } from 'components/InputWithButton' +import { InputWithButton } from 'shared/ui/InputWithButton' import SearchIcon from '@mui/icons-material/Search' import CachedIcon from '@mui/icons-material/Cached' diff --git a/apps/ligretto-frontend/src/index.tsx b/apps/ligretto-frontend/src/index.tsx index 44513901..5ba3f362 100644 --- a/apps/ligretto-frontend/src/index.tsx +++ b/apps/ligretto-frontend/src/index.tsx @@ -3,10 +3,10 @@ import { createRoot } from 'react-dom/client' import { Provider } from 'react-redux' import { ThemeProvider, CssBaseline } from '@memebattle/ui' import { HistoryRouter as Router } from 'redux-first-history/rr6' -import { theme } from './themes/default' +import { store, history } from 'app/store' -import { store, history } from 'store' -import { AppContainer } from 'containers/app' +import { theme } from './app/themes/default' +import { AppContainer } from './app/AppContainer' const reactRootContainer = document.getElementById('root') diff --git a/apps/ligretto-frontend/src/middlewares/saga/actions.ts b/apps/ligretto-frontend/src/middlewares/saga/actions.ts deleted file mode 100644 index b8b34be3..00000000 --- a/apps/ligretto-frontend/src/middlewares/saga/actions.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { createAction } from '@reduxjs/toolkit' -export const socketConnectedAction = createAction('@@socket-middleware/SOCKET_CONNECTED') diff --git a/apps/ligretto-frontend/src/middlewares/saga/index.ts b/apps/ligretto-frontend/src/middlewares/saga/index.ts deleted file mode 100644 index e9c5ed64..00000000 --- a/apps/ligretto-frontend/src/middlewares/saga/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { socketSaga } from './socket-middleware' diff --git a/apps/ligretto-frontend/src/pages/game/GamePage.tsx b/apps/ligretto-frontend/src/pages/game/GamePage.tsx deleted file mode 100644 index e0c9519c..00000000 --- a/apps/ligretto-frontend/src/pages/game/GamePage.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' -import { GamePageContainer } from 'containers/GamePageContainer' -import { GameLayout } from 'components/layouts/game/GameLayout' - -export const GamePage: React.FC = () => ( - - - -) diff --git a/apps/ligretto-frontend/src/pages/game/GamePage.stories.tsx b/apps/ligretto-frontend/src/pages/game/GamePageContainer.stories.tsx similarity index 97% rename from apps/ligretto-frontend/src/pages/game/GamePage.stories.tsx rename to apps/ligretto-frontend/src/pages/game/GamePageContainer.stories.tsx index 4c251281..9d09296e 100644 --- a/apps/ligretto-frontend/src/pages/game/GamePage.stories.tsx +++ b/apps/ligretto-frontend/src/pages/game/GamePageContainer.stories.tsx @@ -1,9 +1,9 @@ import { Provider } from 'react-redux' import type { Meta, StoryFn } from '@storybook/react' -import { history, store } from 'store' +import { history, store } from 'app/store' -import { GamePage } from './GamePage' -import { createStoreForStories } from 'utils/createStoreForStories' +import { GamePageContainer } from './GamePageContainer' +import { createStoreForStories } from 'shared/lib/createStoreForStories' import { initialState as gameInitialState } from 'ducks/game' import { authInitialState } from 'ducks/auth/authSlice' @@ -11,9 +11,9 @@ import type { Player } from '@memebattle/ligretto-shared' import { GameStatus, PlayerStatus } from '@memebattle/ligretto-shared' import { HistoryRouter as Router } from 'redux-first-history/rr6' -const meta: Meta = { - title: 'Ligretto / pages / GamePage', - component: GamePage, +const meta: Meta = { + title: 'Ligretto / pages / GamePageContainer', + component: GamePageContainer, decorators: [ Story => ( @@ -26,7 +26,7 @@ const meta: Meta = { } export default meta -const Template: StoryFn = () => +const Template: StoryFn = () => export const Loading = Template.bind({}) Loading.decorators = [ Story => ( diff --git a/apps/ligretto-frontend/src/pages/game/GamePageContainer.tsx b/apps/ligretto-frontend/src/pages/game/GamePageContainer.tsx new file mode 100644 index 00000000..359545f2 --- /dev/null +++ b/apps/ligretto-frontend/src/pages/game/GamePageContainer.tsx @@ -0,0 +1,30 @@ +import { useSelector } from 'react-redux' +import { createSelector } from '@reduxjs/toolkit' +import { GameStatus } from '@memebattle/ligretto-shared' + +import { gameStatusSelector, isGameLoadedSelector } from 'ducks/game' +import { GameSettingsModal } from 'widgets/game-info' +import { GameLayout } from 'shared/ui/layouts/game/GameLayout' +import { GameContainer } from 'widgets/game' + +const gamePageContainerSelector = createSelector([gameStatusSelector, isGameLoadedSelector], (gameStatus, isGameLoaded) => ({ + gameStatus, + isGameLoaded, +})) + +const activeModalStatuses = new Set([GameStatus.New, GameStatus.Pause, GameStatus.RoundFinished]) + +export const GamePageContainer = () => { + const { gameStatus, isGameLoaded } = useSelector(gamePageContainerSelector) + + if (!isGameLoaded) { + return <>loading + } + + return ( + + + + + ) +} diff --git a/apps/ligretto-frontend/src/pages/home/HomePage.stories.tsx b/apps/ligretto-frontend/src/pages/home/HomePage.stories.tsx index 72de6d11..05f7f767 100644 --- a/apps/ligretto-frontend/src/pages/home/HomePage.stories.tsx +++ b/apps/ligretto-frontend/src/pages/home/HomePage.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react' import { HomePage } from './HomePage' -import { history, store } from 'store' +import { history, store } from 'app/store' import { Provider } from 'react-redux' import { HistoryRouter as Router } from 'redux-first-history/rr6' diff --git a/apps/ligretto-frontend/src/pages/home/HomePage.tsx b/apps/ligretto-frontend/src/pages/home/HomePage.tsx index ce1bcd77..0bab0c1a 100644 --- a/apps/ligretto-frontend/src/pages/home/HomePage.tsx +++ b/apps/ligretto-frontend/src/pages/home/HomePage.tsx @@ -1,10 +1,10 @@ import React from 'react' -import { MainLayout } from 'components/layouts/main/MainLayout' -import { UserInfoContainer } from 'containers/main-page' +import { MainLayout } from 'shared/ui/layouts/main/MainLayout' +import { UserInfoContainer } from 'widgets/user-info' import { Grid, Box } from '@memebattle/ui' -import { LigrettoLogo } from 'components/LigrettoLogo' -import { RoomsManager } from 'components/blocks/home/RoomsManager' +import { LigrettoLogo } from 'shared/ui/LigrettoLogo' +import { RoomsManager } from 'widgets/rooms-manager' export const HomePage: React.FC = () => ( diff --git a/apps/ligretto-frontend/src/api/apiTypes.ts b/apps/ligretto-frontend/src/shared/api/apiTypes.ts similarity index 100% rename from apps/ligretto-frontend/src/api/apiTypes.ts rename to apps/ligretto-frontend/src/shared/api/apiTypes.ts diff --git a/apps/ligretto-frontend/src/utils/buildCasStaticUrl.ts b/apps/ligretto-frontend/src/shared/api/buildCasStaticUrl.ts similarity index 72% rename from apps/ligretto-frontend/src/utils/buildCasStaticUrl.ts rename to apps/ligretto-frontend/src/shared/api/buildCasStaticUrl.ts index 36bda59a..056d38e2 100644 --- a/apps/ligretto-frontend/src/utils/buildCasStaticUrl.ts +++ b/apps/ligretto-frontend/src/shared/api/buildCasStaticUrl.ts @@ -1,4 +1,4 @@ -import { CAS_STATIC_URL } from 'config' +import { CAS_STATIC_URL } from 'shared/constants/config' /** * Return full path diff --git a/apps/ligretto-frontend/src/api/index.ts b/apps/ligretto-frontend/src/shared/api/index.ts similarity index 89% rename from apps/ligretto-frontend/src/api/index.ts rename to apps/ligretto-frontend/src/shared/api/index.ts index 42a9c43e..a6bccd7f 100644 --- a/apps/ligretto-frontend/src/api/index.ts +++ b/apps/ligretto-frontend/src/shared/api/index.ts @@ -1,4 +1,4 @@ -import { request } from 'utils/request' +import { request } from 'shared/api/request' import type { UserModel } from './apiTypes' diff --git a/apps/ligretto-frontend/src/utils/request.ts b/apps/ligretto-frontend/src/shared/api/request.ts similarity index 62% rename from apps/ligretto-frontend/src/utils/request.ts rename to apps/ligretto-frontend/src/shared/api/request.ts index fd483617..9daa548c 100644 --- a/apps/ligretto-frontend/src/utils/request.ts +++ b/apps/ligretto-frontend/src/shared/api/request.ts @@ -1,5 +1,5 @@ import axios from 'axios' -import { LIGRETTO_CORE_URL } from 'config' +import { LIGRETTO_CORE_URL } from 'shared/constants/config' export const request = axios.create({ baseURL: LIGRETTO_CORE_URL, diff --git a/apps/ligretto-frontend/src/config.ts b/apps/ligretto-frontend/src/shared/constants/config.ts similarity index 100% rename from apps/ligretto-frontend/src/config.ts rename to apps/ligretto-frontend/src/shared/constants/config.ts diff --git a/apps/ligretto-frontend/src/utils/constants/index.ts b/apps/ligretto-frontend/src/shared/constants/index.ts similarity index 51% rename from apps/ligretto-frontend/src/utils/constants/index.ts rename to apps/ligretto-frontend/src/shared/constants/index.ts index 72bf7202..89bff046 100644 --- a/apps/ligretto-frontend/src/utils/constants/index.ts +++ b/apps/ligretto-frontend/src/shared/constants/index.ts @@ -1,2 +1 @@ -export * from './text-constants' export * from './router-constants' diff --git a/apps/ligretto-frontend/src/utils/constants/router-constants.ts b/apps/ligretto-frontend/src/shared/constants/router-constants.ts similarity index 100% rename from apps/ligretto-frontend/src/utils/constants/router-constants.ts rename to apps/ligretto-frontend/src/shared/constants/router-constants.ts diff --git a/apps/ligretto-frontend/src/utils/createStoreForStories.ts b/apps/ligretto-frontend/src/shared/lib/createStoreForStories.ts similarity index 74% rename from apps/ligretto-frontend/src/utils/createStoreForStories.ts rename to apps/ligretto-frontend/src/shared/lib/createStoreForStories.ts index ec41902b..17d37f66 100644 --- a/apps/ligretto-frontend/src/utils/createStoreForStories.ts +++ b/apps/ligretto-frontend/src/shared/lib/createStoreForStories.ts @@ -1,8 +1,9 @@ import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit' import type { ConfigureStoreOptions } from '@reduxjs/toolkit' -import { rootReducer } from '../store/rootReducer' -import { routerMiddleware } from '../store/reduxHistoryContext' +// TODO: probably need to move it somewhere from shared +import { rootReducer } from 'app/store/rootReducer' +import { routerMiddleware } from 'app/store/reduxHistoryContext' import type { All } from 'types/store' const middleware = [...getDefaultMiddleware({ serializableCheck: false, thunk: false }), routerMiddleware] diff --git a/apps/ligretto-frontend/src/hooks/useMinTimeLoader/index.ts b/apps/ligretto-frontend/src/shared/lib/hooks/useMinTimeLoader/index.ts similarity index 100% rename from apps/ligretto-frontend/src/hooks/useMinTimeLoader/index.ts rename to apps/ligretto-frontend/src/shared/lib/hooks/useMinTimeLoader/index.ts diff --git a/apps/ligretto-frontend/src/hooks/useMinTimeLoader/useMinTimeLoading.ts b/apps/ligretto-frontend/src/shared/lib/hooks/useMinTimeLoader/useMinTimeLoading.ts similarity index 100% rename from apps/ligretto-frontend/src/hooks/useMinTimeLoader/useMinTimeLoading.ts rename to apps/ligretto-frontend/src/shared/lib/hooks/useMinTimeLoader/useMinTimeLoading.ts diff --git a/apps/ligretto-frontend/src/components/Avatar/Avatar.stories.tsx b/apps/ligretto-frontend/src/shared/ui/Avatar/Avatar.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/Avatar.stories.tsx rename to apps/ligretto-frontend/src/shared/ui/Avatar/Avatar.stories.tsx diff --git a/apps/ligretto-frontend/src/components/Avatar/Avatar.tsx b/apps/ligretto-frontend/src/shared/ui/Avatar/Avatar.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/Avatar.tsx rename to apps/ligretto-frontend/src/shared/ui/Avatar/Avatar.tsx diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u1.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u1.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u1.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u1.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u2.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u2.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u2.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u2.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u3.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u3.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u3.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u3.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u4.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u4.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u4.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u4.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u5.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u5.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u5.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u5.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u6.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u6.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u6.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u6.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u7.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u7.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u7.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u7.svg diff --git a/apps/ligretto-frontend/src/components/Avatar/assets/u8.svg b/apps/ligretto-frontend/src/shared/ui/Avatar/assets/u8.svg similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/assets/u8.svg rename to apps/ligretto-frontend/src/shared/ui/Avatar/assets/u8.svg diff --git a/apps/ligretto-frontend/src/shared/ui/Avatar/getRandomAvatar.spec.ts b/apps/ligretto-frontend/src/shared/ui/Avatar/getRandomAvatar.spec.ts new file mode 100644 index 00000000..f655d172 --- /dev/null +++ b/apps/ligretto-frontend/src/shared/ui/Avatar/getRandomAvatar.spec.ts @@ -0,0 +1,24 @@ +import { getRandomAvatar } from './getRandomAvatar' + +describe('Avatar:getRandomAvatar', () => { + it.each([ + { id: '1', expected: '/src/shared/ui/Avatar/assets/u2.svg' }, + { id: '2', expected: '/src/shared/ui/Avatar/assets/u3.svg' }, + { + id: '7', + expected: '/src/shared/ui/Avatar/assets/u8.svg', + }, + { id: 'a', expected: '/src/shared/ui/Avatar/assets/u2.svg' }, + { id: 'b', expected: '/src/shared/ui/Avatar/assets/u3.svg' }, + { id: 'c', expected: '/src/shared/ui/Avatar/assets/u4.svg' }, + { id: 'd', expected: '/src/shared/ui/Avatar/assets/u5.svg' }, + { id: 'e', expected: '/src/shared/ui/Avatar/assets/u6.svg' }, + { id: 'f', expected: '/src/shared/ui/Avatar/assets/u7.svg' }, + { id: 'g', expected: '/src/shared/ui/Avatar/assets/u8.svg' }, + { id: 'h', expected: '/src/shared/ui/Avatar/assets/u1.svg' }, + { id: '', expected: '/src/shared/ui/Avatar/assets/u1.svg' }, + { id: undefined, expected: '/src/shared/ui/Avatar/assets/u1.svg' }, + ])('Should return correct avatar for ids', ({ id, expected }) => { + expect(getRandomAvatar(id)).toBe(expected) + }) +}) diff --git a/apps/ligretto-frontend/src/components/Avatar/getRandomAvatar.ts b/apps/ligretto-frontend/src/shared/ui/Avatar/getRandomAvatar.ts similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/getRandomAvatar.ts rename to apps/ligretto-frontend/src/shared/ui/Avatar/getRandomAvatar.ts diff --git a/apps/ligretto-frontend/src/components/Avatar/index.ts b/apps/ligretto-frontend/src/shared/ui/Avatar/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/Avatar/index.ts rename to apps/ligretto-frontend/src/shared/ui/Avatar/index.ts diff --git a/apps/ligretto-frontend/src/components/InputWithButton/InputWithButton.stories.tsx b/apps/ligretto-frontend/src/shared/ui/InputWithButton/InputWithButton.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/InputWithButton/InputWithButton.stories.tsx rename to apps/ligretto-frontend/src/shared/ui/InputWithButton/InputWithButton.stories.tsx diff --git a/apps/ligretto-frontend/src/components/InputWithButton/InputWithButton.tsx b/apps/ligretto-frontend/src/shared/ui/InputWithButton/InputWithButton.tsx similarity index 86% rename from apps/ligretto-frontend/src/components/InputWithButton/InputWithButton.tsx rename to apps/ligretto-frontend/src/shared/ui/InputWithButton/InputWithButton.tsx index c0c0753b..d3be9d99 100644 --- a/apps/ligretto-frontend/src/components/InputWithButton/InputWithButton.tsx +++ b/apps/ligretto-frontend/src/shared/ui/InputWithButton/InputWithButton.tsx @@ -1,7 +1,6 @@ import * as React from 'react' -import { Box, Button, InputBase } from '@memebattle/ui' +import { Box, Button, InputBase, useTheme } from '@memebattle/ui' import { styled } from '@mui/material/styles' -import { theme } from '../../themes/default' interface InputWithButtonExtension { Input: typeof StyledInput @@ -28,11 +27,15 @@ interface StyledButtonWrapperProps { onClick?: () => void } -const StyledButtonWrapper: React.FC> = ({ children, onClick }) => ( - - {children} - -) +const StyledButtonWrapper: React.FC> = ({ children, onClick }) => { + const theme = useTheme() + + return ( + + {children} + + ) +} const StyledButton = styled(Button)(({ theme }) => ({ height: '100%', diff --git a/apps/ligretto-frontend/src/components/InputWithButton/index.ts b/apps/ligretto-frontend/src/shared/ui/InputWithButton/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/InputWithButton/index.ts rename to apps/ligretto-frontend/src/shared/ui/InputWithButton/index.ts diff --git a/apps/ligretto-frontend/src/components/LigrettoLogo/LigrettoLogo.stories.tsx b/apps/ligretto-frontend/src/shared/ui/LigrettoLogo/LigrettoLogo.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/LigrettoLogo/LigrettoLogo.stories.tsx rename to apps/ligretto-frontend/src/shared/ui/LigrettoLogo/LigrettoLogo.stories.tsx diff --git a/apps/ligretto-frontend/src/components/LigrettoLogo/LigrettoLogo.tsx b/apps/ligretto-frontend/src/shared/ui/LigrettoLogo/LigrettoLogo.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/LigrettoLogo/LigrettoLogo.tsx rename to apps/ligretto-frontend/src/shared/ui/LigrettoLogo/LigrettoLogo.tsx diff --git a/apps/ligretto-frontend/src/components/LigrettoLogo/index.ts b/apps/ligretto-frontend/src/shared/ui/LigrettoLogo/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/LigrettoLogo/index.ts rename to apps/ligretto-frontend/src/shared/ui/LigrettoLogo/index.ts diff --git a/apps/ligretto-frontend/src/components/layouts/base/BaseLayout.tsx b/apps/ligretto-frontend/src/shared/ui/layouts/base/BaseLayout.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/base/BaseLayout.tsx rename to apps/ligretto-frontend/src/shared/ui/layouts/base/BaseLayout.tsx diff --git a/apps/ligretto-frontend/src/components/layouts/game/GameLayout.tsx b/apps/ligretto-frontend/src/shared/ui/layouts/game/GameLayout.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/game/GameLayout.tsx rename to apps/ligretto-frontend/src/shared/ui/layouts/game/GameLayout.tsx diff --git a/apps/ligretto-frontend/src/components/layouts/main/Background/Background.stories.tsx b/apps/ligretto-frontend/src/shared/ui/layouts/main/Background/Background.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/main/Background/Background.stories.tsx rename to apps/ligretto-frontend/src/shared/ui/layouts/main/Background/Background.stories.tsx diff --git a/apps/ligretto-frontend/src/components/layouts/main/Background/Background.tsx b/apps/ligretto-frontend/src/shared/ui/layouts/main/Background/Background.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/main/Background/Background.tsx rename to apps/ligretto-frontend/src/shared/ui/layouts/main/Background/Background.tsx diff --git a/apps/ligretto-frontend/src/components/layouts/main/Background/index.ts b/apps/ligretto-frontend/src/shared/ui/layouts/main/Background/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/main/Background/index.ts rename to apps/ligretto-frontend/src/shared/ui/layouts/main/Background/index.ts diff --git a/apps/ligretto-frontend/src/components/layouts/main/MainLayout.tsx b/apps/ligretto-frontend/src/shared/ui/layouts/main/MainLayout.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/main/MainLayout.tsx rename to apps/ligretto-frontend/src/shared/ui/layouts/main/MainLayout.tsx diff --git a/apps/ligretto-frontend/src/components/layouts/main/index.ts b/apps/ligretto-frontend/src/shared/ui/layouts/main/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/layouts/main/index.ts rename to apps/ligretto-frontend/src/shared/ui/layouts/main/index.ts diff --git a/apps/ligretto-frontend/src/components/screens/LoaderScreen/LoaderScreen.stories.tsx b/apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/LoaderScreen.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/screens/LoaderScreen/LoaderScreen.stories.tsx rename to apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/LoaderScreen.stories.tsx diff --git a/apps/ligretto-frontend/src/components/screens/LoaderScreen/LoaderScreen.tsx b/apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/LoaderScreen.tsx similarity index 86% rename from apps/ligretto-frontend/src/components/screens/LoaderScreen/LoaderScreen.tsx rename to apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/LoaderScreen.tsx index 867d7737..2881ff2b 100644 --- a/apps/ligretto-frontend/src/components/screens/LoaderScreen/LoaderScreen.tsx +++ b/apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/LoaderScreen.tsx @@ -1,9 +1,9 @@ import React from 'react' import { LoaderCards, Box, useMediaQuery, useTheme } from '@memebattle/ui' -import { MainLayout } from 'components/layouts/main' +import { MainLayout } from 'shared/ui/layouts/main' -import { LigrettoLogo } from 'components/LigrettoLogo' +import { LigrettoLogo } from 'shared/ui/LigrettoLogo' export const LoaderScreen: React.FC = () => { const theme = useTheme() diff --git a/apps/ligretto-frontend/src/components/screens/LoaderScreen/index.ts b/apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/screens/LoaderScreen/index.ts rename to apps/ligretto-frontend/src/shared/ui/screens/LoaderScreen/index.ts diff --git a/apps/ligretto-frontend/src/types/store.ts b/apps/ligretto-frontend/src/types/store.ts index 530561bd..05c3b1ad 100644 --- a/apps/ligretto-frontend/src/types/store.ts +++ b/apps/ligretto-frontend/src/types/store.ts @@ -1,3 +1,3 @@ -import type { store } from 'store' +import type { store } from 'app/store' export type All = ReturnType diff --git a/apps/ligretto-frontend/src/utils/constants/text-constants.ts b/apps/ligretto-frontend/src/utils/constants/text-constants.ts deleted file mode 100644 index 29394819..00000000 --- a/apps/ligretto-frontend/src/utils/constants/text-constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const LOGO_CAPTURE = 'Ligretto Game' diff --git a/apps/ligretto-frontend/src/widgets/game-info/index.ts b/apps/ligretto-frontend/src/widgets/game-info/index.ts new file mode 100644 index 00000000..030423af --- /dev/null +++ b/apps/ligretto-frontend/src/widgets/game-info/index.ts @@ -0,0 +1 @@ +export { GameSettingsModal } from './ui/GameSettingsModal' diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.stories.tsx b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.stories.tsx similarity index 91% rename from apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.stories.tsx rename to apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.stories.tsx index b25033ef..c8f40cd5 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.stories.tsx +++ b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.stories.tsx @@ -3,7 +3,7 @@ import { Provider } from 'react-redux' import { GameSettings } from './GameSettings' import type { Meta } from '@storybook/react' import { GameStatus } from '@memebattle/ligretto-shared' -import { createStoreForStories } from 'utils/createStoreForStories' +import { createStoreForStories } from 'shared/lib/createStoreForStories' export default { title: 'Ligretto / GameSettings', diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.tsx b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.tsx similarity index 96% rename from apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.tsx rename to apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.tsx index 6c5d446f..76028cd2 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/GameSettings/GameSettings.tsx +++ b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettings.tsx @@ -3,7 +3,7 @@ import ExitToAppIcon from '@mui/icons-material/ExitToApp' import { Box, Button, Paper, Stack, Typography } from '@memebattle/ui' import { styled } from '@mui/material/styles' -import { PlayersScoresTableContainer } from 'containers/PlayersScoresTable/PlayersScoresTableContainer' +import { PlayersScoresTableContainer } from 'features/player-scores-table' import { GameStatus } from '@memebattle/ligretto-shared' interface GameSettingsProps { diff --git a/apps/ligretto-frontend/src/containers/GameSettings/GameSettingsContainer.tsx b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettingsContainer.tsx similarity index 90% rename from apps/ligretto-frontend/src/containers/GameSettings/GameSettingsContainer.tsx rename to apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettingsContainer.tsx index 1838091c..f71abadb 100644 --- a/apps/ligretto-frontend/src/containers/GameSettings/GameSettingsContainer.tsx +++ b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/GameSettingsContainer.tsx @@ -1,8 +1,8 @@ -import React, { useCallback } from 'react' +import { useCallback } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router' -import { routes } from 'utils/constants' +import { routes } from 'shared/constants' import { gameNameSelector, gameStatusSelector, @@ -11,7 +11,7 @@ import { startGameAction, togglePlayerStatusAction, } from 'ducks/game' -import { GameSettings } from 'components/blocks/game/GameSettings' +import { GameSettings } from 'widgets/game-info/ui/GameSettings' import { PlayerStatus } from '@memebattle/ligretto-shared' export const GameSettingsContainer = () => { diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameSettings/index.ts b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/GameSettings/index.ts rename to apps/ligretto-frontend/src/widgets/game-info/ui/GameSettings/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameSettingsModal/GameSettingsModal.tsx b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettingsModal.tsx similarity index 86% rename from apps/ligretto-frontend/src/components/blocks/game/GameSettingsModal/GameSettingsModal.tsx rename to apps/ligretto-frontend/src/widgets/game-info/ui/GameSettingsModal.tsx index 3f10dc60..7a9753e2 100644 --- a/apps/ligretto-frontend/src/components/blocks/game/GameSettingsModal/GameSettingsModal.tsx +++ b/apps/ligretto-frontend/src/widgets/game-info/ui/GameSettingsModal.tsx @@ -1,7 +1,6 @@ import { Box, Modal, Slide } from '@memebattle/ui' -import { GameSettingsContainer } from 'containers/GameSettings' +import { GameSettingsContainer } from './GameSettings/GameSettingsContainer' import type { FC } from 'react' -import React from 'react' export const GameSettingsModal: FC<{ isOpen: boolean }> = ({ isOpen }) => ( diff --git a/apps/ligretto-frontend/src/widgets/game/index.ts b/apps/ligretto-frontend/src/widgets/game/index.ts new file mode 100644 index 00000000..fd9951fc --- /dev/null +++ b/apps/ligretto-frontend/src/widgets/game/index.ts @@ -0,0 +1 @@ +export { GameContainer } from './ui/GameContainer' diff --git a/apps/ligretto-frontend/src/widgets/game/ui/GameContainer.tsx b/apps/ligretto-frontend/src/widgets/game/ui/GameContainer.tsx new file mode 100644 index 00000000..b6641077 --- /dev/null +++ b/apps/ligretto-frontend/src/widgets/game/ui/GameContainer.tsx @@ -0,0 +1,41 @@ +import { GameGrid } from './GameGrid' +import { Opponent, CardsPanelContainer } from 'features/player' +import { PlaygroundContainer } from 'features/playground' +import { createSelector } from '@reduxjs/toolkit' +import { useSelector } from 'react-redux' +import { gameStatusSelector, isPlayerSpectatorSelector, opponentsSelector, startingDelayInSecSelector } from 'ducks/game' +import { GameStatus } from '@memebattle/ligretto-shared' +import { ScreenCountdown } from './ScreenCountdown' + +const gamePageContainerSelector = createSelector( + [gameStatusSelector, isPlayerSpectatorSelector, startingDelayInSecSelector, opponentsSelector], + (gameStatus, isPlayerSpectator, startingDelayInSec, opponents) => ({ + gameStatus, + isPlayerSpectator, + startingDelayInSec, + opponents, + }), +) + +export const GameContainer = () => { + const { isPlayerSpectator, opponents, startingDelayInSec, gameStatus } = useSelector(gamePageContainerSelector) + + return ( + <> + {gameStatus === GameStatus.Starting && } + } bottomElement={isPlayerSpectator ? null : }> + {opponents.map(opponent => ( + + ))} + + + ) +} diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameGrid/GameGrid.stories.tsx b/apps/ligretto-frontend/src/widgets/game/ui/GameGrid/GameGrid.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/GameGrid/GameGrid.stories.tsx rename to apps/ligretto-frontend/src/widgets/game/ui/GameGrid/GameGrid.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameGrid/GameGrid.tsx b/apps/ligretto-frontend/src/widgets/game/ui/GameGrid/GameGrid.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/GameGrid/GameGrid.tsx rename to apps/ligretto-frontend/src/widgets/game/ui/GameGrid/GameGrid.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/GameGrid/index.ts b/apps/ligretto-frontend/src/widgets/game/ui/GameGrid/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/GameGrid/index.ts rename to apps/ligretto-frontend/src/widgets/game/ui/GameGrid/index.ts diff --git a/apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/ScreenCountdown.stories.tsx b/apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/ScreenCountdown.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/ScreenCountdown.stories.tsx rename to apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/ScreenCountdown.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/ScreenCountdown.tsx b/apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/ScreenCountdown.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/ScreenCountdown.tsx rename to apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/ScreenCountdown.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/index.ts b/apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/index.ts similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/game/ScreenCountdown/index.ts rename to apps/ligretto-frontend/src/widgets/game/ui/ScreenCountdown/index.ts diff --git a/apps/ligretto-frontend/src/widgets/rooms-manager/index.ts b/apps/ligretto-frontend/src/widgets/rooms-manager/index.ts new file mode 100644 index 00000000..a84b5c74 --- /dev/null +++ b/apps/ligretto-frontend/src/widgets/rooms-manager/index.ts @@ -0,0 +1 @@ +export { RoomsManager } from './ui/RoomsManager' diff --git a/apps/ligretto-frontend/src/components/blocks/home/RoomsManager/RoomsManager.tsx b/apps/ligretto-frontend/src/widgets/rooms-manager/ui/RoomsManager.tsx similarity index 84% rename from apps/ligretto-frontend/src/components/blocks/home/RoomsManager/RoomsManager.tsx rename to apps/ligretto-frontend/src/widgets/rooms-manager/ui/RoomsManager.tsx index 9c32dcd8..fb402017 100644 --- a/apps/ligretto-frontend/src/components/blocks/home/RoomsManager/RoomsManager.tsx +++ b/apps/ligretto-frontend/src/widgets/rooms-manager/ui/RoomsManager.tsx @@ -1,11 +1,10 @@ -import React, { useEffect } from 'react' +import { useEffect } from 'react' import { Box, Grid, Paper, Typography } from '@memebattle/ui' import { styled } from '@mui/material/styles' import { useDispatch } from 'react-redux' -import { RoomsListContainer } from 'containers/RoomsListContainer' -import { CreateRoomContainer } from 'containers/CreateRoomContainer' -import { SearchRoomsContainer } from 'containers/SearchRoomsContainer/SearchRoomsContainer' +import { CreateRoomContainer } from 'features/create-room' +import { SearchRoomsContainer, RoomsListContainer } from 'features/search-rooms' import { getRoomsAction } from 'ducks/rooms' const StyledRoomManager = styled(Paper)(({ theme }) => ({ diff --git a/apps/ligretto-frontend/src/widgets/user-info/index.ts b/apps/ligretto-frontend/src/widgets/user-info/index.ts new file mode 100644 index 00000000..cdaf597b --- /dev/null +++ b/apps/ligretto-frontend/src/widgets/user-info/index.ts @@ -0,0 +1 @@ +export * from './ui/UserInfoContainer' diff --git a/apps/ligretto-frontend/src/components/blocks/home/UserInfo/UserInfo.stories.tsx b/apps/ligretto-frontend/src/widgets/user-info/ui/UserInfo.stories.tsx similarity index 100% rename from apps/ligretto-frontend/src/components/blocks/home/UserInfo/UserInfo.stories.tsx rename to apps/ligretto-frontend/src/widgets/user-info/ui/UserInfo.stories.tsx diff --git a/apps/ligretto-frontend/src/components/blocks/home/UserInfo/UserInfo.tsx b/apps/ligretto-frontend/src/widgets/user-info/ui/UserInfo.tsx similarity index 97% rename from apps/ligretto-frontend/src/components/blocks/home/UserInfo/UserInfo.tsx rename to apps/ligretto-frontend/src/widgets/user-info/ui/UserInfo.tsx index 1ae1e90b..33831f71 100644 --- a/apps/ligretto-frontend/src/components/blocks/home/UserInfo/UserInfo.tsx +++ b/apps/ligretto-frontend/src/widgets/user-info/ui/UserInfo.tsx @@ -4,7 +4,7 @@ import React from 'react' import CreateIcon from '@mui/icons-material/Create' import ClearIcon from '@mui/icons-material/Clear' import { Paper, Button, Box, Typography } from '@memebattle/ui' -import { Avatar } from 'components/Avatar' +import { Avatar } from 'shared/ui/Avatar' export interface UserInfoProps { img?: string diff --git a/apps/ligretto-frontend/src/containers/main-page/UserInfoContainer.tsx b/apps/ligretto-frontend/src/widgets/user-info/ui/UserInfoContainer.tsx similarity index 78% rename from apps/ligretto-frontend/src/containers/main-page/UserInfoContainer.tsx rename to apps/ligretto-frontend/src/widgets/user-info/ui/UserInfoContainer.tsx index 0664ec63..48705cbd 100644 --- a/apps/ligretto-frontend/src/containers/main-page/UserInfoContainer.tsx +++ b/apps/ligretto-frontend/src/widgets/user-info/ui/UserInfoContainer.tsx @@ -1,12 +1,13 @@ import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router' -import React, { useCallback, useMemo } from 'react' +import { useCallback, useMemo } from 'react' -import { UserInfo } from 'components/blocks/home/UserInfo' -import { authRoutes } from 'utils/constants' +import { authRoutes } from 'shared/constants' import { logout, currentUserSelector } from 'ducks/auth' -import { buildCasStaticUrl } from 'utils/buildCasStaticUrl' -import { getRandomAvatar } from 'components/Avatar/getRandomAvatar' +import { buildCasStaticUrl } from 'shared/api/buildCasStaticUrl' +import { getRandomAvatar } from 'shared/ui/Avatar/getRandomAvatar' + +import { UserInfo } from './UserInfo' export const UserInfoContainer = () => { const dispatch = useDispatch() diff --git a/apps/ligretto-frontend/tsconfig.path.json b/apps/ligretto-frontend/tsconfig.path.json index d4e6c700..f12c502b 100644 --- a/apps/ligretto-frontend/tsconfig.path.json +++ b/apps/ligretto-frontend/tsconfig.path.json @@ -5,40 +5,30 @@ "compilerOptions": { "baseUrl": "./src", "paths": { - "api": [ - "api" - ], - "api/*": [ - "api/*" - ], "assets/*": [ "assets/*" ], - "components/*": [ - "components/*" - ], - "containers/*": ["containers/*"], "ducks/*": [ "ducks/*" ], - "hooks": [ - "hooks" - ], - "middlewares/*": [ - "middlewares/*" - ], - "pages": [ + "pages": [ "pages" ], - "store": [ - "store" - ], "types/*": [ "types/*" ], - "utils/*": [ - "utils/*" - ] + "shared/*": [ + "shared/*" + ], + "features/*": [ + "features/*" + ], + "entities": [ + "entities/*" + ], + "wigets/*": [ + "wigets/*" + ], } }, }