activities imp
This commit is contained in:
parent
b073494b2d
commit
bc325b3865
|
|
@ -67,7 +67,14 @@ export default function Activities() {
|
|||
}
|
||||
};
|
||||
|
||||
// Initial fetch
|
||||
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) => {
|
||||
|
|
@ -124,7 +131,16 @@ export default function Activities() {
|
|||
>
|
||||
<div className="flex-1">
|
||||
<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>
|
||||
<Image
|
||||
src={profileUrl}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export function FirstVisitModal({ isOpen, onClose }: FirstVisitModalProps) {
|
|||
|
||||
<div className="space-y-4">
|
||||
<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 />
|
||||
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 ){
|
||||
try{
|
||||
const isDevnet = CLUSTER_URL === clusterApiUrl("devnet");
|
||||
if(isDevnet){
|
||||
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"}`)
|
||||
}else{
|
||||
await fetch(`${API_URL}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}`)
|
||||
}
|
||||
const url = `${API_URL}add_activity.php?type=${type}&owner_id=${owner_id}&joiner_id=${joiner_id}&game=${game}&amount=${amount}`;
|
||||
console.log(url);
|
||||
await fetch(url);
|
||||
}catch(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 chosenBetVaultAcc = await program.account.betVault.fetch(chosenBet);
|
||||
|
||||
// Execute the closeBet transaction
|
||||
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
|
||||
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}`);
|
||||
return txId;
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user