import Loading from '@components/shared/Loading' import { XMarkIcon } from '@heroicons/react/20/solid' import { useWallet } from '@solana/wallet-adapter-react' import mangoStore from '@store/mangoStore' import { useState } from 'react' import { MANGO_DATA_API_URL } from 'utils/constants' import { WalktourLogic } from 'walktour' const CustomTooltip = ({ customOnClose, hasSeenKey, tourLogic, }: { customOnClose?: () => void hasSeenKey: 'account_tour_seen' | 'swap_tour_seen' | 'trade_tour_seen' tourLogic: WalktourLogic | undefined }) => { const { title, description } = tourLogic!.stepContent const { next, prev, close, allSteps, stepIndex } = tourLogic! const { publicKey } = useWallet() const actions = mangoStore.getState().actions const tourSettings = mangoStore((s) => s.settings.tours) const [loading, setLoading] = useState(false) const onClose = async () => { if (!publicKey) return if (tourSettings) { setLoading(true) try { const settings = { ...tourSettings, } settings[hasSeenKey] = true const message = JSON.stringify(settings) const requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: message, } const response = await fetch( `${MANGO_DATA_API_URL}/user-data/settings-unsigned`, requestOptions, ) if (response.status === 200) { await actions.fetchTourSettings(publicKey.toString()) } } catch (e) { console.error(e) } finally { if (customOnClose) { customOnClose() } setLoading(false) close() } } else close() } return (
{!loading ? ( <>

{title}

{description}

{stepIndex !== 0 ? ( ) : (
)}
{allSteps.map((s, i) => (
))}
{stepIndex !== allSteps.length - 1 ? ( ) : ( )}
) : (
)}
) } export default CustomTooltip