forked from Bee-Balanced/Server-Repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvice.js
More file actions
58 lines (55 loc) · 4.14 KB
/
advice.js
File metadata and controls
58 lines (55 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// advice.js - maps survey questions to advice and stores question categories
export const adviceMap = {
"I drink 8 glasses of water daily.": "Drinking 8 cups of water daily improves brain function, boosts energy, and supports digestion. Try carrying a water bottle with you to stay on track.",
"I eat meals regularly.": "Consistent meals keep your metabolism steady and your energy up. Plan meals ahead of time to avoid skipping them.",
"I feel energized and well-rested throughout the day.": "Low energy can signal poor sleep, hydration, or nutrition—addressing these can help. Try winding down an hour earlier and avoid electronics before bed.",
"I am hopeful about the future.": "Maintaining hope improves mental resilience and reduces stress. Practice gratitude by writing down three things you're grateful for each day.",
"I am satisfied with my daily life.": "Satisfaction is tied to meaningful routines—celebrate small wins each day. Set achievable goals and reward yourself for completing them.",
"I am able to concentrate and stay focused.": "Breaks, sleep, and limiting distractions can sharpen your focus. Try using the Pomodoro technique to stay focused and take regular breaks.",
"I feel connected to others and supported.": "Connection boosts happiness—try reaching out or joining small groups. Take the initiative to schedule time with friends or family.",
"I know I'm not alone in my struggles and challenges.": "You're not alone—talking to others often reveals shared challenges. Consider joining a support group or seeking professional guidance.",
"I believe I am just as capable as everyone else.": "Self-worth grows through compassion—focus on progress, not perfection. Practice positive self-talk and celebrate your unique strengths.",
"I generally feel happy and emotionally balanced.": "Mood issues may need support—talk to someone and build uplifting habits. Consider professional counseling or journaling to explore your feelings.",
"I avoid using electronic devices after midnight.": "Late screen time affects sleep—power down early to rest better. Try a digital detox 30 minutes before bed to relax and prepare for sleep.",
"I exercise for 30 minutes or more every day.": "Exercise boosts mood, focus, and long-term health. Mix up your routine to stay motivated—try different activities like walking, yoga, or strength training.",
"I go outside for the sun at least 10 minutes a day.": "Sunlight helps regulate sleep and boosts Vitamin D. Take a short walk outside during your lunch break to get that daily dose of sun.",
"I sleep for 7 to 8 hours.": "Sleep restores the brain and body—aim for consistent, quality rest. Set a regular bedtime, avoid caffeine late in the day, and make your bedroom a restful space.",
"I limit my intake of caffeinated drinks.": "Too much caffeine disrupts sleep and can increase anxiety. Gradually reduce your caffeine intake, especially in the afternoon, to improve sleep quality."
};
export const questionMap = {
general: {
q1: "I drink 8 glasses of water daily.",
q2: "I eat meals regularly.",
q3: "I feel energized and well-rested throughout the day.",
q4: "I am hopeful about the future.",
q5: "I am satisfied with my daily life."
},
mental: {
q1: "I am able to concentrate and stay focused.",
q2: "I feel connected to others and supported.",
q3: "I know I'm not alone in my struggles and challenges.",
q4: "I believe I am just as capable as everyone else.",
q5: "I generally feel happy and emotionally balanced."
},
physical: {
q1: "I avoid using electronic devices after midnight.",
q2: "I exercise for 30 minutes or more every day.",
q3: "I go outside for the sun at least 10 minutes a day.",
q4: "I sleep for 7 to 8 hours.",
q5: "I limit my intake of caffeinated drinks."
}
};
export function getAdviceFor(category, questionKey) {
const question = questionMap[category] && questionMap[category][questionKey];
if (question) {
const advice = adviceMap[question] || "No advice available.";
return {
question: question,
advice: advice
};
} else {
return {
error: "Invalid question or category."
};
}
}