@@ -110,7 +112,6 @@ const RecipeDetails = () => {
{ingredientsArray?.map((x, ind) => {
-
return (
- )
+ );
})}
@@ -127,7 +128,6 @@ const RecipeDetails = () => {
{stepsArray?.map((x, ind) => {
-
return (
- )
+ );
})}
diff --git a/wannameal/src/pages/addProduct/addProduct.jsx b/wannameal/src/pages/addProduct/addProduct.jsx
index 57272c2..53f30ce 100644
--- a/wannameal/src/pages/addProduct/addProduct.jsx
+++ b/wannameal/src/pages/addProduct/addProduct.jsx
@@ -1,366 +1,417 @@
-import React, { useState } from 'react';
+import React, { useEffect, useState } from "react";
import style from "./page.module.css";
import { BiSolidTrash } from "react-icons/bi";
import { IoMdAddCircleOutline } from "react-icons/io";
import { MdCheckCircleOutline } from "react-icons/md";
import { CiCamera } from "react-icons/ci";
import axios from "axios";
-import { useTranslation } from 'react-i18next';
-import { useSelector } from 'react-redux';
-import { getuser } from '../../redux/slices/authSlice';
+import { useTranslation } from "react-i18next";
+import { useSelector } from "react-redux";
+import { getuser } from "../../redux/slices/authSlice";
+import { Helmet } from "react-helmet";
-const AddProduct = () => { // Changed from addProduct to AddProduct
- const [ingredientsValue, setIngredientsValue] = useState([{ id: 1, value: "" }]);
- const [directionsValue, setDirectionsValue] = useState([{ id: 1, value: "" }]);
- const [isActive, setisActive] = useState("");
- const [image, setImage] = useState(null);
- const { t } = useTranslation()
- const { Rname, Special, share, breaks, lunch, dinner, enough, time, Ingredients, Directions, addingredient, addStep, saveRecipe, cancelRecipe } = t('add')
- const user = useSelector(getuser)
- const [recipe, setRecipe] = useState({
- recipeName: "",
- information: "",
- typeMeals: "",
- times: "",
- EnoughFor: "",
- calories: 500,
- image: null,
- ingredients: [],
- steps: [],
- });
-
- const handleInputChange = (e) => {
- const { name, value } = e.target;
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- [name]: value,
- }));
- console.log(recipe);
- };
+const AddProduct = () => {
+ // Changed from addProduct to AddProduct
+ const [ingredientsValue, setIngredientsValue] = useState([
+ { id: 1, value: "" },
+ ]);
+ const [directionsValue, setDirectionsValue] = useState([
+ { id: 1, value: "" },
+ ]);
+ const [isActive, setisActive] = useState("");
+ const [image, setImage] = useState(null);
+ const [randomNumber, setRandomNumber] = useState(null);
+ const { t } = useTranslation();
+ const {
+ Rname,
+ Special,
+ share,
+ breaks,
+ lunch,
+ dinner,
+ enough,
+ time,
+ Ingredients,
+ Directions,
+ addingredient,
+ addStep,
+ saveRecipe,
+ cancelRecipe,
+ caloriess,
+ } = t("add");
+ useEffect(() => {
+ const randomNum = Math.floor(Math.random() * 100) + 1; // Generate random number between 1 and 100
+ setRandomNumber(randomNum);
+ }, [])
- const handleFileChange = (e) => {
- const file = e.target.files[0];
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- image: file,
- }));
- setImage(URL.createObjectURL(file));
- };
+ const user = useSelector(getuser);
+ const [recipe, setRecipe] = useState({
+ recipeName: "",
+ information: "",
+ typeMeals: "",
+ times: "",
+ EnoughFor: "",
+ calories: null,
+ _id: 24,
+ image: null,
+ ingredients: [],
+ steps: [],
+ });
- const handleAddIngredient = () => {
- const newIngredient = { id: ingredientsValue.length + 1, value: "" };
- setIngredientsValue([...ingredientsValue, newIngredient]);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- ingredients: [...ingredientsValue, newIngredient],
- }));
- };
+ const handleInputChange = (e) => {
+ const { name, value } = e.target;
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ [name]: value,
+ }));
+ console.log(recipe);
+ };
- const handleAddDirection = () => {
- const newDirection = { id: directionsValue.length + 1, value: "" };
- setDirectionsValue([...directionsValue, newDirection]);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- steps: [...directionsValue, newDirection],
- }));
- };
+ const handleFileChange = (e) => {
+ const file = e.target.files[0];
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ image: file,
+ }));
+ setImage(URL.createObjectURL(file));
+ };
- const handleIngredientChange = (index, value) => {
- const updatedIngredients = [...ingredientsValue];
- updatedIngredients[index].value = value;
- setIngredientsValue(updatedIngredients);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- ingredients: updatedIngredients,
- }));
- };
+ const handleAddIngredient = () => {
+ const newIngredient = { id: ingredientsValue.length + 1, value: "" };
+ setIngredientsValue([...ingredientsValue, newIngredient]);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ ingredients: [...ingredientsValue, newIngredient],
+ }));
+ };
- const handleDirectionChange = (index, value) => {
- const updatedDirections = [...directionsValue];
- updatedDirections[index].value = value;
- setDirectionsValue(updatedDirections);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- steps: updatedDirections,
- }));
- };
+ const handleAddDirection = () => {
+ const newDirection = { id: directionsValue.length + 1, value: "" };
+ setDirectionsValue([...directionsValue, newDirection]);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ steps: [...directionsValue, newDirection],
+ }));
+ };
- const handleRemoveIngredient = (index) => {
- const updatedIngredients = [...ingredientsValue];
- updatedIngredients.splice(index, 1);
- setIngredientsValue(updatedIngredients);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- ingredients: updatedIngredients,
- }));
- };
+ const handleIngredientChange = (index, value) => {
+ const updatedIngredients = [...ingredientsValue];
+ updatedIngredients[index].value = value;
+ setIngredientsValue(updatedIngredients);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ ingredients: updatedIngredients,
+ }));
+ };
- const handleRemoveDirection = (index) => {
- const updatedDirections = [...directionsValue];
- updatedDirections.splice(index, 1);
- setDirectionsValue(updatedDirections);
- setRecipe((prevRecipe) => ({
- ...prevRecipe,
- steps: updatedDirections,
- }));
- };
+ const handleDirectionChange = (index, value) => {
+ const updatedDirections = [...directionsValue];
+ updatedDirections[index].value = value;
+ setDirectionsValue(updatedDirections);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ steps: updatedDirections,
+ }));
+ console.log(recipe);
+ };
- const clearInputs = () => {
- setRecipe({
- recipeName: "",
- information: "",
- typeMeals: "",
- times: "",
- EnoughFor: "",
- calories: 500,
- image: null,
- ingredients: [],
- steps: [],
- });
- setImage(null);
- setIngredientsValue([{ id: 1, value: "" }]);
- setDirectionsValue([{ id: 1, value: "" }]);
- setisActive('')
- };
+ const handleRemoveIngredient = (index) => {
+ const updatedIngredients = [...ingredientsValue];
+ updatedIngredients.splice(index, 1);
+ setIngredientsValue(updatedIngredients);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ ingredients: updatedIngredients,
+ }));
+ };
+ const handleRemoveDirection = (index) => {
+ const updatedDirections = [...directionsValue];
+ updatedDirections.splice(index, 1);
+ setDirectionsValue(updatedDirections);
+ setRecipe((prevRecipe) => ({
+ ...prevRecipe,
+ steps: updatedDirections,
+ }));
+ };
- const handleAddRecipe = async (e) => {
- e.preventDefault();
- // take the value only
- const ingredients = ingredientsValue.map((ingredient) => ingredient.value);
- const directions = directionsValue.map((direction) => direction.value);
- // add data to form
- const formData = new FormData();
- formData.append("recipeName", recipe.recipeName);
- formData.append("information", recipe.information);
- formData.append("typeMeals", recipe.typeMeals);
- formData.append("times", recipe.times);
- formData.append("EnoughFor", recipe.EnoughFor);
- formData.append("calories", recipe.calories);
- formData.append("image", recipe.image);
- formData.append("ingredients", JSON.stringify(ingredients));
- formData.append("steps", JSON.stringify(directions));
-
- try {
- const response = await axios.post(
- "https://fast-plat1.vercel.app/meals/addAnewRecipe",
- formData,
- {
- headers: {
- "Content-Type": "multipart/form-data",
- token:
- user?.token,
- },
- }
- );
+ const clearInputs = () => {
+ setRecipe({
+ recipeName: "",
+ information: "",
+ typeMeals: "",
+ times: "",
+ EnoughFor: "",
+ calories: 500,
+ image: null,
+ ingredients: [],
+ steps: [],
+ });
+ setImage(null);
+ setIngredientsValue([{ id: 1, value: "" }]);
+ setDirectionsValue([{ id: 1, value: "" }]);
+ setisActive("");
+ };
- console.log(response.data);
- // Handle success
- clearInputs();
- } catch (error) {
- console.error(error.response.data);
- // Handle error
+ const handleAddRecipe = async (e) => {
+ e.preventDefault();
+ // take the value only
+ const ingredients = ingredientsValue.map((ingredient) => ingredient.value);
+ const directions = directionsValue.map((direction) => direction.value);
+ // add data to form
+ const formData = new FormData();
+ formData.append("recipeName", recipe.recipeName);
+ formData.append("information", recipe.information);
+ formData.append("typeMeals", recipe.typeMeals);
+ formData.append("times", recipe.times);
+ formData.append("EnoughFor", recipe.EnoughFor);
+ formData.append("calories", recipe.calories);
+ formData.append("_id", recipe._id);
+ formData.append("image", recipe.image);
+ formData.append("ingredients", JSON.stringify(ingredients.join(',')));
+ formData.append("steps", JSON.stringify(directions.join(',')));
+ try {
+ const response = await axios.post(
+ "https://fast-plat1.vercel.app/meals/addAnewRecipe",
+ formData,
+ {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ token: user?.token,
+ },
}
- };
- console.log(user)
- return (
-
-
-
-
+
+ Add Meal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{Ingredients}
+
+
+ {ingredientsValue.map((ingredient, index) => (
+
+
{index + 1}
+
handleIngredientChange(index, e.target.value)}
+ />
+
handleRemoveIngredient(index)}
+ />
-
-
-
+ ))}
+
+
+
+
{Directions}
+
+
+ {directionsValue.map((direction, index) => (
+
+
{index + 1}
+
handleDirectionChange(index, e.target.value)}
+ />
+
handleRemoveDirection(index)}
+ />
+ ))}
+
- );
+
+
+
+
+
+
+ );
};
export default AddProduct; // Changed from addProduct to AddProduct
diff --git a/wannameal/src/pages/chatting/chatting.jsx b/wannameal/src/pages/chatting/chatting.jsx
index ecd523a..e91b5aa 100644
--- a/wannameal/src/pages/chatting/chatting.jsx
+++ b/wannameal/src/pages/chatting/chatting.jsx
@@ -7,6 +7,8 @@ import { VscSend } from "react-icons/vsc";
import InputEmoji from "react-input-emoji";
import { useSelector, useDispatch } from "react-redux";
import { getTheme } from "../../redux/slices/systemModeSlice";
+import { Helmet } from "react-helmet";
+
export default function Chatting() {
let chats = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8];
const [activeChat, setActiveChat] = useState(true);
@@ -44,6 +46,13 @@ export default function Chatting() {
}, []);
return (
+
+ WannaMeal messenger
+
+
diff --git a/wannameal/src/pages/community/comunity.jsx b/wannameal/src/pages/community/comunity.jsx
index 3741f7c..d034d49 100644
--- a/wannameal/src/pages/community/comunity.jsx
+++ b/wannameal/src/pages/community/comunity.jsx
@@ -11,6 +11,8 @@ import Post from "../../components/post/post";
import { VscSend } from "react-icons/vsc";
import { useSelector, useDispatch } from "react-redux";
import { getuser, getDecodedToken } from "../../redux/slices/authSlice";
+import { Helmet } from "react-helmet";
+
import {
createPost,
fetchFeedPosts,
@@ -275,6 +277,13 @@ export default function Community() {
return (
+
+ WannaMeal community
+
+
@@ -327,7 +336,7 @@ export default function Community() {
{suggestedUsers && suggestedUsers?.length > 0 ? (
suggestedUsers.map((user) => (
+
+ Contact Us
+
+
diff --git a/wannameal/src/pages/dashboeard/dashboard.jsx b/wannameal/src/pages/dashboeard/dashboard.jsx
index 022b6b5..b0bcaf1 100644
--- a/wannameal/src/pages/dashboeard/dashboard.jsx
+++ b/wannameal/src/pages/dashboeard/dashboard.jsx
@@ -6,10 +6,15 @@ import DashNav from "../../components/dashNav/dashNav";
import Sidebar from "../../components/sidebar/sidebar";
import { Route, Routes } from "react-router-dom";
import React from "react";
+import { Helmet } from "react-helmet";
export default function Dashboard() {
return (
+
+ Dashboard
+
+
+
Make Your Meal
+
+ ;
const theme = useSelector(getTheme);
const { t } = useTranslation();
- const {
- make,
- meal,
- } = t('make');
+ const { make, meal } = t("make");
return (
{
setLink(window.location.href);
const handlePopState = () => {
@@ -122,6 +139,10 @@ function Portfolio() {
return (
<>
+
+ Profile
+
+
@@ -152,11 +173,9 @@ function Portfolio() {
-
{user?.followers?.length || 0} {followers}
-
{user?.following?.length || 0} {following}
@@ -182,9 +201,9 @@ function Portfolio() {
className={`${styles.settingIcon}`}
data-bs-target="#exampleModalToggle"
data-bs-toggle="modal"
- // onClick={() => {
- // console.log("🚀 ~ Portfolio ~ showOverlay:", showOverlay);
- // }}
+ // onClick={() => {
+ // console.log("🚀 ~ Portfolio ~ showOverlay:", showOverlay);
+ // }}
>
diff --git a/wannameal/src/redux/slices/recomendedMealsSlice.jsx b/wannameal/src/redux/slices/recomendedMealsSlice.jsx
index 48957ae..158cea1 100644
--- a/wannameal/src/redux/slices/recomendedMealsSlice.jsx
+++ b/wannameal/src/redux/slices/recomendedMealsSlice.jsx
@@ -83,6 +83,19 @@ export const fetchSavedMeals = createAsyncThunk(
}
}
);
+export const fetchMyRecipes = createAsyncThunk(
+ "meals/fetchMyRecipes",
+ async ({ userId, lang }, { rejectWithValue }) => {
+ try {
+ const response = await axios.get(
+ `https://fast-plat1.vercel.app/meals?user=${userId}`
+ );
+ return response.data.result;
+ } catch (error) {
+ return rejectWithValue(error.message);
+ }
+ }
+);
export const saveMeal = createAsyncThunk(
"meals/saveMeal",
@@ -105,23 +118,12 @@ export const saveMeal = createAsyncThunk(
}
);
-export const fetchMyRecipes = createAsyncThunk(
- "meals/fetchMyRecipes",
- async ({ userId }, { rejectWithValue }) => {
- try {
- const response = await axios.get(`https://fast-plat1.vercel.app/meals`);
- return response.result;
- } catch (error) {
- return rejectWithValue(error.message);
- }
- }
-);
export const fetchCommonMeals = createAsyncThunk(
"meals/fetchCommonMeals",
async ({ token, lang }, { rejectWithValue }) => {
try {
const response = await axios.get(
- `https://fast-plat1.vercel.app/meals/common-meals?lang=${lang}`,
+ `https://tesst11.azurewebsites.net/meals/common-meals?lang=${lang}`,
{
headers: {
token: `${token}`,
diff --git a/wannameal/src/redux/slices/systemModeSlice.jsx b/wannameal/src/redux/slices/systemModeSlice.jsx
index 63a8c13..fe089a6 100644
--- a/wannameal/src/redux/slices/systemModeSlice.jsx
+++ b/wannameal/src/redux/slices/systemModeSlice.jsx
@@ -5,16 +5,14 @@ const loadTheme = () => {
const savedTheme = localStorage.getItem("theme");
return savedTheme ? JSON.parse(savedTheme) : "dark";
} catch (err) {
- return "dark";
+ return "light";
}
};
const saveTheme = (theme) => {
try {
localStorage.setItem("theme", JSON.stringify(theme));
- } catch (err) {
- // Ignore write errors
- }
+ } catch (err) {}
};
const initialState = {