import type { Match } from 'requests'

export enum MatchAccess {
  CanBuyMatch = 'CanBuyMatch',
  NoAccess = 'NoAccess',
  NoCountryAccess = 'NoCountryAccess',
  RedirectToProfile = 'RedirectToProfile',
  ViewMatchPopup = 'ViewMatchPopup',
}

export const getMatchAccess = ({
  access,
  calc,
  has_video,
  live,
  storage,
  sub,
}: Match) => {
  switch (true) {
    case !sub:
      return MatchAccess.CanBuyMatch
    case !access:
      return MatchAccess.NoCountryAccess
    case calc || has_video || storage:
      return MatchAccess.RedirectToProfile
    case live:
      return MatchAccess.ViewMatchPopup
    default:
      return MatchAccess.NoAccess
  }
}
