Skip to content

Commit

Permalink
add temp manifestocontext to avoid having to sign all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
datadanne committed Jul 21, 2023
1 parent d0e06f8 commit 21f8459
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 28 deletions.
57 changes: 30 additions & 27 deletions garage/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { GlobalFlyParkModals } from "./components/GlobalFlyParkModals";
import { RequiresWalletConnection } from "./components/RequiresWalletConnection";
import { RigAttributeStatsContextProvider } from "./components/RigAttributeStatsContext";
import { NFTsContextProvider } from "./components/NFTsContext";
import { ManifestoContextProvider } from "./components/ManifestoContext";
import { ActingAsAddressContextProvider } from "./components/ActingAsAddressContext";
import { routes } from "./routes";
import { mainChain, secondaryChain } from "./env";
Expand Down Expand Up @@ -258,33 +259,35 @@ function App() {
<ActingAsAddressContextProvider>
<RigAttributeStatsContextProvider>
<NFTsContextProvider>
<BrowserRouter>
<Topbar />
<GlobalFlyParkModals>
<Routes>
{routes().map(
(
{ requiresWalletConnection, element, ...props },
index
) => (
<Route
{...props}
key={`route-${index}`}
element={
requiresWalletConnection ? (
<RequiresWalletConnection>
{element}
</RequiresWalletConnection>
) : (
element
)
}
/>
)
)}
</Routes>
</GlobalFlyParkModals>
</BrowserRouter>
<ManifestoContextProvider>
<BrowserRouter>
<Topbar />
<GlobalFlyParkModals>
<Routes>
{routes().map(
(
{ requiresWalletConnection, element, ...props },
index
) => (
<Route
{...props}
key={`route-${index}`}
element={
requiresWalletConnection ? (
<RequiresWalletConnection>
{element}
</RequiresWalletConnection>
) : (
element
)
}
/>
)
)}
</Routes>
</GlobalFlyParkModals>
</BrowserRouter>
</ManifestoContextProvider>
</NFTsContextProvider>
</RigAttributeStatsContextProvider>
</ActingAsAddressContextProvider>
Expand Down
32 changes: 32 additions & 0 deletions garage/src/components/ManifestoContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useContext, useMemo, useState } from "react";

interface ManifestoContextValue {
hasSignedManifesto: boolean;
setHasSignedManifesto: (hasSigned: boolean) => void;
}

const ManifestoContext = React.createContext<ManifestoContextValue>({
hasSignedManifesto: false,
setHasSignedManifesto: () => {},
});

export const ManifestoContextProvider = ({
children,
}: React.PropsWithChildren) => {
const [hasSignedManifesto, setHasSignedManifesto] = useState(false);

const value = useMemo(() => {
return {
hasSignedManifesto,
setHasSignedManifesto: () => setHasSignedManifesto(true),
};
}, [hasSignedManifesto, setHasSignedManifesto]);

return (
<ManifestoContext.Provider value={value}>
{children}
</ManifestoContext.Provider>
);
};

export const useManifestoContext = () => useContext(ManifestoContext);
3 changes: 2 additions & 1 deletion garage/src/pages/MissionBoard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Link } from "react-router-dom";
import { TOPBAR_HEIGHT } from "../../Topbar";
import { prettyNumber } from "../../utils/fmt";
import { useOpenMissions } from "../../hooks/useMissions";
import { useManifestoContext } from "../../components/ManifestoContext";
import { Mission } from "../../types";

const GRID_GAP = 4;
Expand Down Expand Up @@ -206,7 +207,7 @@ export const SignManifesto = ({ onAgree }: { onAgree: () => void }) => {
};

export const MissionBoard = () => {
const [hasSignedManifesto, setHasSignedManifesto] = useState(false);
const { hasSignedManifesto, setHasSignedManifesto } = useManifestoContext();
const { missions } = useOpenMissions();

return (
Expand Down

0 comments on commit 21f8459

Please sign in to comment.