diff --git a/public/css/form.css b/public/css/form.css index 02ca853..52b6e62 100644 --- a/public/css/form.css +++ b/public/css/form.css @@ -12,6 +12,7 @@ .form-heading { font-size: 2em; margin-bottom: 0.5em; + text-align: center; } .form-subheading { diff --git a/public/css/main-container.css b/public/css/main-container.css index 1db49b8..1b0d0ab 100644 --- a/public/css/main-container.css +++ b/public/css/main-container.css @@ -34,5 +34,4 @@ hr { justify-content: center; min-height: 100vh; margin: auto; - background-color: #f7f7f7; } diff --git a/routes/affirmationRoutes.js b/routes/affirmationRoutes.js index 4d326bc..db72b38 100644 --- a/routes/affirmationRoutes.js +++ b/routes/affirmationRoutes.js @@ -9,7 +9,7 @@ router.get("/affirmation-setup", async (req, res) => { user = await User.findById(userId); } - res.render("affirmation-setup", { user }); + res.render("affirmation-setup", { user: user.toObject() }); }); router.get("/enter-affirmations", (req, res) => { @@ -17,21 +17,27 @@ router.get("/enter-affirmations", (req, res) => { }); router.post("/submit-affirmations", async (req, res) => { - const userId = req.session.passport.user; // Make sure the user is authenticated + const userId = req.session.passport.user; + console.log("Request body:", req.body); try { const user = await User.findById(userId); + console.log("User before update:", JSON.stringify(user, null, 2)); if (user) { user.affirmations = { - addressingInsecurities: req.body.addressingInsecurities, - shiftingToDesires: req.body.shiftingToDesires, - givingPermission: req.body.givingPermission, - affirmationsAndGratitude: req.body.affirmationsAndGratitude, + addressingInsecurities: req.body.addressinginsecurities, + shiftingToDesires: req.body.shiftingtodesires, + givingPermission: req.body.givingpermission, + affirmationsAndGratitude: req.body.affirmationsandgratitude, }; - await user.save(); - res.redirect("/affirmations"); // Redirect to a page to display affirmations + console.log("User after update:", JSON.stringify(user, null, 2)); + + const result = await user.save(); + console.log("Save result:", result); + + res.redirect("/affirmation-setup"); } } catch (err) { console.log("Error:", err); diff --git a/views/affirmation-setup.pug b/views/affirmation-setup.pug index 8bec9eb..418e158 100644 --- a/views/affirmation-setup.pug +++ b/views/affirmation-setup.pug @@ -5,12 +5,20 @@ block content h1 Hello, #{user.username} h2.form-heading Affirmation Setup + // Input for setting affirmation duration + form(action="/set-affirmation-duration" method="POST") + label(for="affirmationDuration") Set Duration (in seconds): + input(type="number" id="affirmationDuration" name="affirmationDuration" value=user.affirmationDuration || "") + input(type="submit" value="Set Duration") + // Check if affirmations exist - if user.affirmations && user.affirmations.length > 0 - ul.affirmation-list - each affirmation in user.affirmations - li= affirmation + if user.affirmations + each category, categoryName in user.affirmations + h3= categoryName + ul.affirmation-list + each affirmation, point in category + li #{point}: #{affirmation} + // Button to enter new affirmations + a.btn.btn-primary(href="/enter-affirmations") Enter New Affirmations else p.prompt You have no affirmations. Would you like to #[a(href="/enter-affirmations") enter some]? - - \ No newline at end of file diff --git a/views/enter-affirmations.pug b/views/enter-affirmations.pug index ac614e4..c1cc751 100644 --- a/views/enter-affirmations.pug +++ b/views/enter-affirmations.pug @@ -1,33 +1,18 @@ extends layout block content - div.main-container - div.center-container + div.main-container.container + div.center-container.text-center h1 Enter Your Affirmations - form(action="/submit-affirmations" method="POST" class="affirmation-form") + form(action="/submit-affirmations" method="POST", class="affirmation-form") - div.affirmation-section - h3 Addressing Insecurities - each point in ['topOfHead', 'eyebrow', 'sideOfEye', 'underEye', 'underNose', 'chin', 'collarbone', 'underArm'] - label(for=`addressingInsecurities[${point}]`) #{point} - textarea(name=`addressingInsecurities[${point}]`, rows="2", cols="50") - - div.affirmation-section - h3 Shifting to Desires - each point in ['topOfHead', 'eyebrow', 'sideOfEye', 'underEye', 'underNose', 'chin', 'collarbone', 'underArm'] - label(for=`shiftingToDesires[${point}]`) #{point} - textarea(name=`shiftingToDesires[${point}]`, rows="2", cols="50") - - div.affirmation-section - h3 Giving Permission - each point in ['topOfHead', 'eyebrow', 'sideOfEye', 'underEye', 'underNose', 'chin', 'collarbone', 'underArm'] - label(for=`givingPermission[${point}]`) #{point} - textarea(name=`givingPermission[${point}]`, rows="2", cols="50") - - div.affirmation-section - h3 Affirmations and Gratitude - each point in ['topOfHead', 'eyebrow', 'sideOfEye', 'underEye', 'underNose', 'chin', 'collarbone', 'underArm'] - label(for=`affirmationsAndGratitude[${point}]`) #{point} - textarea(name=`affirmationsAndGratitude[${point}]`, rows="2", cols="50") - - input(type="submit" value="Submit" class="submit-button") \ No newline at end of file + each section in ['Addressing Insecurities', 'Shifting to Desires', 'Giving Permission', 'Affirmations and Gratitude'] + div.affirmation-section + h3 #{section} + div.row + each point in ['topOfHead', 'eyebrow', 'sideOfEye', 'underEye', 'underNose', 'chin', 'collarbone', 'underArm'] + div.col-md-6.form-group + label(for=`${section.toLowerCase().replace(/\s+/g, '')}[${point}]`) #{point} + textarea.form-control(name=`${section.toLowerCase().replace(/\s+/g, '')}[${point}]`, rows="2") + + button.btn.btn-primary(type="submit") Submit diff --git a/views/login.pug b/views/login.pug index 0417bd5..e8a8415 100644 --- a/views/login.pug +++ b/views/login.pug @@ -3,11 +3,11 @@ extends layout block content div(class="center-container") // Flash Messages - if success_msg + if success_msg && success_msg.length > 0 div(class="flash-success") = success_msg - if error_msg + if error_msg && error_msg.length > 0 div(class="flash-error") = error_msg