Skip to content

Commit

Permalink
fix: fixed win/loose play again button
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyiegorov committed May 25, 2023
1 parent 4db11f7 commit de926eb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "suuudokuuu",
"slug": "suuudokuuu",
"scheme": "myapp",
"version": "1.0.1",
"version": "1.1.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "automatic",
Expand Down
12 changes: 2 additions & 10 deletions app/loser/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { View } from 'react-native';

import { BlackButton } from '../../components/black-button/black-button';
import { Header } from '../../components/header/header';
import { PageHeader } from '../../components/page-header/page-header';
import { useAppDispatch } from '../../hooks/redux.hook';
import { appRootResetAction } from '../../store/app-root/app-root.actions';
import { PlayAgainButton } from '../../components/play-again-button/play-again-button';

import { LoserStyles as styles } from './loser.styles';

export default function Loser() {
const dispatch = useAppDispatch();

const handlePlayAgain = () => {
dispatch(appRootResetAction);
};

return (
<View style={styles.container}>
<PageHeader title="Looooooser! =)" />
<Header text="Better next time! Loooooser =)" />
<BlackButton text={'Play again'} onPress={handlePlayAgain} href={'/'} />
<PlayAgainButton />
</View>
);
}
4 changes: 2 additions & 2 deletions app/winner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { View } from 'react-native';

import { BlackButton } from '../../components/black-button/black-button';
import { Header } from '../../components/header/header';
import { PageHeader } from '../../components/page-header/page-header';
import { PlayAgainButton } from '../../components/play-again-button/play-again-button';

import { WinnerStyles as styles } from './winner.styles';

Expand All @@ -11,7 +11,7 @@ export default function Winner() {
<View style={styles.container}>
<PageHeader title="Winner!" />
<Header text="Winner-winner, chicken dinner!" />
<BlackButton text={'Play again'} href={'/'} />
<PlayAgainButton />
</View>
);
}
13 changes: 13 additions & 0 deletions components/play-again-button/play-again-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useAppDispatch } from '../../hooks/redux.hook';
import { appRootResetAction } from '../../store/app-root/app-root.actions';
import { BlackButton } from '../black-button/black-button';

export const PlayAgainButton = () => {
const dispatch = useAppDispatch();

const handlePlayAgain = () => {
dispatch(appRootResetAction());
};

return <BlackButton text="Play again" onPress={handlePlayAgain} href="/" />;
};

0 comments on commit de926eb

Please sign in to comment.