-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into resource-popup-improvments
- Loading branch information
Showing
7 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/app/_components/_sharedcomponents/Popup/PopupVariant/LeaveGamePopup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { useGame } from '@/app/_contexts/Game.context'; | ||
import { usePopup } from '@/app/_contexts/Popup.context'; | ||
import { Box, Typography } from '@mui/material'; | ||
import { useRouter } from 'next/navigation'; | ||
import { | ||
containerStyle, | ||
footerStyle, | ||
headerStyle, | ||
textStyle, | ||
titleStyle, | ||
} from '../Popup.styles'; | ||
import PreferenceButton from '@/app/_components/_sharedcomponents/Preferences/_subComponents/PreferenceButton'; | ||
|
||
interface LeaveGamePopupProps { | ||
uuid: string; | ||
} | ||
|
||
export const LeaveGamePopupModule = ({ uuid }: LeaveGamePopupProps) => { | ||
const { sendMessage, gameState } = useGame(); | ||
const { closePopup } = usePopup(); | ||
const router = useRouter(); | ||
const hasWinner = !!gameState?.winner; | ||
const handleConfirm = () => { | ||
sendMessage('manualDisconnect'); | ||
closePopup(uuid); | ||
router.push('/'); | ||
}; | ||
|
||
const handleCancel = () => { | ||
closePopup(uuid); | ||
}; | ||
|
||
return ( | ||
<Box sx={containerStyle}> | ||
<Box sx={headerStyle(false)}> | ||
<Typography sx={titleStyle}>Leave Game</Typography> | ||
</Box> | ||
<Typography sx={textStyle}> | ||
{hasWinner ? 'Leave the game and return to homescreen?' : 'Leaving the game will concede.' } | ||
</Typography> | ||
<Box sx={footerStyle}> | ||
<PreferenceButton | ||
variant={'standard'} | ||
buttonFnc={handleCancel} | ||
text={'Cancel'} | ||
/> | ||
<PreferenceButton | ||
variant={'concede'} | ||
buttonFnc={handleConfirm} | ||
text={'Leave game'} | ||
/> | ||
|
||
</Box> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters