Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change network confirmation #212

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions src/view/components/ConfirmationDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,52 @@ import {
DialogTitle,
DialogContent,
DialogActions,
Button
Button,
Typography,
Box
} from '@mui/material'
import { title } from 'process'

const style = {
backgroundColor: 'background.paper'
}

interface ConfirmationDialogProps {
open: boolean
onClose: () => void
onConfirm: () => void
message?: string
title?: string
}

const TEXT_CONFIRM = 'Be sure you want to perform this action?'
const TITLE_CONFIRM = 'Confirm to continue'
const TEXT_CONFIRM = 'Are you sure you want to continue?'

function ConfirmationDialog({
open,
onClose,
onConfirm,
message = TEXT_CONFIRM
message = TEXT_CONFIRM,
title = TITLE_CONFIRM
}: ConfirmationDialogProps) {
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>Confirm Action</DialogTitle>
<DialogContent>
<p>{message}</p>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Cancel</Button>
<Button onClick={onConfirm}>Confirm</Button>
</DialogActions>
<Box sx={style}>
<DialogTitle>
<Typography variant="h5" color="white">
{title}
</Typography>
</DialogTitle>
<DialogContent>
<Typography variant="body1" color="white">
{message}
</Typography>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Cancel</Button>
<Button onClick={onConfirm}>Confirm</Button>
</DialogActions>
</Box>
</Dialog>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/view/components/WalletConnectButton/NetworkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ export function NetworkSelect({
<ConfirmationDialog
open={isOpen}
onClose={closeModal}
title="Change Network confirmation"
message="Are you sure you want to change the network?"
onConfirm={() => {
closeModal()
router.replace(ROUTES.HOME)
onChange(newChainId)
}}
/>
Expand Down
Loading