From f15ea1c4662501db9444f1303f5b4dd0ef704a3d Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Sat, 14 Jan 2023 09:31:53 +0700 Subject: [PATCH 1/3] ci(autodeploy diwan): autodeploy diwan.insports --- .drone.yml | 110 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index cec503c6..20eb8052 100644 --- a/.drone.yml +++ b/.drone.yml @@ -172,32 +172,34 @@ steps: depends_on: - make-lff -# - name: make-diwansport -# image: node:16-alpine -# environment: -# REACT_APP_STRIPE_PK: -# from_secret: REACT_APP_STRIPE_PK -# commands: -# - apk add --no-cache make -# - make diwansport-prod -# depends_on: -# - npm-install -# -# - name: deploy-diwansport -# image: amazon/aws-cli:latest -# environment: -# AWS_ACCESS_KEY_ID: -# from_secret: AWS_ACCESS_KEY_ID -# AWS_SECRET_ACCESS_KEY: -# from_secret: AWS_SECRET_ACCESS_KEY -# AWS_DEFAULT_REGION: -# from_secret: AWS_DEFAULT_REGION -# AWS_MAX_ATTEMPTS: 10 -# commands: -# - aws s3 sync build_insports-diwansport s3://insports-diwansport --delete -# - aws cloudfront create-invalidation --distribution-id E3LKAH6TR4O2JL --paths "/*" -# depends_on: -# - make-diwansport + - name: make-diwansport + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - apk add --no-cache make + - make diwansport-prod + depends_on: + - npm-install + + - name: deploy-diwansport + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + AWS_MAX_ATTEMPTS: 10 + commands: + - aws s3 sync build_insports-diwansport s3://insports-diwansport --delete + - aws cloudfront create-invalidation --distribution-id E3LKAH6TR4O2JL --paths "/*" # # diwansport.net + - aws cloudfront create-invalidation --distribution-id E3NJ2G0QSB6MVI --paths "/*" # tunisia.insports.tv + + depends_on: + - make-diwansport --- kind: pipeline @@ -681,3 +683,59 @@ steps: - rsync -v -r -C build_auth/clients/* ubuntu@auth.test.insports.tv:/home/ubuntu/ott-auth/src/frontend/templates - aws s3 sync build_auth s3://auth-insports-test --delete - aws cloudfront create-invalidation --distribution-id E10YI3RFOZZDLZ --paths "/*" + + +--- +kind: pipeline +type: docker +name: deploy diwan.insports.tv + +concurrency: + limit: 1 + +platform: + os: linux + arch: amd64 + +trigger: + ref: + - refs/heads/diwan.insports.tv + +steps: + - name: npm-install + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - apk add --no-cache make + - npm install --legacy-peer-deps + + - name: make-diwansport + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - apk add --no-cache make + - make diwansport-prod + depends_on: + - npm-install + + - name: deploy-diwansport + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + AWS_MAX_ATTEMPTS: 10 + commands: + - aws s3 sync build_tunisia s3://insports-diwansport --delete + - aws cloudfront create-invalidation --distribution-id E3LKAH6TR4O2JL --paths "/*" # # diwansport.net + - aws cloudfront create-invalidation --distribution-id E3NJ2G0QSB6MVI --paths "/*" # tunisia.insports.tv + + depends_on: + - make-diwansport -- 2.30.2 From 8c28c0d1b3a23907d853f1c1c2a1a2a90a105a8c Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Sat, 14 Jan 2023 09:06:45 +0700 Subject: [PATCH 2/3] fix(#242): add route for get selected subscriptions --- .../components/SubscriptionGuard/index.tsx | 6 +++++- src/helpers/parseUrlParams/parseUrlParams.tsx | 5 +++++ src/requests/getSelectedSubscriptions.tsx | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/requests/getSelectedSubscriptions.tsx diff --git a/src/features/MatchPage/components/SubscriptionGuard/index.tsx b/src/features/MatchPage/components/SubscriptionGuard/index.tsx index 01286d17..61278d03 100644 --- a/src/features/MatchPage/components/SubscriptionGuard/index.tsx +++ b/src/features/MatchPage/components/SubscriptionGuard/index.tsx @@ -7,6 +7,7 @@ import { useBuyMatchPopupStore } from 'features/BuyMatchPopup' import { useMatchPageStore } from 'features/MatchPage/store' import { prepareMatchProfile } from '../../helpers/prepareMatchProfile' +import { checkUrlParams, getAllUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams' type Props = { children: ReactNode, @@ -18,7 +19,10 @@ export const SubscriptionGuard = ({ children }: Props) => { const { profileId: matchId, sportType } = usePageParams() useEffect(() => { - if (matchProfile && !matchProfile.sub) { + if (matchProfile && ( + !matchProfile.sub + || (checkUrlParams('subscribe') + && getAllUrlParams('id')))) { const profile = prepareMatchProfile({ matchId, profile: matchProfile, diff --git a/src/helpers/parseUrlParams/parseUrlParams.tsx b/src/helpers/parseUrlParams/parseUrlParams.tsx index f960c546..2d02baef 100644 --- a/src/helpers/parseUrlParams/parseUrlParams.tsx +++ b/src/helpers/parseUrlParams/parseUrlParams.tsx @@ -7,3 +7,8 @@ export const checkUrlParams = (key: string) => { const params = new URLSearchParams(window.location.search) return params.get(key) } + +export const getAllUrlParams = (key: string) => { + const params = new URLSearchParams(window.location.search) + return params.getAll(key) +} diff --git a/src/requests/getSelectedSubscriptions.tsx b/src/requests/getSelectedSubscriptions.tsx new file mode 100644 index 00000000..95050c6a --- /dev/null +++ b/src/requests/getSelectedSubscriptions.tsx @@ -0,0 +1,15 @@ +import { callApi } from 'helpers' +import { Subscriptions } from './getSubscriptions' +import { API_ROOT } from '../config' + +export const getSelectedSubscriptions = async ( +): Promise => { + const config = { + method: 'GET', + } + + return callApi({ + config, + url: `${API_ROOT}/v1/subscriptions${window.location.search}`, + }) +} -- 2.30.2 From 6c8bbf1933d6a91159380ad9be71ade9b096f90b Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Mon, 16 Jan 2023 23:28:10 +0700 Subject: [PATCH 3/3] fix($242): add subs for selected suvs --- .../components/SelectSubscription/index.tsx | 21 +++++++++----- .../store/hooks/useSubscriptions.tsx | 14 ++++++++- src/features/TournamentPage/hooks.tsx | 29 +++++++++++++++++-- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/features/BuyMatchPopup/components/SelectSubscription/index.tsx b/src/features/BuyMatchPopup/components/SelectSubscription/index.tsx index f7d746a0..40ba62df 100644 --- a/src/features/BuyMatchPopup/components/SelectSubscription/index.tsx +++ b/src/features/BuyMatchPopup/components/SelectSubscription/index.tsx @@ -32,6 +32,7 @@ import { ChooseSubItem, ChooseSubList, } from './styled' +import { checkUrlParams, getAllUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams' export const SelectSubscriptionStep = () => { const { @@ -55,14 +56,18 @@ export const SelectSubscriptionStep = () => { return (
- - - {` ${MDASH} `} - - - - - + {(!checkUrlParams('subscribe') + && !getAllUrlParams('id')) + && ( + + + {` ${MDASH} `} + + + + + + )} diff --git a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx index 0d063491..7e9710d1 100644 --- a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx +++ b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx @@ -22,6 +22,7 @@ import type { import { SubscriptionType } from '../../types' import { transformSubscriptions } from '../helpers' import { useSubscriptionsLexics } from './useSubscriptionsLexics' +import { checkUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams' const defaultSubscriptions: MatchSubscriptions = [] const defaultPeriod = SubscriptionType.Month @@ -36,6 +37,11 @@ const getInitialPeriod = (subscription?: MatchSubscription) => { || defaultPeriod } +export const MATCH_CONFIG = { + matchId: 2376841, + sportId: 1, +} + export const useSubscriptions = () => { const { suffix } = useLexicsStore() const { fetchLexics } = useSubscriptionsLexics() @@ -55,7 +61,13 @@ export const useSubscriptions = () => { ] = useState(null) const fetchSubscriptions = useCallback(async (match: Match) => { - const subscriptions = await getSubscriptions(match.sportType, match.id) + let subscriptions + if (checkUrlParams('id') && checkUrlParams('subscribe')) { + subscriptions = await getSubscriptions(MATCH_CONFIG.sportId, MATCH_CONFIG.matchId) + } else { + subscriptions = await getSubscriptions(match.sportType, match.id) + } + const convertedSubscriptions = transformSubscriptions({ match, subscriptions, diff --git a/src/features/TournamentPage/hooks.tsx b/src/features/TournamentPage/hooks.tsx index 0d6fa16e..bf414af0 100644 --- a/src/features/TournamentPage/hooks.tsx +++ b/src/features/TournamentPage/hooks.tsx @@ -6,19 +6,28 @@ import { import { useHistory } from 'react-router' import type { TournamentInfo } from 'requests' -import { getTournamentInfo, getTournamentMatches } from 'requests' +import { + getMatchInfo, + getTournamentInfo, + getTournamentMatches, + MatchInfo, +} from 'requests' -import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams' +import { checkUrlParams, getAllUrlParams } from 'helpers/parseUrlParams/parseUrlParams' import { usePageParams } from 'hooks/usePageParams' import { useName } from 'features/Name' import { isPermittedTournament } from '../../helpers/isPermittedTournament' import { useProfileCard } from '../ProfileCard/hooks' +import { useBuyMatchPopupStore } from '../BuyMatchPopup' +import { MATCH_CONFIG } from '../BuyMatchPopup/store/hooks/useSubscriptions' +import { prepareMatchProfile } from '../MatchPage/helpers/prepareMatchProfile' export const useTournamentPage = () => { const [tournamentProfile, setTournamentProfile] = useState(null) const { profileId: tournamentId, sportType } = usePageParams() + const { open: openBuyMatchPopup } = useBuyMatchPopupStore() const country = useName(tournamentProfile?.country || {}) const history = useHistory() @@ -63,6 +72,22 @@ export const useTournamentPage = () => { name_rus: tournamentProfile.name_rus, } + useEffect(() => { + if ((checkUrlParams('subscribe') + && getAllUrlParams('id'))) { + getMatchInfo(MATCH_CONFIG.sportId, MATCH_CONFIG.matchId) + .then((match: MatchInfo) => { + const matchProfile = match && prepareMatchProfile({ + matchId: MATCH_CONFIG.matchId, + profile: match, + sportType: MATCH_CONFIG.sportId, + }) + matchProfile && openBuyMatchPopup(matchProfile) + }) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + return { fetchMatches, headerImage: tournamentProfile?.header_image, -- 2.30.2