mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
fixed a bit
This commit is contained in:
1 parent
291a17eaf6
commit
f2549cb216
4 files changed
+209
-3
No files matched your search
+63
-1
@@ -73,4 +73,66 @@ export async function validateCredentials(username, password) {
|
||||
}
|
||||
}
|
||||
|
||||
// Other functions remain the same...
|
||||
// Join a team
|
||||
export async function joinTeam(userId, teamCode) {
|
||||
try {
|
||||
// Find the team with the given code
|
||||
const team = await queryOne(
|
||||
'SELECT * FROM teams WHERE code = ?',
|
||||
[teamCode]
|
||||
);
|
||||
|
||||
if (!team) {
|
||||
return { success: false, error: 'Invalid team code' };
|
||||
}
|
||||
|
||||
// Update the user's team_id
|
||||
await run(
|
||||
'UPDATE users SET team_id = ? WHERE id = ?',
|
||||
[team.id, userId]
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
teamId: team.id
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Join team error:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: 'Failed to join team: ' + error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Start/Stop Hunt Timer
|
||||
export async function startHuntTimer(active) {
|
||||
try {
|
||||
// Update the hunt status
|
||||
await run(
|
||||
'UPDATE hunt_settings SET active = ?',
|
||||
[active ? 1 : 0]
|
||||
);
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Hunt timer error:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: 'Failed to update hunt timer: ' + error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Get Hunt Status
|
||||
export async function getHuntStatus() {
|
||||
try {
|
||||
const settings = await queryOne('SELECT active FROM hunt_settings LIMIT 1');
|
||||
return {
|
||||
active: settings ? Boolean(settings.active) : false
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Get hunt status error:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user