-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show alert modal before leaving general settings page
- Loading branch information
Showing
4 changed files
with
197 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Icon } from 'antd' | ||
import { ModalBlur } from '../../components' | ||
|
||
const modal = ({ | ||
visible, | ||
onCancel, | ||
onOk, | ||
changedSettings, | ||
}) => { | ||
const modalOpts = { | ||
title: 'Leave General Settings ?', | ||
visible, | ||
onCancel, | ||
onOk, | ||
okText: 'Leave', | ||
} | ||
|
||
return ( | ||
<ModalBlur {...modalOpts}> | ||
<p type="warning"> | ||
<Icon style={{ marginRight: '10px' }} type="exclamation-circle" /> | ||
You have unsaved changes below. | ||
</p> | ||
<ul> | ||
{Object.keys(changedSettings).sort().map((key) => ( | ||
<li key={key}> | ||
{`${key}`} : <strong>{`${changedSettings[key]}`}</strong> | ||
</li> | ||
))} | ||
</ul> | ||
<p>Are you sure you want to leave this page?</p> | ||
</ModalBlur> | ||
) | ||
} | ||
|
||
modal.propTypes = { | ||
visible: PropTypes.bool, | ||
onCancel: PropTypes.func, | ||
onOk: PropTypes.func, | ||
changedSettings: PropTypes.object, | ||
} | ||
|
||
export default modal |
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