keep-around/fd4227743b93a77fb3d734bbe696ff4792c77b97
commit
fd4227743b
@ -0,0 +1,5 @@ |
||||
import { Icon } from 'features/Icon' |
||||
|
||||
export const InfoIcon = () => ( |
||||
<Icon refIcon='Info' /> |
||||
) |
||||
@ -0,0 +1,84 @@ |
||||
import { |
||||
useEffect, |
||||
useState, |
||||
MouseEvent, |
||||
} from 'react' |
||||
|
||||
import { useHistory } from 'react-router-dom' |
||||
|
||||
import { ProfileTypes } from 'config' |
||||
|
||||
import isNumber from 'lodash/isNumber' |
||||
|
||||
import { useLexicsStore } from 'features/LexicsStore' |
||||
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup/store' |
||||
import { getProfileUrl } from 'features/ProfileLink/helpers' |
||||
|
||||
import { getMatchInfo } from 'requests/getMatchInfo' |
||||
import { getBrazilPaymentUrl } from 'requests/getBrazilPaymentUrl' |
||||
|
||||
import type { Props } from './index' |
||||
|
||||
type ResponsePayment = { |
||||
url: string, |
||||
} |
||||
|
||||
type ResponsePaymentArray = ResponsePayment | null |
||||
|
||||
export const useBrazilPayment = ({ |
||||
match, |
||||
open, |
||||
selectedPackage, |
||||
setIsOpenBrasilian, |
||||
}: Props) => { |
||||
const history = useHistory() |
||||
const { close } = useBuyMatchPopupStore() |
||||
|
||||
const [src, setSrc] = useState('') |
||||
const { translate } = useLexicsStore() |
||||
|
||||
const { id, sportType } = match |
||||
|
||||
const { |
||||
name, |
||||
nameLexic, |
||||
originalObject, |
||||
pass, |
||||
} = selectedPackage |
||||
|
||||
const teams = isNumber(nameLexic) ? translate(String(nameLexic)) : name |
||||
const pack = translate(String(pass)) |
||||
|
||||
const matchLink = getProfileUrl({ |
||||
id, |
||||
profileType: ProfileTypes.MATCHES, |
||||
sportType, |
||||
}) |
||||
|
||||
const closePopup = async (e?: MouseEvent) => { |
||||
e?.stopPropagation() |
||||
setIsOpenBrasilian(false) |
||||
|
||||
const accessMatch = await getMatchInfo(sportType, id) |
||||
if (accessMatch?.access) { |
||||
close() |
||||
history.push(matchLink) |
||||
} |
||||
} |
||||
|
||||
useEffect(() => { |
||||
if (open) { |
||||
(async () => { |
||||
const json: ResponsePaymentArray = await getBrazilPaymentUrl({ item: originalObject, product_name: `${pack} ${teams}` }) |
||||
setSrc(json?.url || '') |
||||
})() |
||||
} |
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedPackage, open]) |
||||
|
||||
return { |
||||
closePopup, |
||||
matchLink, |
||||
src, |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
import { InfoIcon } from 'components/InfoIcon/InfoIcon' |
||||
import styled, { css } from 'styled-components' |
||||
import { T9n } from 'features/T9n' |
||||
import { isMobileDevice } from 'config/userAgent' |
||||
|
||||
const Wrapper = styled.div` |
||||
display: flex; |
||||
color: rgba(255, 255, 255, 0.8); |
||||
font-size: 16px; |
||||
max-width: 340px; |
||||
margin-top: 50px; |
||||
|
||||
${isMobileDevice |
||||
? css` |
||||
margin-top: 25px; |
||||
font-size: 12px; |
||||
` |
||||
: ''} |
||||
` |
||||
|
||||
const WrapperIcon = styled.div` |
||||
margin-right: 10px; |
||||
` |
||||
|
||||
export const UnsubscribePrompt = () => ( |
||||
<Wrapper> |
||||
<WrapperIcon> |
||||
<InfoIcon /> |
||||
</WrapperIcon> |
||||
<T9n t='unsubscribe_prompt' /> |
||||
</Wrapper> |
||||
) |
||||
@ -0,0 +1,14 @@ |
||||
export const Info = () => ( |
||||
<svg |
||||
width='17' |
||||
height='17' |
||||
viewBox='0 0 17 17' |
||||
fill='none' |
||||
xmlns='http://www.w3.org/2000/svg' |
||||
> |
||||
<path |
||||
d='M8.5 1.0625C4.39277 1.0625 1.0625 4.39277 1.0625 8.5C1.0625 12.6072 4.39277 15.9375 8.5 15.9375C12.6072 15.9375 15.9375 12.6072 15.9375 8.5C15.9375 4.39277 12.6072 1.0625 8.5 1.0625ZM9.03125 12.0859C9.03125 12.159 8.97148 12.2188 8.89844 12.2188H8.10156C8.02852 12.2188 7.96875 12.159 7.96875 12.0859V7.57031C7.96875 7.49727 8.02852 7.4375 8.10156 7.4375H8.89844C8.97148 7.4375 9.03125 7.49727 9.03125 7.57031V12.0859ZM8.5 6.375C8.29147 6.37074 8.09292 6.28492 7.94695 6.13594C7.80098 5.98696 7.71923 5.7867 7.71923 5.57812C7.71923 5.36955 7.80098 5.16929 7.94695 5.02031C8.09292 4.87133 8.29147 4.78551 8.5 4.78125C8.70853 4.78551 8.90708 4.87133 9.05305 5.02031C9.19902 5.16929 9.28077 5.36955 9.28077 5.57812C9.28077 5.7867 9.19902 5.98696 9.05305 6.13594C8.90708 6.28492 8.70853 6.37074 8.5 6.375Z' |
||||
fill='white' |
||||
/> |
||||
</svg> |
||||
) |
||||
Loading…
Reference in new issue