adding player profiles
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 28s
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 28s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { Hunts, Packages, Scans } = require('../models');
|
||||
const { Hunts, Packages, Scans, Users } = require('../models');
|
||||
|
||||
// ─── Hunt profile ─────────────────────────────────────────
|
||||
router.get('/hunt/:shortName', (req, res) => {
|
||||
@@ -59,6 +59,29 @@ router.get('/hunt/:shortName/:cardNumber', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── User profile ─────────────────────────────────────────
|
||||
router.get('/player/:username', (req, res) => {
|
||||
const user = Users.findByUsername(req.params.username);
|
||||
if (!user) {
|
||||
return res.status(404).render('error', { title: 'Not Found', message: 'Player not found.' });
|
||||
}
|
||||
|
||||
const profile = Users.getProfile(user.id);
|
||||
const recentScans = Users.getRecentScans(user.id);
|
||||
const huntBreakdown = Users.getHuntBreakdown(user.id);
|
||||
const rank = Users.getRank(user.id);
|
||||
const totalPlayers = Users.getTotalPlayerCount();
|
||||
|
||||
res.render('player/profile', {
|
||||
title: `${user.username}'s Profile`,
|
||||
profile,
|
||||
recentScans,
|
||||
huntBreakdown,
|
||||
rank,
|
||||
totalPlayers
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Browse all hunts ─────────────────────────────────────
|
||||
router.get('/hunts', (req, res) => {
|
||||
const hunts = Hunts.getAll();
|
||||
|
||||
Reference in New Issue
Block a user