71 lines
2.0 KiB
JavaScript
71 lines
2.0 KiB
JavaScript
import { WalletSecurityBanner } from './banners'
|
|
import { Form } from './form'
|
|
import { CenterLayout } from './layout'
|
|
|
|
export default function WalletConfigurator ({ config }) {
|
|
const initial = config.provider
|
|
|
|
return (
|
|
<CenterLayout>
|
|
<h2 className='pb-2'>{config.title}</h2>
|
|
<h6 className='text-muted text-center pb-3'>use {config.title} for payments</h6>
|
|
<WalletSecurityBanner />
|
|
<Form
|
|
initial={{
|
|
url: url || '',
|
|
adminKey: adminKey || '',
|
|
isDefault: isDefault || false
|
|
}}
|
|
schema={lnbitsSchema}
|
|
onSubmit={async ({ isDefault, ...values }) => {
|
|
try {
|
|
await saveConfig(values)
|
|
if (isDefault) setProvider(lnbits)
|
|
toaster.success('saved settings')
|
|
router.push('/settings/wallets')
|
|
} catch (err) {
|
|
console.error(err)
|
|
toaster.danger('failed to attach: ' + err.message || err.toString?.())
|
|
}
|
|
}}
|
|
>
|
|
<ClientInput
|
|
initialValue={url}
|
|
label='lnbits url'
|
|
name='url'
|
|
required
|
|
autoFocus
|
|
/>
|
|
<PasswordInput
|
|
initialValue={adminKey}
|
|
label='admin key'
|
|
name='adminKey'
|
|
newPass
|
|
required
|
|
/>
|
|
<ClientCheckbox
|
|
disabled={!configured || isDefault || enabledProviders.length === 1}
|
|
initialValue={isDefault}
|
|
label='default payment method'
|
|
name='isDefault'
|
|
/>
|
|
<WalletButtonBar
|
|
status={status} onDelete={async () => {
|
|
try {
|
|
await clearConfig()
|
|
toaster.success('saved settings')
|
|
router.push('/settings/wallets')
|
|
} catch (err) {
|
|
console.error(err)
|
|
toaster.danger('failed to detach: ' + err.message || err.toString?.())
|
|
}
|
|
}}
|
|
/>
|
|
</Form>
|
|
<div className='mt-3 w-100'>
|
|
<WalletLogs wallet={Wallet.LNbits} embedded />
|
|
</div>
|
|
</CenterLayout>
|
|
)
|
|
}
|