mango-v4-ui/components/settings/PreferredExplorerSettings.tsx

50 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-11-24 18:39:14 -08:00
import { CheckCircleIcon } from '@heroicons/react/20/solid'
import useLocalStorageState from 'hooks/useLocalStorageState'
import { useTranslation } from 'next-i18next'
import Image from 'next/image'
import { PREFERRED_EXPLORER_KEY } from 'utils/constants'
export const EXPLORERS = [
{ name: 'solana-explorer', url: 'https://explorer.solana.com/tx/' },
{ name: 'solscan', url: 'https://solscan.io/tx/' },
{ name: 'solana-beach', url: 'https://solanabeach.io/transaction/' },
{ name: 'solanafm', url: 'https://solana.fm/tx/' },
]
const PreferredExplorerSettings = () => {
const { t } = useTranslation('settings')
const [preferredExplorer, setPreferredExplorer] = useLocalStorageState(
PREFERRED_EXPLORER_KEY,
2023-07-21 11:47:53 -07:00
EXPLORERS[0],
2022-11-24 18:39:14 -08:00
)
return (
<>
<h2 className="mb-4 text-base">{t('settings:preferred-explorer')}</h2>
<div className="space-y-2">
{EXPLORERS.map((ex) => (
<button
2023-06-01 23:05:08 -07:00
className="flex w-full items-center justify-between rounded-md border border-th-bkg-4 p-4 hover:border-th-fgd-4"
2022-11-24 18:39:14 -08:00
onClick={() => setPreferredExplorer(ex)}
key={ex.name}
>
<div className="flex items-center space-x-2">
<Image
alt=""
width="24"
height="24"
src={`/explorer-logos/${ex.name}.png`}
/>
<p>{t(`settings:${ex.name}`)}</p>
</div>
{preferredExplorer.url === ex.url ? (
2022-11-30 19:46:37 -08:00
<CheckCircleIcon className="h-5 w-5 text-th-success" />
2022-11-24 18:39:14 -08:00
) : null}
</button>
))}
</div>
</>
)
}
export default PreferredExplorerSettings