Skip to content

Commit

Permalink
Prototype: settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
augustinhiebel committed Dec 5, 2023
1 parent feceae1 commit 355d0a6
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 136 deletions.
10 changes: 5 additions & 5 deletions pages/stryda/[game_slug]/stats/stats-leagueoflegends.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -111,8 +111,8 @@ export default function StatsLeagueOfLegends() {
setSelectedStat(getGeneralStatsByID(selectedGeneralStat));
}, [selectedGeneralStat]);

function openModalConnectIDLeagueOfLegends() {
uiContext.openModal(<ModalConnectIDLeagueOfLegends />);
function openModalConnectGameID() {
uiContext.openModal(<ModalConnectGameID />);
}

return (
Expand Down Expand Up @@ -148,7 +148,7 @@ export default function StatsLeagueOfLegends() {
<button
type="button"
className="button button-primary"
onClick={openModalConnectIDLeagueOfLegends}
onClick={openModalConnectGameID}
>
<span
className={`icon icon-game-${selectedGame.slug}-symbol`}
Expand Down Expand Up @@ -207,7 +207,7 @@ export default function StatsLeagueOfLegends() {
<button
type="button"
className="button button-primary w-full"
onClick={openModalConnectIDLeagueOfLegends}
onClick={openModalConnectGameID}
>
<span className="icon icon-game-leagueoflegends-symbol" />
<span>Connect my account</span>
Expand Down
8 changes: 4 additions & 4 deletions pages/stryda/clanevents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -65,8 +65,8 @@ export default function Ladders() {
uiContext.openModal(<ModalVideoYoutubePlayer url={url} />);
}

function openModalConnectIDLeagueOfLegends() {
uiContext.openModal(<ModalConnectIDLeagueOfLegends />);
function openModalConnectGameID() {
uiContext.openModal(<ModalConnectGameID />);
}

return (
Expand Down Expand Up @@ -124,7 +124,7 @@ export default function Ladders() {
<button
type="button"
className="button button-secondary"
onClick={openModalConnectIDLeagueOfLegends}
onClick={openModalConnectGameID}
>
<span
className={`icon icon-game-${selectedGame.slug}-symbol`}
Expand Down
8 changes: 4 additions & 4 deletions pages/stryda/ladders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import StructureGamePage from "../components/StructureGamePage";
import ButtonStatsUpdate from "@/components/ButtonStatsUpdate/ButtonStatsUpdate";
import Countdown from "@/components/Countdown/Countdown";
import ModalVideoYoutubePlayer from "../modal-videoyoutubeplayer";
import ModalConnectIDLeagueOfLegends from "../modal-connectIDleagueoflegends";
import ModalConnectGameID from "../modal-connectgameID";

const TabsItems = [
{
Expand Down Expand Up @@ -66,8 +66,8 @@ export default function Ladders() {
);
}

function openModalConnectIDLeagueOfLegends() {
uiContext.openModal(<ModalConnectIDLeagueOfLegends />);
function openModalConnectGameID() {
uiContext.openModal(<ModalConnectGameID />);
}

useEffect(() => {
Expand Down Expand Up @@ -139,7 +139,7 @@ export default function Ladders() {
<button
type="button"
className="button button-secondary"
onClick={openModalConnectIDLeagueOfLegends}
onClick={openModalConnectGameID}
>
<span
className={`icon icon-game-${selectedGame.slug}-symbol`}
Expand Down
8 changes: 4 additions & 4 deletions pages/stryda/ladders/ladders-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from "react";

import Link from "next/link";
import ModalLadderHowitworksVideo from "./modal-howitworks-video";
import ModalConnectIDLeagueOfLegends from "../modal-connectIDleagueoflegends";
import ModalConnectGameID from "../modal-connectgameID";
import { UiContext } from "@/contexts/ui";
import { usePrototypeData } from "@/contexts/prototype";
import { useRouter } from "next/router";
Expand All @@ -22,8 +22,8 @@ export default function LaddersHeader(props) {
);
}

function openModalConnectIDLeagueOfLegends() {
uiContext.openModal(<ModalConnectIDLeagueOfLegends />);
function openModalConnectGameID() {
uiContext.openModal(<ModalConnectGameID />);
}


Expand Down Expand Up @@ -115,7 +115,7 @@ export default function LaddersHeader(props) {
<button
type="button"
className="button button-secondary"
onClick={openModalConnectIDLeagueOfLegends}
onClick={openModalConnectGameID}
>
<span
className={`icon icon-game-${selectedGame.slug}-symbol`}
Expand Down
8 changes: 4 additions & 4 deletions pages/stryda/missions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TabMissionsHowItWorks from "./tab-howitworks";
import TabMissionsMissions from "./tab-missions";
import TabMissionsHistory from "./tab-history";
import TabMissionsLeaderboard from "./tab-leaderboard";
import ModalConnectIDLeagueOfLegends from "../modal-connectIDleagueoflegends";
import ModalConnectGameID from "../modal-connectgameID";
import { UiContext } from "@/contexts/ui";
import { usePrototypeData } from "@/contexts/prototype";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -54,12 +54,12 @@ export default function Missions() {

useEffect(() => {
if (modalConnectIDLeagueOfLegends) {
openModalConnectIDLeagueOfLegends();
openModalConnectGameID();
}
}, [modalConnectIDLeagueOfLegends]);

function openModalConnectIDLeagueOfLegends() {
uiContext.openModal(<ModalConnectIDLeagueOfLegends />);
function openModalConnectGameID() {
uiContext.openModal(<ModalConnectGameID />);
}

useEffect(() => {
Expand Down
110 changes: 0 additions & 110 deletions pages/stryda/modal-connectIDleagueoflegends.js

This file was deleted.

120 changes: 120 additions & 0 deletions pages/stryda/modal-connectgameID.js
Original file line number Diff line number Diff line change
@@ -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 && (
<div className="relative z-10 max-w-md w-full">
<div className="modal modal-center w-full">
<button
type="button"
className="button button-secondary button-close"
onClick={uiContext.closeModal}
>
<span className="icon icon-e-remove" />
</button>
<div className="modal-content">
<div className="modal-body text-center">
<h2 className="modal-title">Connect your account</h2>
<div className="form-group form-select mt-8 mb-4">
<select
id="gameaccount-region"
onChange={(e) => selectGameRegion(e)}
>
<option disabled selected>
Select your region
</option>
<option>Brazil</option>
<option>Europe Nordic & East</option>
<option>Europe West</option>
<option>North America</option>
<option>Latin America North</option>
<option>Latin America South</option>
<option>Oceania</option>
<option>Russia</option>
<option>Turkey</option>
<option>Japan</option>
<option>Republic of Korea</option>
<option>The Philippines</option>
<option>Singapore, Malaysia, Indonesia</option>
<option>Taiwan, Hong Kong, Macao</option>
<option>Thailand</option>
<option>Vietnam</option>
</select>
</div>
<p className="text-ui-300 my-2 leading-tight">
By connecting my {selectedGame.name} account I acknowledge
making my profile public to all users.
</p>
</div>
<div className="modal-action justify-center">
<button
type="button"
onClick={closeModalWithDelay}
disabled={!isGameRegionSelected}
className={`button button-primary flex-1 ${
submitting ? "is-loading" : ""
}`}
>
<span
className={`icon icon-game-${selectedGame.slug}-symbol`}
/>
<span>Connect my account</span>
</button>
<button
className="button button-secondary flex-1"
onClick={uiContext.closeModal}
>
<span>Cancel</span>
</button>
</div>
</div>
</div>
</div>
)}
</>
);
}
Loading

0 comments on commit 355d0a6

Please sign in to comment.