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: