activities imp
This commit is contained in:
parent
b073494b2d
commit
bc325b3865
|
|
@ -67,7 +67,14 @@ export default function Activities() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Initial fetch
|
||||||
fetchActivities();
|
fetchActivities();
|
||||||
|
|
||||||
|
// Set up interval for periodic updates
|
||||||
|
const intervalId = setInterval(fetchActivities, 5000);
|
||||||
|
|
||||||
|
// Cleanup function to clear the interval when component unmounts
|
||||||
|
return () => clearInterval(intervalId);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const formatActivityMessage = (activity: Activity) => {
|
const formatActivityMessage = (activity: Activity) => {
|
||||||
|
|
@ -124,7 +131,16 @@ export default function Activities() {
|
||||||
>
|
>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-white">{formatActivityMessage(activity)}</p>
|
<p className="text-white">{formatActivityMessage(activity)}</p>
|
||||||
<p className="text-sm text-gray-400">{new Date(activity.time).toLocaleString()}</p>
|
<p className="text-sm text-gray-400">
|
||||||
|
{new Date(activity.time + 'Z').toLocaleString(undefined, {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
hour12: true
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Image
|
<Image
|
||||||
src={profileUrl}
|
src={profileUrl}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export function FirstVisitModal({ isOpen, onClose }: FirstVisitModalProps) {
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<p className="text-gray-300">
|
<p className="text-gray-300">
|
||||||
Challenge your friends (or strangers) in a head-to-head skill games and earn from your victories!
|
Challenge your friends (or strangers) in head-to-head skill games and earn from your victories!
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Create or join duels, set an entry fee, and the winner takes all.
|
Create or join duels, set an entry fee, and the winner takes all.
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,9 @@ export async function showNewGameNotification(username:string, game:string, wage
|
||||||
|
|
||||||
export async function add_new_activity(type:string, owner_id:string, joiner_id:string, game:string, amount:number ){
|
export async function add_new_activity(type:string, owner_id:string, joiner_id:string, game:string, amount:number ){
|
||||||
try{
|
try{
|
||||||
const isDevnet = CLUSTER_URL === clusterApiUrl("devnet");
|
const url = `${API_URL}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}`;
|
||||||
if(isDevnet){
|
console.log(url);
|
||||||
await fetch(`${API_URL}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}&devnet=${isDevnet ? "1" : "0"}`)
|
await fetch(url);
|
||||||
}else{
|
|
||||||
await fetch(`${API_URL}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}`)
|
|
||||||
}
|
|
||||||
}catch(error){
|
}catch(error){
|
||||||
console.error("Error adding new activity:", error);
|
console.error("Error adding new activity:", error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ export async function closeBet(wallets: ConnectedSolanaWallet, uid:string, betI
|
||||||
}
|
}
|
||||||
|
|
||||||
const winner = new PublicKey(wallets.address);
|
const winner = new PublicKey(wallets.address);
|
||||||
|
const chosenBetVaultAcc = await program.account.betVault.fetch(chosenBet);
|
||||||
|
|
||||||
// Execute the closeBet transaction
|
// Execute the closeBet transaction
|
||||||
const tx = await program.methods
|
const tx = await program.methods
|
||||||
|
|
@ -113,7 +113,7 @@ export async function closeBet(wallets: ConnectedSolanaWallet, uid:string, betI
|
||||||
|
|
||||||
// Send transaction// Replace with correct RPC endpoint
|
// Send transaction// Replace with correct RPC endpoint
|
||||||
const txId = await connection.sendRawTransaction(signedTx.serialize());
|
const txId = await connection.sendRawTransaction(signedTx.serialize());
|
||||||
add_new_activity("close", uid, "", game_id, 0);
|
add_new_activity("close", uid, chosenBetVaultAcc.joinerId, game_id, chosenBetVaultAcc.wager.toNumber() / LAMPORTS_PER_SOL);
|
||||||
console.log(`Transaction: ${txId}`);
|
console.log(`Transaction: ${txId}`);
|
||||||
return txId;
|
return txId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user