diff --git a/src/routes/hunts.js b/src/routes/hunts.js index e9deecc..21c04c5 100644 --- a/src/routes/hunts.js +++ b/src/routes/hunts.js @@ -158,33 +158,40 @@ router.post('/player/:username/display-name', requireAuth, (req, res) => { }); // ─── Apply to become organizer ──────────────────────────── -router.post('/player/:username/apply-organizer', requireAuth, (req, res) => { - const user = Users.findByUsername(req.params.username); - if (!user || user.id !== req.session.userId) { - return res.status(403).render('error', { title: 'Forbidden', message: 'You can only submit your own application.' }); +router.get('/apply-organizer', requireAuth, (req, res) => { + const user = Users.findById(req.session.userId); + if (user.is_organizer || user.is_admin) { + req.session.flash = { type: 'info', message: 'You already have organizer access.' }; + return res.redirect(`/player/${user.username}`); } + const pendingApplication = OrganizerApplications.findByUser(user.id); + res.render('apply-organizer', { title: 'Apply to Become an Organizer', pendingApplication }); +}); + +router.post('/apply-organizer', requireAuth, (req, res) => { + const user = Users.findById(req.session.userId); if (user.is_organizer || user.is_admin) { req.session.flash = { type: 'info', message: 'You already have organizer access.' }; return res.redirect(`/player/${user.username}`); } if (OrganizerApplications.findByUser(user.id)) { req.session.flash = { type: 'info', message: 'You already have a pending application.' }; - return res.redirect(`/player/${user.username}`); + return res.redirect('/apply-organizer'); } const reason = (req.body.reason || '').trim(); if (!reason || reason.length < 10) { req.session.flash = { type: 'danger', message: 'Please provide a reason (at least 10 characters).' }; - return res.redirect(`/player/${user.username}`); + return res.redirect('/apply-organizer'); } if (reason.length > 1000) { req.session.flash = { type: 'danger', message: 'Reason is too long (max 1000 characters).' }; - return res.redirect(`/player/${user.username}`); + return res.redirect('/apply-organizer'); } OrganizerApplications.submit(user.id, reason); req.session.flash = { type: 'success', message: 'Your organizer application has been submitted!' }; - res.redirect(`/player/${user.username}`); + res.redirect('/apply-organizer'); }); // ─── Delete own account ─────────────────────────────────── diff --git a/src/views/about.ejs b/src/views/about.ejs index 26bed2c..d92975b 100644 --- a/src/views/about.ejs +++ b/src/views/about.ejs @@ -67,6 +67,7 @@
  • Download printable PDF cards with QR codes (Avery 5371 format, 10 per page)
  • Monitor scan activity and leaderboards for your hunts
  • +

    Interested? Apply to become an organizer.

    diff --git a/src/views/apply-organizer.ejs b/src/views/apply-organizer.ejs new file mode 100644 index 0000000..19cbbfe --- /dev/null +++ b/src/views/apply-organizer.ejs @@ -0,0 +1,31 @@ +<%- include('partials/header') %> + +
    +

    Apply to Become an Organizer

    + +
    +

    Organizers can create treasure hunts, generate QR code cards, set start dates and expiry windows, and monitor their hunt activity and leaderboards.

    +

    If you'd like to run your own hunts, fill out the form below. An admin will review your application.

    +
    + + <% if (typeof pendingApplication !== 'undefined' && pendingApplication) { %> +
    +
    ⏳ Application Pending
    +

    Your application is pending review. Hang tight!

    +

    <%= pendingApplication.reason %>

    +
    + <% } else { %> +
    +
    +
    + + +
    10–1000 characters.
    +
    + +
    +
    + <% } %> +
    + +<%- include('partials/footer') %> diff --git a/src/views/player/profile.ejs b/src/views/player/profile.ejs index 001603f..0ebe7b7 100644 --- a/src/views/player/profile.ejs +++ b/src/views/player/profile.ejs @@ -93,16 +93,12 @@
    🎯 Become an Organizer
    <% if (typeof pendingApplication !== 'undefined' && pendingApplication) { %>

    Your application is pending review. Hang tight!

    -

    <%= pendingApplication.reason %>

    <% } else { %> -

    Organizers can create hunts, generate QR codes, and manage their own events. Tell us why you'd like to become one!

    -
    -
    - - -
    - -
    +

    Want to create your own treasure hunts?

    + <% } %> + <%= (typeof pendingApplication !== 'undefined' && pendingApplication) ? 'View Application' : 'Apply Now' %> +
    + <% } %> <% } %> <% } %>