Skip to content

Commit

Permalink
fix UI state
Browse files Browse the repository at this point in the history
  • Loading branch information
starknetdev committed Jan 11, 2024
1 parent e108665 commit bc68494
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
19 changes: 17 additions & 2 deletions ui/src/app/containers/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Arcade from "public/icons/arcade.svg";
import { indexAddress, formatCurrency, displayAddress } from "@/app/lib/utils";
import { useBurner } from "@/app/lib/burner";
import ArcadeLoader from "@/app/components/animations/ArcadeLoader";
import useUIStore from "@/app/hooks/useUIStore";
import useUIStore, { ScreenPage } from "@/app/hooks/useUIStore";
import { useUiSounds, soundSelector } from "@/app/hooks/useUiSound";

type Section = "connect" | "eth" | "lords" | "arcade";
Expand Down Expand Up @@ -58,6 +58,7 @@ interface SectionContentProps {
listConnectors: () => any[];
updateConnectors: () => void;
handleOnboarded: () => void;
setScreen: (value: ScreenPage) => void;
}

const SectionContent = ({
Expand All @@ -82,6 +83,7 @@ const SectionContent = ({
listConnectors,
updateConnectors,
handleOnboarded,
setScreen,
}: SectionContentProps) => {
console.log(lordsGameCost * 25);
switch (section) {
Expand Down Expand Up @@ -377,6 +379,7 @@ const SectionContent = ({
updateConnectors();
setFullDeployment(false);
handleOnboarded();
setScreen("start");
} catch (e) {
console.log("Arcade deployment cancelled");
}
Expand Down Expand Up @@ -586,6 +589,7 @@ const Onboarding = ({
const [step, setStep] = useState(1);

const handleOnboarded = useUIStore((state) => state.handleOnboarded);
const setScreen = useUIStore((state) => state.setScreen);

const eth = Number(ethBalance);
const lords = Number(lordsBalance);
Expand Down Expand Up @@ -642,7 +646,10 @@ const Onboarding = ({
</Button>
<Button
className="fixed top-2 right-2 sm:top-20 sm:right-20"
onClick={() => handleOnboarded()}
onClick={() => {
setScreen("start");
handleOnboarded();
}}
>
Skip to game
</Button>
Expand Down Expand Up @@ -679,6 +686,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
</div>
<div className="flex flex-col items-center w-1/4">
Expand All @@ -705,6 +713,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
</div>
<div className="flex flex-col items-center w-1/4">
Expand All @@ -731,6 +740,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
</div>
<div className="flex flex-col items-center w-1/4">
Expand All @@ -757,6 +767,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
</div>
</div>
Expand Down Expand Up @@ -798,6 +809,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
)}
{step == 2 && (
Expand All @@ -823,6 +835,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
)}
{step == 3 && (
Expand All @@ -848,6 +861,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
)}
{step == 4 && (
Expand All @@ -873,6 +887,7 @@ const Onboarding = ({
listConnectors={listConnectors}
updateConnectors={updateConnectors}
handleOnboarded={handleOnboarded}
setScreen={setScreen}
/>
)}
</div>
Expand Down
7 changes: 5 additions & 2 deletions ui/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function Home({ updateConnectors }: HomeProps) {
const calls = useTransactionCartStore((state) => state.calls);
const screen = useUIStore((state) => state.screen);
const setScreen = useUIStore((state) => state.setScreen);
const handleOnboarded = useUIStore((state) => state.handleOnboarded);
const deathDialog = useUIStore((state) => state.deathDialog);
const hasBeast = useAdventurerStore((state) => state.computed.hasBeast);
const hasStatUpgrades = useAdventurerStore(
Expand Down Expand Up @@ -470,12 +471,14 @@ function Home({ updateConnectors }: HomeProps) {
}, [account, accountChainId, isConnected]);

useEffect(() => {
console.log(arcadeConnectors.length, onboarded);
if (arcadeConnectors.length === 0 && !onboarded) {
setScreen("onboarding");
} else {
} else if (!onboarded) {
handleOnboarded();
setScreen("start");
}
}, [arcadeConnectors, onboarded]);
}, [arcadeConnectors]);

useEffect(() => {
resetCalls();
Expand Down

1 comment on commit bc68494

@vercel
Copy link

@vercel vercel bot commented on bc68494 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.