diff --git a/home.html b/home.html index cc09348..99c1fb4 100644 --- a/home.html +++ b/home.html @@ -14,7 +14,7 @@ body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; - background-color: #f2f2f2; + background: linear-gradient(120deg, #eef2ff 0%, #f8fafc 55%, #fff7ed 100%); display: flex; } @@ -129,6 +129,53 @@ background: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + margin-bottom: 18px; + } + + .hero { + background: linear-gradient(130deg, #29293d, #364474); + color: #fff; + padding: 28px; + border-radius: 14px; + box-shadow: 0 12px 26px rgba(41, 41, 61, 0.22); + margin-bottom: 18px; + } + + .hero p { + margin-top: 10px; + line-height: 1.55; + color: #e7e7f8; + } + + .stats-grid, .features-grid { + display: grid; + gap: 14px; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + } + + .stat-card, .feature-card { + background: #fff; + border-radius: 12px; + padding: 16px; + box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); + border: 1px solid #f1f5f9; + } + + .stat-card h3 { + color: #29293d; + margin-bottom: 6px; + } + + .feature-card i { + color: #ffaa00; + margin-bottom: 10px; + font-size: 22px; + } + + .feature-card p { + color: #334155; + font-size: 14px; + margin-top: 5px; } @media (max-width: 768px) { @@ -185,9 +232,36 @@

Welcome, User

testimonials -
+

Welcome to CoreFit!

-

This is your personalized fitness platform. Use the tabs above to navigate through your workout, diet, and progress tools.

+

Track your fitness journey, explore workouts, and stay consistent with guided plans made for your goals.

+
+ +
+

Your Quick Overview

+
+
+

Goal: --

+

Your selected target stays visible here.

+
+
+

Weight: --

+

Track and update progress from the dashboard.

+
+
+

Program: --

+

Access your chosen training path anytime.

+
+
+
+ +
+

What You Can Do

+
+

Workout Plans

Browse exercises and classes by category.

+

Diet Guidance

Find healthy meal ideas and calorie tools.

+

Progress Tracking

Monitor improvements and stay motivated.

+
@@ -199,6 +273,7 @@

Welcome to CoreFit!

const age = sessionStorage.getItem("age") || "--"; const goal = sessionStorage.getItem("goal") || "--"; const weight = sessionStorage.getItem("weight") || "--"; + const program = sessionStorage.getItem("program") || "--"; document.getElementById("profile-name").innerText = `Welcome, ${name}`; document.getElementById("profile-details").innerHTML = ` @@ -207,6 +282,9 @@

Welcome to CoreFit!

Goal: ${goal}

Weight: ${weight} kg

`; + document.getElementById("goal-card").innerText = `Goal: ${goal}`; + document.getElementById("weight-card").innerText = `Weight: ${weight} kg`; + document.getElementById("program-card").innerText = `Program: ${program}`; const savedPic = sessionStorage.getItem("profilePic"); if (savedPic) { diff --git a/index.html b/index.html index 8858701..99c1fb4 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@ body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; - background-color: #f2f2f2; + background: linear-gradient(120deg, #eef2ff 0%, #f8fafc 55%, #fff7ed 100%); display: flex; } @@ -129,6 +129,53 @@ background: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + margin-bottom: 18px; + } + + .hero { + background: linear-gradient(130deg, #29293d, #364474); + color: #fff; + padding: 28px; + border-radius: 14px; + box-shadow: 0 12px 26px rgba(41, 41, 61, 0.22); + margin-bottom: 18px; + } + + .hero p { + margin-top: 10px; + line-height: 1.55; + color: #e7e7f8; + } + + .stats-grid, .features-grid { + display: grid; + gap: 14px; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + } + + .stat-card, .feature-card { + background: #fff; + border-radius: 12px; + padding: 16px; + box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); + border: 1px solid #f1f5f9; + } + + .stat-card h3 { + color: #29293d; + margin-bottom: 6px; + } + + .feature-card i { + color: #ffaa00; + margin-bottom: 10px; + font-size: 22px; + } + + .feature-card p { + color: #334155; + font-size: 14px; + margin-top: 5px; } @media (max-width: 768px) { @@ -162,7 +209,7 @@

Welcome, User

- +
@@ -185,9 +232,36 @@

Welcome, User

testimonials -
+

Welcome to CoreFit!

-

This is your personalized fitness platform. Use the tabs above to navigate through your workout, diet, and progress tools.

+

Track your fitness journey, explore workouts, and stay consistent with guided plans made for your goals.

+
+ +
+

Your Quick Overview

+
+
+

Goal: --

+

Your selected target stays visible here.

+
+
+

Weight: --

+

Track and update progress from the dashboard.

+
+
+

Program: --

+

Access your chosen training path anytime.

+
+
+
+ +
+

What You Can Do

+
+

Workout Plans

Browse exercises and classes by category.

+

Diet Guidance

Find healthy meal ideas and calorie tools.

+

Progress Tracking

Monitor improvements and stay motivated.

+
@@ -199,6 +273,7 @@

Welcome to CoreFit!

const age = sessionStorage.getItem("age") || "--"; const goal = sessionStorage.getItem("goal") || "--"; const weight = sessionStorage.getItem("weight") || "--"; + const program = sessionStorage.getItem("program") || "--"; document.getElementById("profile-name").innerText = `Welcome, ${name}`; document.getElementById("profile-details").innerHTML = ` @@ -207,6 +282,9 @@

Welcome to CoreFit!

Goal: ${goal}

Weight: ${weight} kg

`; + document.getElementById("goal-card").innerText = `Goal: ${goal}`; + document.getElementById("weight-card").innerText = `Weight: ${weight} kg`; + document.getElementById("program-card").innerText = `Program: ${program}`; const savedPic = sessionStorage.getItem("profilePic"); if (savedPic) { @@ -250,8 +328,5 @@

Welcome to CoreFit!

window.location.href = "login.html"; } - - - diff --git a/registration.html b/registration.html index c12c41c..f583e89 100644 --- a/registration.html +++ b/registration.html @@ -214,6 +214,7 @@

CoreFit Registration

+ Already have an account? Login
@@ -283,7 +284,7 @@

✅ Registration Successful!

for (const key in data) { sessionStorage.setItem(key, data[key]); } - window.location.href = "index.html"; + window.location.href = "home.html"; } else { alert(`Registration failed: ${result.error}`); } diff --git a/server.js b/server.js index f8a3425..69db5e5 100644 --- a/server.js +++ b/server.js @@ -3,15 +3,32 @@ const bodyParser = require("body-parser"); const fs = require("fs"); const path = require("path"); const XLSX = require("xlsx"); +const cors = require("cors"); +const bcrypt = require("bcryptjs"); const app = express(); +app.use(cors()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); // Path to Excel file const filePath = path.join(__dirname, "registrations.xlsx"); -// Function to save data to a specific sheet +function readWorkbook() { + if (fs.existsSync(filePath)) { + return XLSX.readFile(filePath); + } + return XLSX.utils.book_new(); +} + +function readSheet(sheetName) { + const workbook = readWorkbook(); + if (!workbook.SheetNames.includes(sheetName)) { + return []; + } + return XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); +} + function saveToExcel(sheetName, data) { let workbook; if (fs.existsSync(filePath)) { @@ -41,8 +58,105 @@ function saveToExcel(sheetName, data) { XLSX.writeFile(workbook, filePath); } +function normalizeEmail(value) { + return String(value || "").trim().toLowerCase(); +} + +function getField(row, fieldNames) { + for (const fieldName of fieldNames) { + if (row[fieldName] !== undefined) { + return row[fieldName]; + } + } + return ""; +} + // ------------------- ROUTES -------------------- +app.get("/api/test", (req, res) => { + res.json({ success: true, message: "Server is running" }); +}); + +app.post("/api/register", async (req, res) => { + try { + const requiredFields = ["name", "email", "password", "phone", "age", "gender", "weight", "goal", "domain", "program"]; + for (const field of requiredFields) { + if (!req.body[field] || String(req.body[field]).trim() === "") { + return res.status(400).json({ error: `Missing required field: ${field}` }); + } + } + + const email = normalizeEmail(req.body.email); + const users = readSheet("Users"); + const alreadyExists = users.some((user) => + normalizeEmail(getField(user, ["email", "Email"])) === email + ); + + if (alreadyExists) { + return res.status(400).json({ error: "Email already registered" }); + } + + const passwordHash = await bcrypt.hash(String(req.body.password), 10); + const userToSave = { + name: String(req.body.name).trim(), + email, + passwordHash, + phone: String(req.body.phone).trim(), + age: String(req.body.age).trim(), + gender: String(req.body.gender).trim(), + weight: String(req.body.weight).trim(), + goal: String(req.body.goal).trim(), + domain: String(req.body.domain).trim(), + program: String(req.body.program).trim(), + createdAt: new Date().toISOString() + }; + + saveToExcel("Users", userToSave); + const { passwordHash: _ignored, ...safeUser } = userToSave; + res.status(201).json({ success: true, message: "Registration successful", user: safeUser }); + } catch (error) { + res.status(500).json({ error: "Unable to register user" }); + } +}); + +app.post("/api/login", async (req, res) => { + try { + const email = normalizeEmail(req.body.email); + const password = String(req.body.password || ""); + if (!email || !password) { + return res.status(400).json({ error: "Email and password are required" }); + } + + const users = readSheet("Users"); + const user = users.find((row) => normalizeEmail(getField(row, ["email", "Email"])) === email); + if (!user) { + return res.status(401).json({ error: "Invalid email or password" }); + } + + const storedHash = String(getField(user, ["passwordHash", "PasswordHash", "password", "Password"])); + const isValidPassword = storedHash ? await bcrypt.compare(password, storedHash) : false; + if (!isValidPassword) { + return res.status(401).json({ error: "Invalid email or password" }); + } + + const safeUser = { + name: getField(user, ["name", "Name"]) || "", + email: getField(user, ["email", "Email"]) || "", + phone: getField(user, ["phone", "Phone"]) || "", + age: getField(user, ["age", "Age"]) || "", + gender: getField(user, ["gender", "Gender"]) || "", + weight: getField(user, ["weight", "Weight"]) || "", + goal: getField(user, ["goal", "Goal"]) || "", + domain: getField(user, ["domain", "Domain"]) || "", + program: getField(user, ["program", "Program"]) || "" + }; + + res.json({ success: true, message: "Login successful", user: safeUser }); + } catch (error) { + res.status(500).json({ error: "Unable to login" }); + } +}); + // Signup app.post("/api/signup", (req, res) => { saveToExcel("Signup", req.body);