import React from 'react' import Modal from './Modal' import { ElementTitle } from './styles' import Button from './Button' import Input from './Input' import useMangoStore from '../stores/useMangoStore' import useLocalStorageState from '../hooks/useLocalStorageState' import Select from './Select' const NODE_URLS = [ { label: 'Mango Node', value: 'https://mango.rpcpool.com' }, { label: 'Genesys Go', value: 'https://lokidfxnwlabdq.main.genesysgo.net:8899/', }, { label: 'Project Serum', value: 'https://solana-api.projectserum.com/', }, { label: 'Custom', value: '' }, ] const CUSTOM_NODE = NODE_URLS.find((n) => n.label === 'Custom') export const NODE_URL_KEY = 'node-url-key-0.4' const SettingsModal = ({ isOpen, onClose }) => { const actions = useMangoStore((s) => s.actions) const [rpcEndpointUrl, setRpcEndpointUrl] = useLocalStorageState( NODE_URL_KEY, NODE_URLS[0].value ) const rpcEndpoint = NODE_URLS.find((node) => node.value === rpcEndpointUrl) || CUSTOM_NODE console.log('rpcEndpoint', rpcEndpointUrl) const handleSetEndpointUrl = (endpointUrl) => { setRpcEndpointUrl(endpointUrl) actions.updateConnection(endpointUrl) onClose() } const handleSelectEndpointUrl = (url) => { setRpcEndpointUrl(url) } return ( Advanced Settings
{rpcEndpoint.label === 'Custom' ? ( setRpcEndpointUrl(e.target.value)} prefix="RPC Node URL" /> ) : null}
) } export default React.memo(SettingsModal)