select instead of dropdown for currency

This commit is contained in:
keyan 2022-10-04 16:21:42 -05:00
parent 0ff9bbc92d
commit 729bcead69
4 changed files with 20 additions and 25 deletions

View File

@ -136,7 +136,7 @@ export default function Footer ({ noLinks }) {
? <Sun onClick={() => darkMode.toggle()} className='fill-grey theme' /> ? <Sun onClick={() => darkMode.toggle()} className='fill-grey theme' />
: <Moon onClick={() => darkMode.toggle()} className='fill-grey theme' />} : <Moon onClick={() => darkMode.toggle()} className='fill-grey theme' />}
</div>} </div>}
<div className='mb-2' style={{ fontWeight: 500 }}> <div className='mb-0' style={{ fontWeight: 500 }}>
<OverlayTrigger trigger='click' placement='top' overlay={AnalyticsPopover} rootClose> <OverlayTrigger trigger='click' placement='top' overlay={AnalyticsPopover} rootClose>
<div className='nav-link p-0 d-inline-flex' style={{ cursor: 'pointer' }}> <div className='nav-link p-0 d-inline-flex' style={{ cursor: 'pointer' }}>
analytics analytics

View File

@ -430,20 +430,14 @@ export function SyncForm ({
) )
} }
export function Dropdown ({ label, items, groupClassName, ...props }) { export function Select ({ label, items, groupClassName, ...props }) {
const [field, _, helper] = useField({ ...props, type: 'input' }) const [field] = useField(props)
return ( return (
<FormGroup label={label} className={groupClassName}> <FormGroup label={label} className={groupClassName}>
<BootstrapDropdown> <BootstrapForm.Control as='select' custom {...field} {...props}>
<BootstrapDropdown.Toggle> {items.map(item => <option key={item}>{item}</option>)}
{field.value} </BootstrapForm.Control>
</BootstrapDropdown.Toggle>
<BootstrapDropdown.Menu>
{items.map(item => (
<BootstrapDropdown.Item onSelect={() => helper.setValue(item)}>{item}</BootstrapDropdown.Item>
))}
</BootstrapDropdown.Menu>
</BootstrapDropdown>
</FormGroup> </FormGroup>
) )
} }

View File

@ -11,12 +11,12 @@ export const PriceContext = React.createContext({
}) })
export const CURRENCY_SYMBOLS = { export const CURRENCY_SYMBOLS = {
'AUD': '$', AUD: '$',
'CAD': '$', CAD: '$',
'EUR': '€', EUR: '€',
'GBP': '£', GBP: '£',
'USD': '$', USD: '$',
'NZD': '$' NZD: '$'
} }
const endpoint = (fiat) => `https://api.coinbase.com/v2/prices/BTC-${fiat ?? 'USD'}/spot` const endpoint = (fiat) => `https://api.coinbase.com/v2/prices/BTC-${fiat ?? 'USD'}/spot`
@ -58,7 +58,7 @@ export default function Price () {
}, []) }, [])
const price = usePrice() const price = usePrice()
const me = useMe() const me = useMe()
const fiatSymbol = CURRENCY_SYMBOLS[me?.fiatCurrency || 'USD']; const fiatSymbol = CURRENCY_SYMBOLS[me?.fiatCurrency || 'USD']
if (!price) return null if (!price) return null

View File

@ -1,4 +1,4 @@
import { Checkbox, Form, Input, SubmitButton, Dropdown } from '../components/form' import { Checkbox, Form, Input, SubmitButton, Select } from '../components/form'
import * as Yup from 'yup' import * as Yup from 'yup'
import { Alert, Button, InputGroup, Modal } from 'react-bootstrap' import { Alert, Button, InputGroup, Modal } from 'react-bootstrap'
import LayoutCenter from '../components/layout-center' import LayoutCenter from '../components/layout-center'
@ -71,8 +71,8 @@ export default function Settings ({ data: { settings } }) {
greeterMode: settings?.greeterMode greeterMode: settings?.greeterMode
}} }}
schema={SettingsSchema} schema={SettingsSchema}
onSubmit={async ({ tipDefault, fiatCurrency, ...values }) => { onSubmit={async ({ tipDefault, ...values }) => {
await setSettings({ variables: { tipDefault: Number(tipDefault), fiatCurrency, ...values } }) await setSettings({ variables: { tipDefault: Number(tipDefault), ...values } })
setSuccess('settings saved') setSuccess('settings saved')
}} }}
> >
@ -84,9 +84,10 @@ export default function Settings ({ data: { settings } }) {
autoFocus autoFocus
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>} append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
/> />
<Dropdown <Select
label='fiat currency' label='fiat currency'
name='fiatCurrency' name='fiatCurrency'
size='sm'
items={supportedCurrencies} items={supportedCurrencies}
required required
/> />