Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Configure/Configure.js
// Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
import React, { useState, useEffect } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import styled from 'styled-components'; | import styled from 'styled-components'; | ||||
import { useLocation, Link } from 'react-router-dom'; | import { useLocation, Link } from 'react-router-dom'; | ||||
import { Collapse, Form, Alert, Switch, Tooltip, Checkbox } from 'antd'; | import { Collapse, Form, Alert, Tooltip, Checkbox } from 'antd'; | ||||
import { Row, Col } from 'antd'; | import { Row, Col } from 'antd'; | ||||
import { CheckOutlined, CloseOutlined, LockFilled } from '@ant-design/icons'; | import { LockFilled } from '@ant-design/icons'; | ||||
import { WalletContext } from 'wallet/context'; | import { WalletContext } from 'wallet/context'; | ||||
import { SidePaddingCtn } from 'components/Common/Atoms'; | import { SidePaddingCtn } from 'components/Common/Atoms'; | ||||
import { StyledCollapse } from 'components/Common/StyledCollapse'; | import { StyledCollapse } from 'components/Common/StyledCollapse'; | ||||
import { | import { | ||||
AntdFormWrapper, | AntdFormWrapper, | ||||
CurrencySelectDropdown, | CurrencySelectDropdown, | ||||
} from 'components/Common/EnhancedInputs'; | } from 'components/Common/EnhancedInputs'; | ||||
import PrimaryButton, { | import PrimaryButton, { | ||||
Show All 35 Lines | import { | ||||
createCashtabWallet, | createCashtabWallet, | ||||
generateMnemonic, | generateMnemonic, | ||||
toXec, | toXec, | ||||
getWalletsForNewActiveWallet, | getWalletsForNewActiveWallet, | ||||
} from 'wallet'; | } from 'wallet'; | ||||
import CustomModal from 'components/Common/Modal'; | import CustomModal from 'components/Common/Modal'; | ||||
import { toast } from 'react-toastify'; | import { toast } from 'react-toastify'; | ||||
import { Input, ModalInput, InputFlex } from 'components/Common/Inputs'; | import { Input, ModalInput, InputFlex } from 'components/Common/Inputs'; | ||||
import CashtabSwitch from 'components/Common/Switch'; | |||||
const { Panel } = Collapse; | const { Panel } = Collapse; | ||||
const VersionContainer = styled.div` | const VersionContainer = styled.div` | ||||
color: ${props => props.theme.contrast}; | color: ${props => props.theme.contrast}; | ||||
`; | `; | ||||
const SWRow = styled.div` | const SWRow = styled.div` | ||||
▲ Show 20 Lines • Show All 813 Lines • ▼ Show 20 Lines | const renameContactByName = async contact => { | ||||
// Update localforage and state | // Update localforage and state | ||||
await updateCashtabState('contactList', contactList); | await updateCashtabState('contactList', contactList); | ||||
} else { | } else { | ||||
toast.error(`Unable to find contact`); | toast.error(`Unable to find contact`); | ||||
} | } | ||||
}; | }; | ||||
const handleSendModalToggle = checkedState => { | const handleSendModalToggle = e => { | ||||
updateCashtabState('settings', { | updateCashtabState('settings', { | ||||
...settings, | ...settings, | ||||
sendModal: checkedState, | sendModal: e.target.checked, | ||||
}); | }); | ||||
}; | }; | ||||
const handleMinFeesToggle = checkedState => { | const handleMinFeesToggle = e => { | ||||
updateCashtabState('settings', { | updateCashtabState('settings', { | ||||
...settings, | ...settings, | ||||
minFeeSends: checkedState, | minFeeSends: e.target.checked, | ||||
}); | }); | ||||
}; | }; | ||||
const handleCameraOverride = checkedState => { | const handleCameraOverride = e => { | ||||
updateCashtabState('settings', { | updateCashtabState('settings', { | ||||
...settings, | ...settings, | ||||
autoCameraOn: checkedState, | autoCameraOn: e.target.checked, | ||||
}); | }); | ||||
}; | }; | ||||
const handleUnknownSenderMsg = checkedState => { | const handleUnknownSenderMsg = e => { | ||||
updateCashtabState('settings', { | updateCashtabState('settings', { | ||||
...settings, | ...settings, | ||||
hideMessagesFromUnknownSenders: checkedState, | hideMessagesFromUnknownSenders: e.target.checked, | ||||
}); | }); | ||||
}; | }; | ||||
const getContactNameByAddress = contactAddress => { | const getContactNameByAddress = contactAddress => { | ||||
if (!contactAddress) { | if (!contactAddress) { | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 712 Lines • ▼ Show 20 Lines | return ( | ||||
<h2> | <h2> | ||||
<ThemedSettingOutlined /> General Settings | <ThemedSettingOutlined /> General Settings | ||||
</h2> | </h2> | ||||
<GeneralSettingsItem> | <GeneralSettingsItem> | ||||
<SettingsLabel> | <SettingsLabel> | ||||
<LockFilled /> Send Confirmations | <LockFilled /> Send Confirmations | ||||
</SettingsLabel> | </SettingsLabel> | ||||
<SwitchContainer> | <SwitchContainer> | ||||
<Switch | <CashtabSwitch | ||||
data-testid="send-confirmations-switch" | name="send-confirmations-switch" | ||||
size="small" | small | ||||
checkedChildren={<CheckOutlined />} | checked={settings.sendModal} | ||||
unCheckedChildren={<CloseOutlined />} | handleToggle={handleSendModalToggle} | ||||
checked={settings ? settings.sendModal : false} | |||||
onChange={handleSendModalToggle} | |||||
/> | /> | ||||
</SwitchContainer> | </SwitchContainer> | ||||
</GeneralSettingsItem> | </GeneralSettingsItem> | ||||
{isMobile(navigator) && ( | {isMobile(navigator) && ( | ||||
<GeneralSettingsItem> | <GeneralSettingsItem> | ||||
<SettingsLabel> | <SettingsLabel> | ||||
<LockFilled /> Auto-open camera on send | <LockFilled /> Auto-open camera on send | ||||
</SettingsLabel> | </SettingsLabel> | ||||
<SwitchContainer> | <SwitchContainer> | ||||
<Switch | <CashtabSwitch | ||||
size="small" | name="settings-camera-auto-open" | ||||
checkedChildren={<CheckOutlined />} | small | ||||
unCheckedChildren={<CloseOutlined />} | checked={settings.autoCameraOn} | ||||
checked={ | handleToggle={handleCameraOverride} | ||||
settings ? settings.autoCameraOn : false | |||||
} | |||||
onChange={handleCameraOverride} | |||||
/> | /> | ||||
</SwitchContainer> | </SwitchContainer> | ||||
</GeneralSettingsItem> | </GeneralSettingsItem> | ||||
)} | )} | ||||
<GeneralSettingsItem> | <GeneralSettingsItem> | ||||
<SettingsLabel> | <SettingsLabel> | ||||
<LockFilled /> Hide msgs from unknown sender | <LockFilled /> Hide msgs from unknown sender | ||||
</SettingsLabel> | </SettingsLabel> | ||||
<SwitchContainer> | <SwitchContainer> | ||||
<Switch | <CashtabSwitch | ||||
size="small" | name="hideMessagesFromUnknownSenders" | ||||
checkedChildren={<CheckOutlined />} | small | ||||
unCheckedChildren={<CloseOutlined />} | checked={settings.hideMessagesFromUnknownSenders} | ||||
checked={ | handleToggle={handleUnknownSenderMsg} | ||||
settings | |||||
? settings.hideMessagesFromUnknownSenders | |||||
: false | |||||
} | |||||
onChange={handleUnknownSenderMsg} | |||||
/> | /> | ||||
</SwitchContainer> | </SwitchContainer> | ||||
</GeneralSettingsItem> | </GeneralSettingsItem> | ||||
{hasEnoughToken( | {hasEnoughToken( | ||||
tokens, | tokens, | ||||
appConfig.vipSettingsTokenId, | appConfig.vipSettingsTokenId, | ||||
appConfig.vipSettingsTokenQty, | appConfig.vipSettingsTokenQty, | ||||
Show All 9 Lines | return ( | ||||
<h2>VIP Settings</h2> | <h2>VIP Settings</h2> | ||||
</VIPSettingsHolder> | </VIPSettingsHolder> | ||||
<GeneralSettingsItem> | <GeneralSettingsItem> | ||||
<SettingsLabel> | <SettingsLabel> | ||||
{' '} | {' '} | ||||
<LockFilled /> ABSOLUTE MINIMUM fees | <LockFilled /> ABSOLUTE MINIMUM fees | ||||
</SettingsLabel> | </SettingsLabel> | ||||
<SwitchContainer> | <SwitchContainer> | ||||
<Switch | <CashtabSwitch | ||||
data-testid="settings-minFeeSends-switch" | name="settings-minFeeSends-switch" | ||||
size="small" | small | ||||
checkedChildren={<CheckOutlined />} | checked={settings.minFeeSends} | ||||
unCheckedChildren={<CloseOutlined />} | handleToggle={handleMinFeesToggle} | ||||
checked={ | |||||
settings ? settings.minFeeSends : false | |||||
} | |||||
onChange={handleMinFeesToggle} | |||||
/> | /> | ||||
</SwitchContainer> | </SwitchContainer> | ||||
</GeneralSettingsItem> | </GeneralSettingsItem> | ||||
</> | </> | ||||
)} | )} | ||||
<StyledSpacer /> | <StyledSpacer /> | ||||
<SocialContainer> | <SocialContainer> | ||||
Show All 37 Lines |