Skip to content

Commit

Permalink
feat: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhkeshan committed Dec 18, 2024
1 parent ff930b8 commit 539952f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ export default function Game({
// fetches player info 30 seconds
const interval = setInterval(() => {
setUpdateNum(updateNum + 1);
}, 10000);
}, 20000);

return () => clearInterval(interval);
}, [contract, updateNum]);

const updatePageNum = () => {
setTimeout(() => {
setUpdateNum(updateNum + 1);
}, 3000);
}, 3500);
};
const handlePlantSuccess = (position: number) => {
setSeeds((prev) => prev - 1);
Expand All @@ -132,6 +132,9 @@ export default function Game({
} as GardenVectorOutput;
});
};
const handleBuySuccess = () => {
setSeeds((prev) => prev + 10);
};
const onHarvestSuccess = (position: number) => {
setItems((prev) => prev + 1);
setTileStates((prev) => {
Expand Down Expand Up @@ -253,6 +256,7 @@ export default function Game({
items={items}
setCanMove={setCanMove}
farmCoinAssetID={farmCoinAssetID}
onBuySuccess={handleBuySuccess}
/>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/NewPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function NewPlayer({
} as PlayerOutput);
setModal("none");
updatePageNum();
toast.success("Welcome to Sway Farm! 🌱");
toast.success("Welcome to Sway Farm!");
}
return tx;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ export default function NewPlayer({
} as PlayerOutput);
setModal("none");
updatePageNum();
toast.success("Welcome to Sway Farm! 🌱");
toast.success("Welcome to Sway Farm!");
}
}

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/modals/BuySeeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ interface BuySeedsProps {
updatePageNum: () => void;
setCanMove: Dispatch<SetStateAction<boolean>>;
farmCoinAssetID: BytesLike;
onBuySuccess: () => void;
}

export default function BuySeeds({
contract,
updatePageNum,
setCanMove,
farmCoinAssetID,
onBuySuccess,
}: BuySeedsProps) {
const [status, setStatus] = useState<
"error" | "none" | "loading" | "retrying"
Expand Down Expand Up @@ -93,6 +95,7 @@ export default function BuySeeds({
});
if (tx) {
toast.success("Successfully bought seeds!");
onBuySuccess();
updatePageNum();
}
}
Expand Down Expand Up @@ -121,7 +124,7 @@ export default function BuySeeds({

if (tx) {
toast.success("Successfully bought seeds!");

onBuySuccess();
updatePageNum();
}
return tx;
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/modals/MarketModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface MarketModalProps {
items: number;
setCanMove: Dispatch<SetStateAction<boolean>>;
farmCoinAssetID: BytesLike;
onBuySuccess: () => void;
}

export default function MarketModal({
Expand All @@ -20,6 +21,7 @@ export default function MarketModal({
items,
setCanMove,
farmCoinAssetID,
onBuySuccess,
}: MarketModalProps) {
return (
<div className="market-modal">
Expand All @@ -28,6 +30,7 @@ export default function MarketModal({
updatePageNum={updatePageNum}
setCanMove={setCanMove}
farmCoinAssetID={farmCoinAssetID}
onBuySuccess={onBuySuccess}
/>
{items > 0 && (
<SellItem
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/modals/PlantModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function PlantModal({
if (tx) {
onPlantSuccess(tileArray[0]);
setModal("none");
toast.success("Seed planted!");
toast.success("Seed Planted!");
updatePageNum();
}
return tx;
Expand Down Expand Up @@ -110,7 +110,7 @@ export default function PlantModal({
onPlantSuccess(tileArray[0]);
setModal("none");
updatePageNum();
toast.success("Seed planted!");
toast.success("Seed Planted!");
}
}

Expand Down
25 changes: 15 additions & 10 deletions frontend/src/components/modals/UnsupportedWalletsNoticeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const UnsupportedWalletsNoticeModal = ({
left: 0,
width: "100%",
height: "100%",
backgroundColor: "rgba(0, 0, 0, 0.5)",
backgroundColor: "rgba(0, 0, 0, 0.7)",
display: "flex",
justifyContent: "center",
alignItems: "center",
Expand All @@ -27,27 +27,31 @@ export const UnsupportedWalletsNoticeModal = ({
className="modal-content"
onClick={(e) => e.stopPropagation()}
style={{
backgroundColor: "white",
padding: "20px",
backgroundColor: "rgb(18, 18, 18)",
padding: "30px",
borderRadius: "8px",
maxWidth: "400px",
width: "90%",
position: "relative",
}}
>
<div
style={{ fontWeight: "bold", marginBottom: "15px", fontSize: "16px" }}
style={{
fontWeight: "bold",
marginBottom: "15px",
fontSize: "18px",
color: "green",
}}
>
Wallet Support Notice
</div>
<div style={{ fontSize: "14px" }}>
<div style={{ fontSize: "14px", color: "white", marginTop: "10px" }}>
Note: Gasless transactions are currently only supported for the Burner
wallet & Fuelet.
wallet & Fuelet Wallet.
<br />
<br />
Support for other wallets is coming soon. If you use these other
wallets, you can still play the game, but you will need to pay gas
fees yourself.
wallets, you can still play the game by paying gas fees yourself.
</div>
<button
onClick={onClose}
Expand All @@ -56,8 +60,8 @@ export const UnsupportedWalletsNoticeModal = ({
padding: "8px 16px",
borderRadius: "4px",
border: "none",
backgroundColor: "#007bff",
color: "white",
backgroundColor: "#102a9e",
color: "#d0cdcd",
cursor: "pointer",
}}
>
Expand All @@ -67,3 +71,4 @@ export const UnsupportedWalletsNoticeModal = ({
</div>
);
};

0 comments on commit 539952f

Please sign in to comment.