feat(ott-2616): time format changed

keep-around/d190b869cb1410814463052a6e32995d92ec5e8a
PolyakovaM 3 years ago
parent 54643fac09
commit d190b869cb
  1. 33772
      package-lock.json
  2. 11
      src/features/MatchCard/CardFrontside/MatchCardMobile/index.tsx
  3. 11
      src/features/MatchCard/CardFrontside/index.tsx
  4. 17
      src/features/MatchCard/helpers/index.tsx
  5. 7
      src/features/MatchCard/hooks.tsx
  6. 7
      src/features/MatchCard/index.tsx

33772
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -13,6 +13,7 @@ import { MatchAccess } from 'features/Matches/helpers/getMatchClickAction'
import { useUserFavoritesStore } from 'features/UserFavorites/store' import { useUserFavoritesStore } from 'features/UserFavorites/store'
import { NoAccessMessage } from '../../NoAccessMessage' import { NoAccessMessage } from '../../NoAccessMessage'
import { getPrepareTimeFormat } from '../../helpers'
import { import {
CardWrapperOuter, CardWrapperOuter,
CardWrapper, CardWrapper,
@ -39,12 +40,14 @@ import {
import { useCardPreview } from '../hooks' import { useCardPreview } from '../hooks'
type Props = { type Props = {
isNeedFormatTimeChanged: boolean,
match: Match, match: Match,
onClick: () => void, onClick: () => void,
onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void, onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void,
} }
export const CardFrontsideMobile = ({ export const CardFrontsideMobile = ({
isNeedFormatTimeChanged,
match, match,
onClick, onClick,
onKeyPress, onKeyPress,
@ -78,6 +81,12 @@ export const CardFrontsideMobile = ({
previewURL, previewURL,
}) })
const prepareTime = getPrepareTimeFormat({
date,
isNeedFormatTimeChanged,
time,
})
return ( return (
<CardWrapperOuter onClick={onClick} onKeyPress={onKeyPress}> <CardWrapperOuter onClick={onClick} onKeyPress={onKeyPress}>
<CardWrapper> <CardWrapper>
@ -135,7 +144,7 @@ export const CardFrontsideMobile = ({
</Team> </Team>
</Teams> </Teams>
<SecondaryInfo> <SecondaryInfo>
<Time>{time}</Time> <Time>{prepareTime}</Time>
{access === MatchAccess.CanBuyMatch && ( {access === MatchAccess.CanBuyMatch && (
<BuyMatchBadge> <BuyMatchBadge>
<ScDollar refIcon='Dollar' /> <ScDollar refIcon='Dollar' />

@ -39,14 +39,17 @@ import {
HoverFrame, HoverFrame,
} from '../styled' } from '../styled'
import { useCardPreview } from './hooks' import { useCardPreview } from './hooks'
import { getPrepareTimeFormat } from '../helpers'
type Props = { type Props = {
isNeedFormatTimeChanged: boolean,
match: Match, match: Match,
onClick: () => void, onClick: () => void,
onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void, onKeyPress: (e: KeyboardEvent<HTMLLIElement>) => void,
} }
export const CardFrontside = ({ export const CardFrontside = ({
isNeedFormatTimeChanged,
match, match,
onClick, onClick,
onKeyPress, onKeyPress,
@ -84,6 +87,12 @@ export const CardFrontside = ({
previewURL, previewURL,
}) })
const prepareTime = getPrepareTimeFormat({
date,
isNeedFormatTimeChanged,
time,
})
return ( return (
<CardWrapperOuter <CardWrapperOuter
onClick={onClick} onClick={onClick}
@ -122,7 +131,7 @@ export const CardFrontside = ({
<MatchTimeInfo> <MatchTimeInfo>
<MatchDate isHomePage={isHomePage}> <MatchDate isHomePage={isHomePage}>
{isHomePage || isMatchPage ? null : formattedDate} {isHomePage || isMatchPage ? null : formattedDate}
<Time>{time}</Time> <Time>{prepareTime}</Time>
</MatchDate> </MatchDate>
{live && ( {live && (
<LiveSign> <LiveSign>

@ -0,0 +1,17 @@
import format from 'date-fns/format'
type prepareTimeFormat = {
date: Date,
isNeedFormatTimeChanged: boolean,
time: string,
}
export const getPrepareTimeFormat = ({
date,
isNeedFormatTimeChanged,
time,
}: prepareTimeFormat) => (
isNeedFormatTimeChanged
? format(date, 'hh:mm aaa')
: time
)

@ -2,11 +2,14 @@ import type { KeyboardEvent } from 'react'
import { useCallback } from 'react' import { useCallback } from 'react'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import includes from 'lodash/includes'
import { ProfileTypes } from 'config' import { ProfileTypes } from 'config'
import type { Match } from 'features/Matches' import type { Match } from 'features/Matches'
import { useMatchPopupStore } from 'features/MatchPopup' import { useMatchPopupStore } from 'features/MatchPopup'
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup' import { useBuyMatchPopupStore } from 'features/BuyMatchPopup'
import { useAuthStore } from 'features/AuthStore'
import { getProfileUrl } from 'features/ProfileLink/helpers' import { getProfileUrl } from 'features/ProfileLink/helpers'
import { MatchAccess } from 'features/Matches/helpers/getMatchClickAction' import { MatchAccess } from 'features/Matches/helpers/getMatchClickAction'
@ -14,6 +17,7 @@ export const useCard = (match: Match) => {
const { openMatchPopup } = useMatchPopupStore() const { openMatchPopup } = useMatchPopupStore()
const { open: openBuyMatchPopup } = useBuyMatchPopupStore() const { open: openBuyMatchPopup } = useBuyMatchPopupStore()
const history = useHistory() const history = useHistory()
const { user } = useAuthStore()
const redirectToMatchPage = useCallback(() => { const redirectToMatchPage = useCallback(() => {
const matchLink = getProfileUrl({ const matchLink = getProfileUrl({
id: match.id, id: match.id,
@ -56,7 +60,10 @@ export const useCard = (match: Match) => {
} }
}, [onMatchClick]) }, [onMatchClick])
const isNeedFormatTimeChanged = includes(['US', 'CA'], user?.profile.country_code)
return { return {
isNeedFormatTimeChanged,
onKeyPress, onKeyPress,
onMatchClick, onMatchClick,
} }

@ -11,7 +11,11 @@ type Props = {
} }
export const MatchCard = ({ match }: Props) => { export const MatchCard = ({ match }: Props) => {
const { onKeyPress, onMatchClick } = useCard(match) const {
isNeedFormatTimeChanged,
onKeyPress,
onMatchClick,
} = useCard(match)
const CurrentComponent = isMobileDevice ? CardFrontsideMobile : CardFrontside const CurrentComponent = isMobileDevice ? CardFrontsideMobile : CardFrontside
@ -20,6 +24,7 @@ export const MatchCard = ({ match }: Props) => {
match={match} match={match}
onClick={onMatchClick} onClick={onMatchClick}
onKeyPress={onKeyPress} onKeyPress={onKeyPress}
isNeedFormatTimeChanged={isNeedFormatTimeChanged}
/> />
) )
} }

Loading…
Cancel
Save