diff --git a/wannameal/src/components/FoodIngreientSlider/FoodIngreientSlider.jsx b/wannameal/src/components/FoodIngreientSlider/FoodIngreientSlider.jsx index 914ad34..c48f884 100644 --- a/wannameal/src/components/FoodIngreientSlider/FoodIngreientSlider.jsx +++ b/wannameal/src/components/FoodIngreientSlider/FoodIngreientSlider.jsx @@ -45,8 +45,6 @@ function FoodIngreientSlider() { const ingredientsStatus = useSelector(getIngredientsStatus); const ingredientError = useSelector(getIngredientsError); const language = useSelector(getLanguage); - console.log("🚀 ~ FoodIngreientSlider ~ language:", language); - console.log("🚀 ~ FoodIngreientSlider ~ language:", language); const handleCheckboxChange = (ingredient) => { setCheckedIngredients((prevIngredients) => { @@ -90,7 +88,7 @@ function FoodIngreientSlider() { useEffect(() => { const fetchMeals = async () => { try { - let ingredientNames = "موز"; // Default value if no checked ingredients + let ingredientNames = ""; // Default value if no checked ingredients console.log("🚀 ~ fetchMeals ~ ingredientNames:", ingredientNames); if (checkedIngredients.length > 0) { ingredientNames = checkedIngredients @@ -102,37 +100,19 @@ function FoodIngreientSlider() { "🚀 ~ fetchMeals ~ checkedIngredients:", checkedIngredients ); - console.log( - "🚀🚀🚀🚀🚀 ~ fetchMeals ~ ingredientNames:", - ingredientNames - ); - - await dispatch( - recommendMeals({ - ingredients: ingredientNames, - lang: language, - token: availableUser?.token, - }) - ); - - // axios - // .get("https://tesst11.azurewebsites.net/meals/recommendMeal", { - // params: { - // lang: language, - // ingredients: ingredientNames, - // }, - // headers: { - // token: availableUser?.token, - // }, - // }) - // .then((response) => { - // console.log(response.data); - // }) - // .catch((error) => { - // console.error(error); - // }); + console.log(ingredientNames); + console.log(typeof ingredientNames); - // console.log("Recommendation response:", response); // Log the response or handle it as needed + if (ingredientNames !== "") { + const response = await dispatch( + recommendMeals({ + ingredients: ingredientNames, + lang: language, + token: availableUser?.token, + }) + ); + console.log("Recommendation response:", response); // Log the response or handle it as needed + } } catch (error) { console.error("Error fetching meals:", error); } diff --git a/wannameal/src/components/mealsSlider/mealsSlider.jsx b/wannameal/src/components/mealsSlider/mealsSlider.jsx index eeeec96..79653db 100644 --- a/wannameal/src/components/mealsSlider/mealsSlider.jsx +++ b/wannameal/src/components/mealsSlider/mealsSlider.jsx @@ -24,6 +24,7 @@ import { getRecommendMeals, } from "../../redux/slices/recomendedMealsSlice"; import Loading from "../loading/loading"; +import CommonMeals from "../commonMeals/commonMeals"; function MealsSlider() { const recomendedMeals = useSelector(getRecommendMeals); @@ -33,6 +34,9 @@ function MealsSlider() { const error = useSelector(getMealsError); console.log("🚀 ~ MealsSlider ~ error:", error); + if (recomendedMeals && recomendedMeals.length == 0) { + return ; + } if (mealsStatus == "loading") return (
@@ -74,12 +78,13 @@ function MealsSlider() { spaceBetween: 40, }, }} + style={{ direction: "ltr" }} > - {/* {recomendedMeals?.map((meal, index) => ( + {recomendedMeals?.map((meal, index) => ( - ))} */} + ))}
); diff --git a/wannameal/src/components/postContent/postContent.module.css b/wannameal/src/components/postContent/postContent.module.css index 98a12fa..9b203ca 100644 --- a/wannameal/src/components/postContent/postContent.module.css +++ b/wannameal/src/components/postContent/postContent.module.css @@ -16,12 +16,13 @@ object-fit: cover; } -.userInfo { +.userInfo .text { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; letter-spacing: -1px; + margin-left: 8px; } .userInfo .name { font-weight: 600; @@ -29,8 +30,8 @@ } .userInfo .email { color: var(--grayWritingColor); - font-size: 14px; - transform: scale(0.8) translate(-5px, -8px); + font-size: 12px; + /* transform: scale(0.8); */ } .postText { diff --git a/wannameal/src/components/savedMeals/SavedMeals.jsx b/wannameal/src/components/savedMeals/SavedMeals.jsx index c4d38f5..ec9ee3c 100644 --- a/wannameal/src/components/savedMeals/SavedMeals.jsx +++ b/wannameal/src/components/savedMeals/SavedMeals.jsx @@ -51,27 +51,33 @@ export default function SavedMeals() { ); return ( - <> -
- {savedMeals && savedMeals.length > 0 ? ( - savedMeals.map((meal) => { - return ; - }) - ) : ( -
-
- +
+
+
+ {savedMeals && savedMeals.length > 0 ? ( + savedMeals.map((meal) => ( +
+ +
+ )) + ) : ( +
+
+ +
+

+ There are no recipes saved yet. +

+

+ Save the recipes you like to try later and you will find them + saved here.{" "} +

-

There are no recipes saved yet.

-

- Save the recipes you like to try later and you will find them - saved here.{" "} -

-
- )} + )} +
- +
); } diff --git a/wannameal/src/components/savedMeals/savedMeals.module.css b/wannameal/src/components/savedMeals/savedMeals.module.css index 15f5041..98d4c06 100644 --- a/wannameal/src/components/savedMeals/savedMeals.module.css +++ b/wannameal/src/components/savedMeals/savedMeals.module.css @@ -1,7 +1,8 @@ .recipsContainer { display: grid; - grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); - gap: 30px; + grid-template-columns: repeat(auto-fill, minmax(370px, 1fr)); + justify-content: space-between; + gap: 10px; } .noMealscontainer { @@ -11,7 +12,7 @@ flex-direction: column; gap: 10px; align-items: center; - justify-content: center; + justify-content: space-around; } .noMealscontainer .imageContainer { diff --git a/wannameal/src/pages/community/comunity.jsx b/wannameal/src/pages/community/comunity.jsx index a801786..3741f7c 100644 --- a/wannameal/src/pages/community/comunity.jsx +++ b/wannameal/src/pages/community/comunity.jsx @@ -222,8 +222,8 @@ export default function Community() { try { dispatch( getProfileById({ - userId: decodedToken.id, - token: availableUser.token, + userId: decodedToken?.id, + token: availableUser?.token, lang: language, }) ); diff --git a/wannameal/src/pages/contact/contact.jsx b/wannameal/src/pages/contact/contact.jsx index a485d01..e2324ef 100644 --- a/wannameal/src/pages/contact/contact.jsx +++ b/wannameal/src/pages/contact/contact.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import styles from "./contactUS.module.css"; import { MdOutlineLocationOn } from "react-icons/md"; import { FiPhone } from "react-icons/fi"; @@ -8,9 +8,65 @@ import { FaXTwitter } from "react-icons/fa6"; import { TiSocialLinkedin } from "react-icons/ti"; import "animate.css"; import { useTranslation } from "react-i18next"; +import axios from "axios"; +import Swal from "sweetalert2"; + function ContactUs() { - const { t } = useTranslation() - const { head, fname, Email, msg, send, location, phone, mail } = t('contact') + const { t } = useTranslation(); + const { head, fname, Email, msg, send, location, phone, mail } = t("contact"); + + const [formData, setFormData] = useState({ + name: "", + email: "", + message: "", + }); + + console.log("🚀 ~ ContactUs ~ formData:", formData); + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ + ...formData, + [name]: value, + }); + }; + + const handleSubmit = async (e) => { + e.preventDefault(); + try { + const response = await axios.post( + "https://fast-plat1.vercel.app/contactus", + formData + ); + console.log("🚀 ~ handleSubmit ~ response:", response); + Swal.fire({ + icon: "success", + title: response?.data?.message, + toast: true, + position: "top-end", + showConfirmButton: false, + timer: 3000, + timerProgressBar: true, + }); + + setFormData({ + name: "", + email: "", + message: "", + }); + } catch (error) { + console.error("Failed to send contact: ", error); + Swal.fire({ + icon: "error", + title: "Failed to send", + toast: true, + position: "top-end", + showConfirmButton: false, + timer: 2000, + timerProgressBar: true, + }); + } + }; + return (
-
+
@@ -39,6 +98,9 @@ function ContactUs() { className={`form-control ${styles.input}`} id="exampleFormControlInput1" placeholder={Email} + value={formData.email} + onChange={handleChange} + required />
@@ -48,33 +110,14 @@ function ContactUs() { placeholder={msg} id="exampleFormControlTextarea1" rows={3} - defaultValue={""} + value={formData.message} + onChange={handleChange} + required />
- -
{send}
- {/* {message &&
{message}
} */} - {/* {!isLoading ? ( -
- send message -
- ) : ( -
-
- Loading... -
-
- )} */} +
diff --git a/wannameal/src/pages/profile.rar b/wannameal/src/pages/profile.rar deleted file mode 100644 index d8253a8..0000000 Binary files a/wannameal/src/pages/profile.rar and /dev/null differ diff --git a/wannameal/src/pages/profile/edit/editProfile.jsx b/wannameal/src/pages/profile/edit/editProfile.jsx index 24e49a6..742b859 100644 --- a/wannameal/src/pages/profile/edit/editProfile.jsx +++ b/wannameal/src/pages/profile/edit/editProfile.jsx @@ -229,7 +229,7 @@ function EditProfile() { } }; - let handleDeleteAccount = () => { + const handleDeleteAccount = async () => { Swal.fire({ title: "Are you sure?", text: "You won't be able to revert this!", @@ -241,33 +241,58 @@ function EditProfile() { }).then(async (result) => { if (result.isConfirmed) { let timerInterval; - await dispatch( - deleteAccount({ - userId: decodedToken.id, - token: availableUser.token, - }) - ); - Swal.fire({ - title: "Deleting Account!", - html: "Your Account will be Deleted in second.", - timer: 5000, - timerProgressBar: true, - didOpen: () => { - Swal.showLoading(); - const timer = Swal.getPopup().querySelector("b"); - timerInterval = setInterval(() => { - timer.textContent = `${parseInt(Swal.getTimerLeft() / 1000)}`; - }, 1000); - }, - willClose: () => { - clearInterval(timerInterval); - }, - }).then((result) => { - if (result.dismiss === Swal.DismissReason.timer) { - dispatch(logout()); + try { + await dispatch( + deleteAccount({ + userId: decodedToken.id, + token: availableUser.token, + }) + ); + + if (userError) { + Swal.fire({ + icon: "error", + title: `${userError?.msgError}`, + toast: true, + position: "top-end", + showConfirmButton: false, + timer: 2000, + timerProgressBar: true, + }); + } else { + Swal.fire({ + title: "Deleting Account!", + html: "Your Account will be Deleted in second.", + timer: 5000, + timerProgressBar: true, + didOpen: () => { + Swal.showLoading(); + const timer = Swal.getPopup().querySelector("b"); + timerInterval = setInterval(() => { + timer.textContent = `${parseInt(Swal.getTimerLeft() / 1000)}`; + }, 1000); + }, + willClose: () => { + clearInterval(timerInterval); + }, + }).then((result) => { + if (result.dismiss === Swal.DismissReason.timer) { + dispatch(logout()); + } + }); } - }); + } catch (error) { + Swal.fire({ + icon: "error", + title: `${userError?.msgError || "Failed to delete account"}`, + toast: true, + position: "top-end", + showConfirmButton: false, + timer: 2000, + timerProgressBar: true, + }); + } } }); }; diff --git a/wannameal/src/redux/slices/recomendedMealsSlice.jsx b/wannameal/src/redux/slices/recomendedMealsSlice.jsx index 5551a03..48957ae 100644 --- a/wannameal/src/redux/slices/recomendedMealsSlice.jsx +++ b/wannameal/src/redux/slices/recomendedMealsSlice.jsx @@ -14,7 +14,7 @@ const initialState = { export const recommendMeals = createAsyncThunk( "meals/recommendMeals", - async ({ ingredients, lang }, { rejectWithValue }) => { + async ({ ingredients, lang, token }, { rejectWithValue }) => { try { console.log("Sending request to API with params:", { lang: lang, @@ -22,15 +22,15 @@ export const recommendMeals = createAsyncThunk( }); const response = await axios.get( - `https://tesst11.azurewebsites.net/meals/recommendMeal?lang=${lang}`, - { ingredients }, + `https://tesst11.azurewebsites.net/meals/recommendMeal?lang=${lang}&ingredients=${ingredients}`, { headers: { "Content-Type": "application/json", + token: token, }, } ); - return response; + return response.data.Recommendation; } catch (error) { return rejectWithValue(error.message); }