diff --git a/pages/stryda/[game_slug]/stats/stats-leagueoflegends.js b/pages/stryda/[game_slug]/stats/stats-leagueoflegends.js index a0ae331a..0f63951f 100644 --- a/pages/stryda/[game_slug]/stats/stats-leagueoflegends.js +++ b/pages/stryda/[game_slug]/stats/stats-leagueoflegends.js @@ -14,7 +14,7 @@ import { StatsLeagueOfLegendsDemoGeneral } from "@/mock-data/data-stats-demo-lea import { StatsLeagueOfLegendsDemoLatestMatches } from "@/mock-data/data-stats-demo-leagueoflegends"; import LoadMore from "../../../../components/LoadMore/LoadMore"; import LoadMoreContainer from "../../../../components/LoadMore/LoadMoreContainer"; -import ModalConnectIDLeagueOfLegends from "../../modal-connectIDleagueoflegends"; +import ModalConnectGameID from "../../modal-connectgameID"; export default function StatsLeagueOfLegends() { const router = useRouter(); @@ -111,8 +111,8 @@ export default function StatsLeagueOfLegends() { setSelectedStat(getGeneralStatsByID(selectedGeneralStat)); }, [selectedGeneralStat]); - function openModalConnectIDLeagueOfLegends() { - uiContext.openModal(); + function openModalConnectGameID() { + uiContext.openModal(); } return ( @@ -148,7 +148,7 @@ export default function StatsLeagueOfLegends() { Connect my account diff --git a/pages/stryda/clanevents/index.js b/pages/stryda/clanevents/index.js index 75c78941..3f36755d 100644 --- a/pages/stryda/clanevents/index.js +++ b/pages/stryda/clanevents/index.js @@ -14,7 +14,7 @@ import TabClanLeaderboardsHowItWorks from "./[game_slug]/[leaderboard_id]/tab-ho import TabClanLeaderboardsHistory from "./[game_slug]/[leaderboard_id]/tab-history"; import StructureGamePage from "../components/StructureGamePage"; import ModalVideoYoutubePlayer from "../modal-videoyoutubeplayer"; -import ModalConnectIDLeagueOfLegends from "../modal-connectIDleagueoflegends"; +import ModalConnectGameID from "../modal-connectgameID"; const TabsItems = [ { @@ -65,8 +65,8 @@ export default function Ladders() { uiContext.openModal(); } - function openModalConnectIDLeagueOfLegends() { - uiContext.openModal(); + function openModalConnectGameID() { + uiContext.openModal(); } return ( @@ -124,7 +124,7 @@ export default function Ladders() { ); + function openModalConnectGameID() { + uiContext.openModal(); } useEffect(() => { @@ -139,7 +139,7 @@ export default function Ladders() { ); + function openModalConnectGameID() { + uiContext.openModal(); } @@ -115,7 +115,7 @@ export default function LaddersHeader(props) { { if (modalConnectIDLeagueOfLegends) { - openModalConnectIDLeagueOfLegends(); + openModalConnectGameID(); } }, [modalConnectIDLeagueOfLegends]); - function openModalConnectIDLeagueOfLegends() { - uiContext.openModal(); + function openModalConnectGameID() { + uiContext.openModal(); } useEffect(() => { diff --git a/pages/stryda/modal-connectIDleagueoflegends.js b/pages/stryda/modal-connectIDleagueoflegends.js deleted file mode 100644 index 88af4e41..00000000 --- a/pages/stryda/modal-connectIDleagueoflegends.js +++ /dev/null @@ -1,110 +0,0 @@ -import React, { useContext, useState } from "react"; - -import { UiContext } from "@/contexts/ui.js"; -import { VariablesContext } from "@/contexts/variables.js"; -import { usePrototypeData } from "@/contexts/prototype.js"; - -export default function ModalConnectIDLeagueOfLegends(props) { - const uiContext = useContext(UiContext); - const prototype = usePrototypeData(); - const [submitting, setSubmitting] = useState(false); - const [selectedGamesCount, setSelectedGamesCount] = useState( - prototype.games.filter((g) => g.isFavorite).length - ); - - const [isLoLRegionSelected, setIsLoLRegionSelected] = useState(false); - - function selectLoLRegion(e) { - setIsLoLRegionSelected(true); - } - - function closeModalWithDelay() { - setSubmitting(true); - - setTimeout(() => { - uiContext.openToastr({ - size: "medium", - text: "Your League of Legends account has been connected", - color: "green", - autoDelete: true, - autoDeleteDelay: 2500, - }); - uiContext.closeModal(); - setSubmitting(false); - }, 1000); - } - - function clearSelectedGame() { - setSelectedGamesCount(0); - } - - return ( - <> - - - - - - - - Connect your account - - selectLoLRegion(e)} - > - - Select your region - - Brazil - Europe Nordic & East - Europe West - North America - Latin America North - Latin America South - Oceania - Russia - Turkey - Japan - Republic of Korea - The Philippines - Singapore, Malaysia, Indonesia - Taiwan, Hong Kong, Macao - Thailand - Vietnam - - - - By connecting my League of Legends account I acknowledge - making my profile public to all users. - - - - - - Connect my account - - - Cancel - - - - - - > - ); -} diff --git a/pages/stryda/modal-connectgameID.js b/pages/stryda/modal-connectgameID.js new file mode 100644 index 00000000..55e8c856 --- /dev/null +++ b/pages/stryda/modal-connectgameID.js @@ -0,0 +1,120 @@ +import React, { useEffect, useContext, useState } from "react"; + +import { UiContext } from "@/contexts/ui.js"; +import { VariablesContext } from "@/contexts/variables.js"; +import { usePrototypeData } from "@/contexts/prototype.js"; + +export default function ModalConnectGameID(props) { + const uiContext = useContext(UiContext); + const prototype = usePrototypeData(); + const gameID = props.gameID || 2; + const [submitting, setSubmitting] = useState(false); + const [selectedGame, setSelectedGame] = useState(); + const [selectedGamesCount, setSelectedGamesCount] = useState( + prototype.games.filter((g) => g.isFavorite).length + ); + + const [isGameRegionSelected, setIsGameRegionSelected] = useState(false); + + useEffect(() => { + setSelectedGame(prototype.getGameByID(gameID)); + }, [gameID]); + + function selectGameRegion(e) { + setIsGameRegionSelected(true); + } + + function closeModalWithDelay() { + setSubmitting(true); + + setTimeout(() => { + uiContext.openToastr({ + size: "medium", + text: `Your ${selectedGame.name} account has been connected`, + color: "green", + autoDelete: true, + autoDeleteDelay: 2500, + }); + uiContext.closeModal(); + setSubmitting(false); + }, 1000); + } + + function clearSelectedGame() { + setSelectedGamesCount(0); + } + + return ( + <> + {selectedGame && ( + + + + + + + + Connect your account + + selectGameRegion(e)} + > + + Select your region + + Brazil + Europe Nordic & East + Europe West + North America + Latin America North + Latin America South + Oceania + Russia + Turkey + Japan + Republic of Korea + The Philippines + Singapore, Malaysia, Indonesia + Taiwan, Hong Kong, Macao + Thailand + Vietnam + + + + By connecting my {selectedGame.name} account I acknowledge + making my profile public to all users. + + + + + + Connect my account + + + Cancel + + + + + + )} + > + ); +} diff --git a/pages/stryda/profile/settings/tab-gameaccounts.js b/pages/stryda/profile/settings/tab-gameaccounts.js index e472ab25..9c330949 100644 --- a/pages/stryda/profile/settings/tab-gameaccounts.js +++ b/pages/stryda/profile/settings/tab-gameaccounts.js @@ -4,6 +4,7 @@ import { UiContext } from "@/contexts/ui"; import { usePrototypeData } from "@/contexts/prototype"; import { useRouter } from "next/router"; import Tooltip from "@/components/Tooltip/Tooltip"; +import ModalConnectGameID from "../../modal-connectgameID"; export default function TabSettingsGameAccounts() { const router = useRouter(); @@ -28,6 +29,10 @@ export default function TabSettingsGameAccounts() { setIsLoLRegionSelected(true); } + function openModalConnectGameID(gameID) { + uiContext.openModal(); + } + return ( <> {selectedUser && ( @@ -111,9 +116,10 @@ export default function TabSettingsGameAccounts() { <> - setIsValorantConnected(!isValorantConnected) - } + onClick={() => { + setIsValorantConnected(!isValorantConnected); + openModalConnectGameID(1); + }} className="button button-primary w-full" > @@ -214,7 +220,10 @@ export default function TabSettingsGameAccounts() { <> setIsLoLConnected(!isLoLConnected)} + onClick={() => { + setIsLoLConnected(!isLoLConnected); + openModalConnectGameID(6); + }} className="button button-primary w-full" > @@ -386,6 +395,7 @@ export default function TabSettingsGameAccounts() { setIsAlreadyPUBGConnected( !isAlreadyPUBGConnected ); + openModalConnectGameID(2); }} className="button button-primary w-full" > @@ -429,7 +439,10 @@ export default function TabSettingsGameAccounts() { <> setIsPUBGConnected(!isPUBGConnected)} + onClick={() => { + setIsPUBGConnected(!isPUBGConnected); + openModalConnectGameID(2); + }} className="button button-primary w-full" >
- By connecting my League of Legends account I acknowledge - making my profile public to all users. -
+ By connecting my {selectedGame.name} account I acknowledge + making my profile public to all users. +