Skip to content

Commit

Permalink
Merge pull request #14 from thedemonsid/update/forms
Browse files Browse the repository at this point in the history
Update/forms Merge all three forms into one big form
  • Loading branch information
thedemonsid authored Jul 12, 2024
2 parents 7646739 + 1e303ad commit 2bd4f29
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 520 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:
- You are about to drop the column `filledForms` on the `users` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "users" DROP COLUMN "filledForms",
ADD COLUMN "flagfilled" BOOLEAN DEFAULT false;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ model User {
dietPlans DietPlan[]
aiWorkout String? // AI generated workout but temporary need to change
aiDiet String? // AI generated diet but temporary need to change
filledForms Json? @default("{\"onboarding\": false, \"workout\": false, \"diet\": false}")
flagfilled Boolean? @default(false)
@@map(name: "users")
}
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions src/app/Diet/diet-info-form/page.jsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/Diet/your-meal/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ function PersonalDietPage() {
useEffect(() => {
// Fetching meal data by user ID
if (session) {
if (session?.user?.filledForms.diet) {
fetchGeminiResponse(session?.user?.id,"meal").then((data) => {
if (session?.user?.flagfilled) {
fetchGeminiResponse(session?.user?.id, "meal").then((data) => {
//console.log(data);
setContent(data); // Setting the fetched data to state
});
} else {
redirect("/Diet/diet-info-form");
redirect("/OnBoardForm");
}
}
}, [session?.user?.id]);
Expand Down
12 changes: 12 additions & 0 deletions src/app/Gym/GymPokedex/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import MealPokedex from "@/components/MealPokedexComponent";
import React from "react";

const page = () => {
return (
<div>
<MealPokedex></MealPokedex>
</div>
);
};

export default page;
12 changes: 0 additions & 12 deletions src/app/Gym/workout-info-form/page.jsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/Gym/your-workout/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function PersonalWorkoutPage() {
useEffect(() => {
// Fetching Exercise data by user ID
if (session) {
if (session?.user?.filledForms.workout) {
fetchGeminiResponse(session?.user?.id,"exercise").then((data) => {
if (session?.user?.flagfilled) {
fetchGeminiResponse(session?.user?.id, "exercise").then((data) => {
//console.log(data);
setContent(data); // Setting the fetched data to state
});
} else {
redirect("/Gym/workout-info-form");
redirect("/OnBoardForm");
}
}
}, [session?.user?.id]);
Expand Down
4 changes: 2 additions & 2 deletions src/app/OnBoardForm/page.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GymQuestionnaireCarousel from "@/components/forms/OnboardForm";
import AllInOneForm from "@/components/forms/AllInOneForm";
import React from "react";

const page = () => {
return (
<div>
<GymQuestionnaireCarousel></GymQuestionnaireCarousel>
<AllInOneForm></AllInOneForm>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/auth/[...nextauth]/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const options = {
});
if (sessionUser) {
session.user.id = sessionUser.id;
session.user.filledForms = sessionUser.filledForms;
session.user.flagfilled = sessionUser.flagfilled;
}
}
return session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,36 @@ import {
import { Button } from "@/components/ui/button";
import { ChevronLeft, ChevronRight } from "lucide-react";
import UpdateUser from "@/utils/updateUser";

const questions = [
{
id: "fitnessGoal",
question: "What is your primary fitness goal?",
type: "select",
options: [
"Weight Loss",
"Weight Gain",
"Maintain Weight",
"Improve Health",
],
description: "Choose the primary goal for your fitness journey",
},
{
id: "dietPreference",
question: "Do you have any dietary Preferences?",
type: "select",
options: [
"None",
"Vegetarian",
"Vegan",
"Gluten-free",
"Lactose-free",
"Other",
],
description: "Select your dietary restrictions if any, or select 'None'",
},
{
id: "region",
question: "What is your preferred cuisine?",
type: "select",
options: [
"INDIAN",
"AMERICAN",
"CHINESE",
"ITALIAN",
"MEXICAN",
"CONTINENTAL",
"OTHER",
],
},
];
import questions from "@/lib/FormQuestions";
import { useSession } from "next-auth/react";
import FitnessLoader from "@/app/loading";
const DietQuestionnaireCarousel = () => {
const AllInOneForm = () => {
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
const router = useRouter();
const { data: session } = useSession();
useEffect(() => {
if (session) {
if (session?.user?.filledForms.diet) {
router.push("/Gym/workout-info-form");
if (session?.user?.flagfilled) {
router.push("/Dashboard");
}
}
}, [session]);
const [answers, setAnswers] = useState({
name: "",
age: "",
height: "",
weight: "",
fitnessGoal: "",
frequency: "",
healthConditions: "",
dietPreference: "",
region: "",
fitnessGoal: "",
frequency: "",
ExerciseType: "",
fitnessLevel: "",
intensityLevel: "",
equipmentAccess: "",
});

const handleInputChange = (id, value) => {
Expand All @@ -97,9 +67,9 @@ const DietQuestionnaireCarousel = () => {
console.error("Failed to update user");
}
console.log("User updated successfully");
session.user.filledForms.diet = true;
session.user.flagfilled = true;
// console.log(session);
router.push("/Diet/your-meal");
router.push("/Dashboard");
};

const currentQuestion = questions[currentQuestionIndex];
Expand Down Expand Up @@ -150,6 +120,7 @@ const DietQuestionnaireCarousel = () => {
) : (
<Input
type={currentQuestion.type}
autoFocus
placeholder={
currentQuestion.placeholder || "Enter your answer"
}
Expand Down Expand Up @@ -203,4 +174,4 @@ const DietQuestionnaireCarousel = () => {
);
};

export default DietQuestionnaireCarousel;
export default AllInOneForm;
Loading

0 comments on commit 2bd4f29

Please sign in to comment.