@@ -75,32 +120,33 @@ export default function LineGraph({
Decision Maker
How did the things I wanted to do feel?
+
No data available for the graph.
;
+ }
+
+ // Sort data by timestamp
+ const sortedData = [...dataArray].sort(
+ (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
+ );
+
+ // Filter to the current range
+ const filteredData = sortedData.filter(entry => {
+ const t = new Date(entry.timestamp).getTime();
+ return t >= startOfRange.getTime() && t <= endOfRange.getTime();
+ });
+
+ if (filteredData.length === 0) {
+ return
No data available in the selected range.
;
+ }
+
+ const uniqueMoods = Array.from(
+ new Set(filteredData.map((entry) => entry.moodName))
+ );
+
+ // After filtering data but before creating traces
+ const firstMood = filteredData[0].moodName;
+
+ const traces = uniqueMoods.map((mood) => {
+ const dataPoints = filteredData.map((entry, index) => {
+ const timestamp = new Date(entry.timestamp).toISOString();
+ const entriesUpToNow = filteredData.slice(0, index + 1);
+ const moodCount = entriesUpToNow.filter(e => e.moodName === mood).length;
+
+ // For the first timestamp, set initial values
+ if (index === 0) {
+ // If this is the first mood, give it a height of 1
+ // Other moods start at 0
+ return {
+ x: timestamp,
+ y: mood === firstMood ? 1 : 0
+ };
+ }
+
+ return { x: timestamp, y: moodCount };
+ });
+
+ return {
+ x: dataPoints.map(point => point.x),
+ y: dataPoints.map(point => point.y),
+ type: "scatter",
+ mode: "none",
+ fill: "tonexty",
+ name: mood,
+ stackgroup: "one",
+ fillcolor: "auto",
+ orientation: "v",
+ stackgaps: "interpolate",
+ line: { shape: "spline" },
+ hoveron: "points+fills",
+ hoverinfo: "name+y"
+ };
+ });
+
+ // Apply silhouette offset at each timestamp to center the stack
+ if (traces.length > 0) {
+ const timeSteps = traces[0].x;
+ for (let i = 0; i < timeSteps.length; i++) {
+ let totalAtTime = 0;
+ for (let t = 0; t < traces.length; t++) {
+ totalAtTime += (traces[t].y as number[])[i];
+ }
+ const midpoint = totalAtTime / 2;
+
+ // For the first timestamp, use a smaller offset to create the 20% band
+ const offset = i === 0 ? 0.5 : midpoint; // This will create roughly a 20% band
+
+ for (let t = 0; t < traces.length; t++) {
+ (traces[t].y as number[])[i] = (traces[t].y as number[])[i] - offset;
+ }
+ }
+ }
+
+ const tickFormat = (() => {
+ switch (selectedButton) {
+ case "day":
+ return "%H:00";
+ case "week":
+ return "%a";
+ case "month":
+ return "%d";
+ case "year":
+ return "%b";
+ default:
+ return "";
+ }
+ })();
+
+ return (
+
+
+
Mood Flow
+
Find out how which moods have been most prevalent in this time period
+ The Insights tab is designed to help you make the most out of your
+ data by providing{" "}
+
+ personalized insights, trends, and summaries
+
+ . Whether you’re tracking your mood, monitoring patterns over time,
+ or discovering which tools work best for you, this feature ensures
+ you gain valuable insights without needing to engage with the app
+ every single day.
+
+
+
+ {/* How Can This Tab Help Section */}
+
+
+ How Can This Tab Help?
+
+
+
+
+ Time-Based Filtering:
+ {" "}
+ This helps you visualize how urgency, effort, and mood vary over
+ specific periods—whether mornings are more stressful, weekends
+ feel more rewarding, or winters bring unique challenges.
+
+
+
+ Summarized Insights:
+ {" "}
+ Overall Mood Trends, Frequently Unmet Needs, Most-Used Tools:
+ These summaries give you a clear picture of your behavior and what
+ supports you best.
+
+
+
+ Insights Without Consistency:
+ {" "}
+ Even if you don’t use the app daily, you’ll still get meaningful
+ insights. This feature analyzes the data you’ve entered to create
+ trends and summaries, so there’s no pressure to engage frequently.
+
+
+
+
+ {/* Special Features Section */}
+
+
+ What Makes This Feature Special?
+
+
+ This feature isn’t just about collecting data—it’s about helping you
+ see the bigger picture. It empowers you to:
+
+
+
Understand patterns in your behavior and emotions.
+
Discover what tools and approaches work best for you.
+
+ Take control of your well-being by gaining actionable insights.
+
+
+
+ Whether you’re a casual user or someone who loves diving into
+ details, this feature adapts to your needs and makes your data
+ meaningful.
+
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/app/insights/page.tsx b/src/app/insights/page.tsx
index a71ccde2..7acea234 100644
--- a/src/app/insights/page.tsx
+++ b/src/app/insights/page.tsx
@@ -9,6 +9,7 @@ export default function InsightsPage() {
description="analyse your moods and needs over time."
hasInfoButton={true}
/>
+
>
);
diff --git a/src/app/moods/components/Cube.tsx b/src/app/moods/components/Cube.tsx
index 865a6da0..218a6801 100644
--- a/src/app/moods/components/Cube.tsx
+++ b/src/app/moods/components/Cube.tsx
@@ -47,7 +47,7 @@ interface CubeProps {
neuroState: NeurochemState;
}
-export function Cube({ neuroState }: CubeProps) {
+export default function Cube({ neuroState }: CubeProps) {
const [isPriorityMatrix, setIsPriorityMatrix] = useState(false);
const [hasRendered, setHasRendered] = useState(false);
diff --git a/src/app/moods/components/MoodsDisplay.tsx b/src/app/moods/components/MoodsDisplay.tsx
index e49e089f..0a85c37a 100644
--- a/src/app/moods/components/MoodsDisplay.tsx
+++ b/src/app/moods/components/MoodsDisplay.tsx
@@ -1,7 +1,7 @@
"use client";
-import { Cube } from "./Cube";
-import { SliderBox } from "./SliderBox";
+import Cube from "./Cube";
+import SliderBox from "./SliderBox";
import MoodButtons from "./MoodButtons";
import { useDatabase } from "@/context/DatabaseContext";
import { useState } from "react";
@@ -31,7 +31,42 @@ export default function MoodsDisplay() {
};
const submitMood = () => {
- const { dopamine, serotonin, adrenaline } = neuroState;
+ let moodName = "";
+ const { dopamine, serotonin, adrenaline } = neuroState as {
+ dopamine: number;
+ serotonin: number;
+ adrenaline: number;
+ };
+
+ if (dopamine <= 5) {
+ if (adrenaline <= 5) {
+ if (serotonin <= 5) {
+ moodName = "guilt";
+ } else if (serotonin >= 6) {
+ moodName = "content";
+ }
+ } else if (adrenaline >= 6) {
+ if (serotonin <= 5) {
+ moodName = "distress";
+ } else if (serotonin >= 6) {
+ moodName = "relief";
+ }
+ }
+ } else if (dopamine >= 6) {
+ if (adrenaline <= 5) {
+ if (serotonin <= 5) {
+ moodName = "freeze";
+ } else if (serotonin >= 6) {
+ moodName = "joy";
+ }
+ } else if (adrenaline >= 6) {
+ if (serotonin <= 5) {
+ moodName = "fight/flight";
+ } else if (serotonin >= 6) {
+ moodName = "interest";
+ }
+ }
+ }
const submitObj = {
neurotransmitters: {
@@ -39,7 +74,7 @@ export default function MoodsDisplay() {
serotonin: serotonin,
adrenaline: adrenaline,
},
- moodName: "new-mood",
+ moodName: moodName,
timestamp: new Date().toISOString(),
};
diff --git a/src/app/moods/components/SliderBox.tsx b/src/app/moods/components/SliderBox.tsx
index fac2dad3..218addd7 100644
--- a/src/app/moods/components/SliderBox.tsx
+++ b/src/app/moods/components/SliderBox.tsx
@@ -18,7 +18,7 @@ const sliders: {
{ chem: "adrenaline", label: "Step 3. Does it feel worth doing?" },
];
-export function SliderBox({ handleChange, neuroState }: SliderBoxProps) {
+export default function SliderBox({ handleChange, neuroState }: SliderBoxProps) {
return (