fix(#in261): future mathces click disabled for virt user

pull/74/head
Farber Denis 3 years ago
parent a47ccbbe3e
commit 07c928ab97
  1. 6
      src/features/Matches/helpers/getMatchClickAction/index.tsx

@ -1,6 +1,7 @@
import type { Match } from 'requests'
import type { User } from 'oidc-client'
import { isFuture } from 'date-fns'
export enum MatchAccess {
CanBuyMatch = 'CanBuyMatch',
@ -21,7 +22,12 @@ export const getMatchAccess = (match: Match, user: User | undefined) => {
const dateToMs = Date.parse(date?.replace(/ /, 'T')) // без замены не будет работать в сафари
const dateNowMin10 = dateToMs - 10 * 60 * 1000
const matchDate = new Date(date)
const isFutureDate = isFuture(matchDate)
switch (true) {
case !user && isFutureDate:
return MatchAccess.NoAccess
case !user:
return MatchAccess.ViewMatchPopupWithoutUser
case !sub:

Loading…
Cancel
Save