import type { ReactNode } from 'react'
import { createContext, useContext } from 'react'

import { useBuyMatchPopup } from './hooks'

type Context = ReturnType<typeof useBuyMatchPopup>
type Props = { children: ReactNode }

const BuyMatchPopupContext = createContext({} as Context)

export const BuyMatchPopupStore = ({ children }: Props) => {
  const value = useBuyMatchPopup()
  return (
    <BuyMatchPopupContext.Provider value={value}>
      {children}
    </BuyMatchPopupContext.Provider>
  )
}

export const useBuyMatchPopupStore = () => useContext(BuyMatchPopupContext)
