Skip to content

Commit

Permalink
erase "export default" outside of pages dir
Browse files Browse the repository at this point in the history
  • Loading branch information
yuta-fujimoto committed Oct 26, 2022
1 parent 1dbe28c commit a62a41c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 36 deletions.
17 changes: 8 additions & 9 deletions frontend/components/game/home/Display.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Grid } from '@mui/material';
import { createContext, useMemo, useEffect } from 'react';
import usePlayStateStore, {
import {
usePlayStateStore,
stateNothing,
stateWaiting,
statePlaying,
} from '../../../store/game/home/PlayState';
import ClientSocket from '../../../store/game/ClientSocket';
import Start from './Start';
import Play from './Play';
import Wait from './Wait';
import Watch from './Watch';
import { ClientSocket } from '../../../store/game/ClientSocket';
import { Start } from './Start';
import { Play } from './Play';
import { Wait } from './Wait';
import { Watch } from './Watch';

export const Context = createContext({} as ClientSocket);

const Display = () => {
export const Display = () => {
const clientSocket = useMemo(() => {
return new ClientSocket('ws://localhost:3001/game');
}, []);
Expand Down Expand Up @@ -42,5 +43,3 @@ const Display = () => {
</Grid>
);
};

export default Display;
4 changes: 1 addition & 3 deletions frontend/components/game/home/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {
children: ReactNode;
};

const Layout: FC<Props> = ({ children, title = 'Next.js' }) => {
export const Layout: FC<Props> = ({ children, title = 'Next.js' }) => {
return (
<div>
<Head>
Expand All @@ -17,5 +17,3 @@ const Layout: FC<Props> = ({ children, title = 'Next.js' }) => {
</div>
);
};

export default Layout;
6 changes: 2 additions & 4 deletions frontend/components/game/home/Play.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useCallback, useEffect, useContext } from 'react';
import useOpponentStore from '../../../store/game/home/Opponent';
import { useOpponentStore } from '../../../store/game/home/Opponent';
import { Context } from './Display';

const Play = () => {
export const Play = () => {
const [score, setScore] = useState(0);
const clientSocket = useContext(Context);
const { opponent } = useOpponentStore();
Expand Down Expand Up @@ -35,5 +35,3 @@ const Play = () => {
</div>
);
};

export default Play;
7 changes: 3 additions & 4 deletions frontend/components/game/home/Start.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import VideogameAssetSharpIcon from '@mui/icons-material/VideogameAssetSharp';
import { Button, Grid, TextField } from '@mui/material';
import React, { useContext, useRef } from 'react';
import usePlayStateStore, {
import {
usePlayStateStore,
stateWaiting,
} from '../../../store/game/home/PlayState';
import { Context } from './Display';

const Start = () => {
export const Start = () => {
const playerNameRef = useRef<HTMLInputElement>(null);
const clientSocket = useContext(Context);
const updatePlayState = usePlayStateStore((store) => store.updatePlayState);
Expand Down Expand Up @@ -39,5 +40,3 @@ const Start = () => {
</>
);
};

export default Start;
9 changes: 4 additions & 5 deletions frontend/components/game/home/Wait.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { CircularProgress, Grid } from '@mui/material';
import { useContext, useEffect } from 'react';
import useOpponentStore from '../../../store/game/home/Opponent';
import usePlayStateStore, {
import { useOpponentStore } from '../../../store/game/home/Opponent';
import {
usePlayStateStore,
statePlaying,
} from '../../../store/game/home/PlayState';
import { Context } from './Display';

const Wait = () => {
export const Wait = () => {
const clientSocket = useContext(Context);
const updatePlayState = usePlayStateStore((store) => store.updatePlayState);
const updateOpponent = useOpponentStore((store) => store.updateOpponent);
Expand All @@ -27,5 +28,3 @@ const Wait = () => {
</Grid>
);
};

export default Wait;
4 changes: 1 addition & 3 deletions frontend/components/game/home/Watch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type RoomInfo = {
playerName2: string;
};

const Watch = () => {
export const Watch = () => {
const clientSocket = useContext(Context);
const [rooms, setRooms] = useState<RoomInfo[]>([]);

Expand Down Expand Up @@ -49,5 +49,3 @@ const Watch = () => {
</Grid>
);
};

export default Watch;
4 changes: 2 additions & 2 deletions frontend/pages/game/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextPage } from 'next';
import Layout from '../../../components/game/home/Layout';
import Display from '../../../components/game/home/Display';
import { Layout } from '../../../components/game/home/Layout';
import { Display } from '../../../components/game/home/Display';

const Home: NextPage = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/store/game/ClientSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class ClientSocket {
}
}

export default ClientSocket;
export { ClientSocket };
4 changes: 1 addition & 3 deletions frontend/store/game/home/Opponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ type State = {
updateOpponent: (payload: string) => void;
};

const useOpponentStore = create<State>((set) => ({
export const useOpponentStore = create<State>((set) => ({
opponent: '',
updateOpponent: (payload) => {
set({
opponent: payload,
});
},
}));

export default useOpponentStore;
3 changes: 1 addition & 2 deletions frontend/store/game/home/PlayState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type State = {
updatePlayState: (payload: PlayState) => void;
};

const usePlayStateStore = create<State>((set) => ({
export const usePlayStateStore = create<State>((set) => ({
playState: stateNothing,
updatePlayState: (payload) =>
set({
Expand All @@ -23,4 +23,3 @@ const usePlayStateStore = create<State>((set) => ({
}));

export { stateNothing, stateWaiting, statePlaying, type PlayState };
export default usePlayStateStore;

0 comments on commit a62a41c

Please sign in to comment.