Skip to content

Commit 096dde8

Browse files
authored
add processing transaction spinner (#27)
also fixes game character not appearing
1 parent 422c73d commit 096dde8

5 files changed

Lines changed: 72 additions & 7 deletions

File tree

client/src/pages/Game.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default function Game() {
186186
event.preventDefault();
187187
if (!gameStateRef.current.isPlaying && !gameStateRef.current.isGameOver) {
188188
startGame();
189-
gameLoop();
189+
// Game loop is already running, no need to call it again
190190
} else if (!gameStateRef.current.isGameOver) {
191191
jump();
192192
}
@@ -209,6 +209,9 @@ export default function Game() {
209209
drawStartText();
210210
}
211211
drawDino(DINO_X, GROUND_Y);
212+
213+
// Continue the animation loop even when not playing to update the character image
214+
animationId = requestAnimationFrame(gameLoop);
212215
return;
213216
}
214217

@@ -270,12 +273,15 @@ export default function Game() {
270273
}
271274
}
272275

273-
// Initial draw
276+
// Initial draw and start animation loop
274277
ctx.clearRect(0, 0, canvas.width, canvas.height);
275278
drawGround();
276279
drawDino(DINO_X, GROUND_Y);
277280
drawStartText();
278281

282+
// Start the animation loop immediately
283+
gameLoop();
284+
279285
// Cleanup function
280286
return () => {
281287
canvas.removeEventListener("mousedown", handleClick);

client/src/pages/MicroTransactionStore.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,47 @@
452452
0 15px 25px var(--color-shadow-medium);
453453
}
454454
}
455+
456+
/* Processing Spinner Styles */
457+
.processing-spinner {
458+
position: fixed;
459+
top: 0;
460+
left: 0;
461+
right: 0;
462+
bottom: 0;
463+
background: rgba(0, 0, 0, 0.7);
464+
display: flex;
465+
flex-direction: column;
466+
justify-content: center;
467+
align-items: center;
468+
z-index: 1000;
469+
color: var(--color-text);
470+
font-family: "Cinzel", serif;
471+
}
472+
473+
.spinner {
474+
width: 60px;
475+
height: 60px;
476+
border: 4px solid rgba(255, 255, 255, 0.2);
477+
border-top: 4px solid var(--color-gold);
478+
border-radius: 50%;
479+
animation: spin 1s linear infinite;
480+
margin-bottom: 1rem;
481+
box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
482+
}
483+
484+
.processing-spinner p {
485+
font-size: 1.2rem;
486+
font-weight: 600;
487+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
488+
letter-spacing: 1px;
489+
}
490+
491+
@keyframes spin {
492+
0% {
493+
transform: rotate(0deg);
494+
}
495+
100% {
496+
transform: rotate(360deg);
497+
}
498+
}

client/src/pages/MicroTransactionStore.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515

1616
export function MicroTransactionStore() {
1717
const [selectedPackage, setSelectedPackage] = useState<string | null>(null);
18+
const [isProcessing, setIsProcessing] = useState<boolean>(false);
1819
const { data: gemPackages, isLoading } = useGetAllProducts();
1920
const { mutate: validateUser } = useValidateUser();
2021

@@ -35,19 +36,25 @@ export function MicroTransactionStore() {
3536
console.log("Payment link retrieved:", paymentLink);
3637
const paymentLinkSession = await BoltSDK.gaming.openCheckout(paymentLink);
3738

39+
setIsProcessing(true);
40+
3841
if (!paymentLinkSession) {
3942
console.error("Failed to open payment link session");
43+
setIsProcessing(false);
4044
return;
4145
} else if (paymentLinkSession.status === "abandoned") {
4246
console.log("Purchase cancelled by user:", pkg.name);
47+
setIsProcessing(false);
4348
} else {
4449
console.log("Purchase pending for:", pkg.name);
4550
validateUser(paymentLinkSession.paymentLinkId, {
4651
onSuccess: (data) => {
52+
setIsProcessing(false);
4753
toast.success(`Successfully purchased ${pkg.gemAmount} gems!`);
4854
console.log("User validated:", data);
4955
},
5056
onError: (error) => {
57+
setIsProcessing(false);
5158
toast.error(`Failed to validate purchase: ${error.message}`);
5259
console.error("Validation error:", error);
5360
},
@@ -73,6 +80,13 @@ export function MicroTransactionStore() {
7380
/>
7481
))}
7582
</div>
83+
84+
{isProcessing && (
85+
<div className="processing-spinner">
86+
<div className="spinner"></div>
87+
<p>Processing your purchase...</p>
88+
</div>
89+
)}
7690
</div>
7791
<div className="coin-store-footer">
7892
<p>

server/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
"scripts": {
1313
"start:staging": "tsx --env-file=.env.staging src/index.ts",
1414
"seed": "tsx --env-file=.env.local src/seed.ts",
15+
"seed:staging": "tsx --env-file=.env.staging src/seed.ts",
1516
"dev": "tsx watch --env-file=.env.local src/index.ts"
1617
},
1718
"keywords": [],
1819
"author": "",
1920
"license": "ISC",
2021
"dependencies": {
21-
"@boltpay/bolt-js": "^0.2.1",
22+
"@boltpay/bolt-js": "^0.2.2",
2223
"@types/better-sqlite3": "^7.6.13",
2324
"@types/uuid": "^10.0.0",
2425
"axios": "^1.9.0",

0 commit comments

Comments
 (0)