Disable address autofill option
This commit is contained in:
parent
7125ca89d4
commit
2dd97ee953
3 changed files with 39 additions and 3 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
|
import { ChangeEvent } from 'react'
|
||||||
import { Label, Checkbox } from 'theme-ui'
|
import { Label, Checkbox } from 'theme-ui'
|
||||||
|
|
||||||
interface CheckBoxProps {
|
interface CheckBoxProps {
|
||||||
title: string
|
title: string
|
||||||
onChange?: () => void
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
||||||
checked?: boolean
|
checked?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
17
src/Popup/Pages/AutofillPage/handleAutofillAddress.ts
Normal file
17
src/Popup/Pages/AutofillPage/handleAutofillAddress.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
const handleAutofillAddress = (value: boolean) => {
|
||||||
|
console.log(!value)
|
||||||
|
chrome.privacy.services.autofillAddressEnabled.clear({}, () => {
|
||||||
|
chrome.privacy.services.autofillAddressEnabled.set(
|
||||||
|
{
|
||||||
|
value: !value,
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
chrome.storage.local.set({
|
||||||
|
autofillAddress: value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default handleAutofillAddress
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Text } from 'theme-ui'
|
import { Text } from 'theme-ui'
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect, ChangeEvent } from 'react'
|
||||||
import Page from '../../Components/Page'
|
import Page from '../../Components/Page'
|
||||||
import CheckBox from '../../Components/CheckBox'
|
import CheckBox from '../../Components/CheckBox'
|
||||||
// import { autofillData } from '../../../types'
|
// import { autofillData } from '../../../types'
|
||||||
|
|
@ -8,6 +8,7 @@ import TableRow from '../../Components/TableRow'
|
||||||
import { Button } from 'theme-ui'
|
import { Button } from 'theme-ui'
|
||||||
import addresses from '../../../utils/addresses'
|
import addresses from '../../../utils/addresses'
|
||||||
import FooterLink from '../../Components/FooterLink'
|
import FooterLink from '../../Components/FooterLink'
|
||||||
|
import handleAutofillAddress from './handleAutofillAddress'
|
||||||
|
|
||||||
interface AutofillPageProps {
|
interface AutofillPageProps {
|
||||||
tab: string
|
tab: string
|
||||||
|
|
@ -16,6 +17,7 @@ interface AutofillPageProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const AutofillPage = ({ tab, autofillData }: AutofillPageProps) => {
|
const AutofillPage = ({ tab, autofillData }: AutofillPageProps) => {
|
||||||
|
const [autofillAddress, setAutofillAddress] = useState(false)
|
||||||
const [country, setCountry] = useState('')
|
const [country, setCountry] = useState('')
|
||||||
const [city, setCity] = useState('')
|
const [city, setCity] = useState('')
|
||||||
const [region, setRegion] = useState('')
|
const [region, setRegion] = useState('')
|
||||||
|
|
@ -24,6 +26,12 @@ const AutofillPage = ({ tab, autofillData }: AutofillPageProps) => {
|
||||||
const [phone, setPhone] = useState('9057814565')
|
const [phone, setPhone] = useState('9057814565')
|
||||||
// const [configuration, setConfiguration] = useState('default')
|
// const [configuration, setConfiguration] = useState('default')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
chrome.storage.local.get(['autofillAddress'], (storage) => {
|
||||||
|
storage.autofillAddress && setAutofillAddress(storage.autofillAddress)
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// chrome.storage.local.get(['configuration', 'autofillData'], (storage) => {
|
// chrome.storage.local.get(['configuration', 'autofillData'], (storage) => {
|
||||||
// storage.configuration && setConfiguration(storage.configuration)
|
// storage.configuration && setConfiguration(storage.configuration)
|
||||||
|
|
@ -103,9 +111,19 @@ const AutofillPage = ({ tab, autofillData }: AutofillPageProps) => {
|
||||||
// // }
|
// // }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
const changeCheckBoxValue = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
console.log(e.target.checked)
|
||||||
|
handleAutofillAddress(e.target.checked)
|
||||||
|
setAutofillAddress(e.target.checked)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page isCurrentTab={tab === 'autofill'} title={'Autofill'}>
|
<Page isCurrentTab={tab === 'autofill'} title={'Autofill'}>
|
||||||
<CheckBox title={'Disable Built-In Address Autofill'} />
|
<CheckBox
|
||||||
|
title={'Disable Built-In Address Autofill'}
|
||||||
|
onChange={changeCheckBoxValue}
|
||||||
|
checked={autofillAddress}
|
||||||
|
/>
|
||||||
{/* <CheckBox title={'Automatically Autofill'} /> */}
|
{/* <CheckBox title={'Automatically Autofill'} /> */}
|
||||||
<Table>
|
<Table>
|
||||||
<TableRow title="Country" value={country} />
|
<TableRow title="Country" value={country} />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue