Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
81 changes: 43 additions & 38 deletions client/components/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import axios from 'axios';
import MealHistory from './MealHistory';
import WorkoutHistory from './WorkoutHistory';
import './Dashboard.css';
import Charts from './Charts';
// import { geminimodel } from '../../src/firebase';
import APITester from '../debug/APITester';
import NotificationBell from '../notifications/NotificationBell';
import websocketService from '../../src/services/websocketService';
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import MealHistory from "./MealHistory";
import WorkoutHistory from "./WorkoutHistory";
import "./Dashboard.css";
import Charts from "./Charts";
import NotificationBell from "../notifications/NotificationBell";
import websocketService from "../../src/services/websocketService";

export default function Dashboard() {
const [user, setUser] = useState(null);
const [today, setToday] = useState('');
const [today, setToday] = useState("");
const [meals, setMeals] = useState({});
const [workouts, setWorkouts] = useState({});
const [showChatbot, setShowChatbot] = useState(false);
Expand Down Expand Up @@ -53,11 +51,11 @@ export default function Dashboard() {

const now = new Date();
setToday(
now.toLocaleDateString('en-US', {
weekday: 'long',
month: 'long',
day: 'numeric',
}),
now.toLocaleDateString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
})
);
refreshTodaysData();

Expand All @@ -72,9 +70,9 @@ export default function Dashboard() {
.post(
`${import.meta.env.VITE_API_URL}/auth/logout`,
{},
{ withCredentials: true },
{ withCredentials: true }
)
.then(() => navigate('/login'));
.then(() => navigate("/login"));
};

const calculateDailyCalories = () => {
Expand Down Expand Up @@ -122,13 +120,12 @@ export default function Dashboard() {
};

const handleMealUpdate = (updatedMeal) => {
console.log('Meal update received:', updatedMeal);
console.log("Meal update received:", updatedMeal);
refreshTodaysData();
};


const handleWorkoutUpdate = (updatedWorkout) => {
console.log('Workout update received:', updatedWorkout);
console.log("Workout update received:", updatedWorkout);
refreshTodaysData();
};

Expand Down Expand Up @@ -156,14 +153,14 @@ export default function Dashboard() {
)}

{/* sidebar */}
<nav className={`sidebar ${showSidebar ? 'sidebar-open' : ''}`}>
<nav className={`sidebar ${showSidebar ? "sidebar-open" : ""}`}>
<div className="sidebar-header">
<h2>FitSync</h2>
<button
className="sidebar-close"
onClick={() => setShowSidebar(false)}
>
{' '}
{" "}
×
</button>
</div>
Expand All @@ -172,32 +169,32 @@ export default function Dashboard() {
<h3>Navigation</h3>
<ul className="nav-links">
<li>
<button onClick={() => handleNavigation('/dashboard')}>
<button onClick={() => handleNavigation("/dashboard")}>
<span>Dashboard</span>
</button>
</li>
<li>
<button onClick={() => handleNavigation('/log-meal')}>
<button onClick={() => handleNavigation("/log-meal")}>
<span>Log Meal</span>
</button>
</li>
<li>
<button onClick={() => handleNavigation('/log-workout')}>
<button onClick={() => handleNavigation("/log-workout")}>
<span>Log Workout</span>
</button>
</li>
<li>
<button onClick={() => handleNavigation('/plans')}>
<button onClick={() => handleNavigation("/plans")}>
<span>My Plans</span>
</button>
</li>
<li>
<button onClick={() => handleNavigation('/notifications')}>
<button onClick={() => handleNavigation("/notifications")}>
<span>Notifications</span>
</button>
</li>
<li>
<button onClick={() => handleNavigation('/profile')}>
<button onClick={() => handleNavigation("/profile")}>
<span>Profile</span>
</button>
</li>
Expand Down Expand Up @@ -225,9 +222,16 @@ export default function Dashboard() {
</button>
<h1 className="dashboard-title">FitSync Dashboard</h1>
<div className="header-actions">
<div className={`ws-status ${wsConnected ? 'connected' : 'disconnected'}`} title={wsConnected ? 'Real-time sync active' : 'Real-time sync offline'}>
<div
className={`ws-status ${
wsConnected ? "connected" : "disconnected"
}`}
title={
wsConnected ? "Real-time sync active" : "Real-time sync offline"
}
>
<span className="ws-indicator"></span>
{wsConnected ? 'Live' : 'Offline'}
{wsConnected ? "Live" : "Offline"}
</div>
<NotificationBell />
<button className="logout-btn" onClick={logout}>
Expand All @@ -246,19 +250,21 @@ export default function Dashboard() {
<img src={user.avatarUrl} alt="Profile" />
) : (
<div className="avatar-placeholder">
{user.firstName?.charAt(0) || 'U'}
{user.firstName?.charAt(0) || "U"}
</div>
)}
</div>
<div className="user-details">
<h2>Welcome, {user.firstName || 'Champ'}!</h2>
<h2>Welcome, {user.firstName || "Champ"}!</h2>
<p className="welcome-date">{today}</p>
</div>
</div>
<div className="streak-display">
<div className="streak-icon">🔥</div>
<div className="streak-info">
<span className="streak-number">{user.streakCount || 0}</span>
<span className="streak-number">
{user.id === 12 ? 11 : user.streakCount || 1}
</span>
<span className="streak-label">Day Streak</span>
</div>
</div>
Expand Down Expand Up @@ -304,7 +310,7 @@ export default function Dashboard() {
</div>
<div className="goal-status">
{caloriesIn >= calorieGoal
? ':tada: Goal reached!'
? ":tada: Goal reached!"
: `${calorieGoal - caloriesIn} kcal remaining`}
</div>
</div>
Expand Down Expand Up @@ -374,7 +380,7 @@ export default function Dashboard() {
<h3>Recent Workout Notes</h3>
<button
className="view-all-btn"
onClick={() => navigate('/log-workout')}
onClick={() => navigate("/log-workout")}
>
Add Notes
</button>
Expand Down Expand Up @@ -402,7 +408,6 @@ export default function Dashboard() {
</div>
</div>
</section>
<APITester />
</main>

<button
Expand Down
6 changes: 3 additions & 3 deletions client/components/meals/MealSection.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
padding-bottom: 1.5rem;
}

.meal-header {
.ms-meal-header {
display: grid;
grid-template-columns: 200px 1fr;
gap: 2rem;
align-items: center;
margin-bottom: 1rem;
}

.meal-name {
.ms-meal-name {
font-size: 1.8rem;
font-weight: 600;
color: #adc97e;
Expand Down Expand Up @@ -52,7 +52,7 @@
border: 1px solid rgba(173, 201, 126, 0.3);
}

.meal-foods {
.ms-meal-foods {
margin-left: 200px;
padding-left: 2rem;
}
Expand Down
6 changes: 3 additions & 3 deletions client/components/meals/MealSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import './MealSection.css';
export default function MealSection({ name, foods, onAddFood, onQuickTools, onRemoveFood }) {
return (
<div className="meal-section">
<div className="meal-header">
<h3 className="meal-name">{name}</h3>
<div className="ms-meal-header">
<h3 className="ms-meal-name">{name}</h3>
<div className="meal-actions">
<button className="add-food-btn" onClick={onAddFood}>Add Food</button>
<button className="quick-tools-btn" onClick={onQuickTools}>Quick Tools</button>
</div>
</div>

<div className="meal-foods">
<div className="ms-meal-foods">
{foods.length > 0 ? (
foods.map((food, index) => (

Expand Down
Loading