From 07c928ab974be70ed3c43f58e4e5d75ce939a257 Mon Sep 17 00:00:00 2001 From: Farber Denis Date: Tue, 7 Feb 2023 16:19:25 +0300 Subject: [PATCH] fix(#in261): future mathces click disabled for virt user --- src/features/Matches/helpers/getMatchClickAction/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/features/Matches/helpers/getMatchClickAction/index.tsx b/src/features/Matches/helpers/getMatchClickAction/index.tsx index 4539f329..6f038e27 100644 --- a/src/features/Matches/helpers/getMatchClickAction/index.tsx +++ b/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: