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 your account

-
- -
-

- By connecting my League of Legends account I acknowledge - making my profile public to all users. -

-
-
- - -
-
- - - - ); -} 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

+
+ +
+

+ By connecting my {selectedGame.name} account I acknowledge + making my profile public to all users. +

+
+
+ + +
+
+
+
+ )} + + ); +} 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() { <>