From 35ca38f36ba5ace33511bfbfc928a7bb3f9f034b Mon Sep 17 00:00:00 2001 From: Rama Aldakkak Date: Fri, 19 Aug 2022 16:49:53 +0300 Subject: [PATCH 01/11] fix: added some classes to navbar, conatc us, and footer re #88 --- src/components/ContactUs/ContactUs.css | 12 -- src/components/ContactUs/ContactUs.jsx | 92 ++++-------- .../__snapshots__/ContactUs.test.jsx.snap | 142 ------------------ src/components/layout/Footer/Footer.jsx | 1 - src/components/layout/Navbar/Navbar.jsx | 10 +- .../Navbar/__snapshots__/Navbar.test.jsx.snap | 12 +- 6 files changed, 38 insertions(+), 231 deletions(-) delete mode 100644 src/components/ContactUs/ContactUs.css delete mode 100644 src/components/ContactUs/__snapshots__/ContactUs.test.jsx.snap diff --git a/src/components/ContactUs/ContactUs.css b/src/components/ContactUs/ContactUs.css deleted file mode 100644 index 50f479c..0000000 --- a/src/components/ContactUs/ContactUs.css +++ /dev/null @@ -1,12 +0,0 @@ -@media only screen and (max-width: 600px) { - .ContactUs .contactInfo { - font-size: 13px; - margin-left: 30px; - max-width: 400px; - } - .FormTextContactUs{ - max-width: 290px; - } - - -} \ No newline at end of file diff --git a/src/components/ContactUs/ContactUs.jsx b/src/components/ContactUs/ContactUs.jsx index 827134b..7e0d0c9 100644 --- a/src/components/ContactUs/ContactUs.jsx +++ b/src/components/ContactUs/ContactUs.jsx @@ -2,7 +2,6 @@ import { React, useState } from "react"; import Phone from "../../assets/phone.svg"; import Message from "../../assets/email.svg"; import Location from "../../assets/location.svg"; -import "./ContactUs.css"; import { useMutation } from "@tanstack/react-query"; function ContactUs() { @@ -11,14 +10,14 @@ function ContactUs() { email: "", Message: "", }); - + function handleChange(event) { const name = event.target.name; let value = event.target.value; - + setFormData({ ...formData, [name]: value }); } - + function handleSubmit(event) { event.preventDefault(); } @@ -33,24 +32,17 @@ function ContactUs() { }); }); return ( -
-
-
-
+
+

Contact Us

Get the understanding you need to channel the books of spells you have always been @@ -58,32 +50,32 @@ function ContactUs() { rabbits love to steal! Get the understanding you need to

-
-
+
+
Location icon -

+

9094 Bay Meadows Street Conyers, GA 30012

-
+
Phone icon -

+

+229-955-5388-336

-

+

+229-955-5373-360

-
+
Contact icon -

+

support@mail.com

-

+

office@mail.com

@@ -91,18 +83,16 @@ function ContactUs() {
-
+
-
-
+
@@ -113,23 +103,14 @@ function ContactUs() { type='text' onChange={handleChange} value={formData.Fullname} - className='FormTextContactUs h-10 rounded border focus:border focus:border-indigo-700' - style={{ - backgroundColor: "#DDDDDD", - borderWidth: 0, - width: "580px", - }} + className="focus:border focus:border-blue-dark rounded border-none bg-gray mb-6" placeholder='Full Name' />
-
-
-
@@ -140,47 +121,30 @@ function ContactUs() { type='email' onChange={handleChange} value={formData.email} - className='FormTextContactUs h-10 rounded border focus:border focus:border-indigo-700' - style={{ - backgroundColor: "#DDDDDD", - borderWidth: 0, - width: "580px", - }} + className="focus:border focus:border-blue-dark rounded border-none bg-gray mb-6" placeholder='example@email.com' />
-
-
+
+
+ + {/* END OF FORM */} +
+ {/*footer of the form*/} +
+ + +
+
+
+
+
+ + ) : null} + + ); +} +export default EditInfoForm; diff --git a/src/components/NgoProfilePageHeroSection/NgoProfilePageHeroSection.jsx b/src/components/NgoProfilePageHeroSection/NgoProfilePageHeroSection.jsx index c7a300c..f36b0d7 100644 --- a/src/components/NgoProfilePageHeroSection/NgoProfilePageHeroSection.jsx +++ b/src/components/NgoProfilePageHeroSection/NgoProfilePageHeroSection.jsx @@ -1,94 +1,79 @@ import React, { useState } from "react"; import "../../App.css"; import NGOImage from "../../assets/NGOImage.png"; -import EditInfoForm from "../EditInfoForm/EditInfoForm"; -import Axios from "axios"; +import EditInfoForm from "./EditInfoForm"; +import { useQuery } from "@tanstack/react-query"; import SubmitConfirm from "../AdminDashboardHeroSection/SubmitConfirm"; function NgoProfilePageHeroSection() { const [info, setInfo] = useState([]); //changed {} to [] - const [updated, setUpdated] = useState(false); - - function handleChange(e) { - setInfo({ ...info, [e.target.name]: e.target.value }); - } - - function dataSender(e) { - Axios.put("http://localhost:8000/adminDashboard/1", info).then( - (response) => { - // console.log(response.data) - setInfo(() => response.data); - // console.log('info after dataSender',info) - setUpdated(true); - setTimeout(() => setUpdated(false), 2000); - } - ); - } + const { isLoading, error, data } = useQuery(["repoData"], () => + fetch("http://localhost:8000/adminDashboard/1").then((res) => + res.json().then((data) => setInfo(data)) + ) + ); + // if (isLoading) return "Loading..."; - React.useEffect(() => { - Axios.get("http://localhost:8000/adminDashboard/1") - .then((res) => { - setInfo(res.data); - // console.log('info after useEffect', info) - }) - .catch((err) => { - console.log("err", err); - }); - }, []); + // if (error) return error.messag; return ( <>
-
- +
+ - {updated ? : null} - -
-
+
+
+

+ {info.name} +

+ {/* {" "} */}
-
+
    -

    - Name: {info.name} +

    + Profile :

    -
  • Location: {info.location}
  • -
  • Date: {info.date}
  • -
  • Email: {info.email}
  • +
  • Date: {info.date}
  • +
  • Email: {info.email}
  • Website: {info.website}
  • -
  • Phone: {info.phone}
  • +
  • Phone: +{info.phone}
  • -

    - About Us : -

    -

    - {info.message} -

    -
+ +
+
+

+ About Us : +

+

+ {info.message} +

); } - export default NgoProfilePageHeroSection; diff --git a/src/components/layout/Footer/Footer.jsx b/src/components/layout/Footer/Footer.jsx index 5ffd01c..e11ebf5 100644 --- a/src/components/layout/Footer/Footer.jsx +++ b/src/components/layout/Footer/Footer.jsx @@ -6,7 +6,7 @@ import instagram from "../../../assets/instagram.png"; import facebook from "../../../assets/facebook.png"; import youtube from "../../../assets/youtube.png"; import PostRequestFunction from "./PostRequestFunction"; -import isValidEmail from "../../../services/ValidationFunctions"; +import { isValidEmail } from "../../../services/ValidationFunctions"; export default function Footer() { const [subscriptionData, setSubscriptionData] = useState(""); diff --git a/src/services/ValidationFunctions.jsx b/src/services/ValidationFunctions.jsx index c5785b8..536fe71 100644 --- a/src/services/ValidationFunctions.jsx +++ b/src/services/ValidationFunctions.jsx @@ -1,7 +1,18 @@ import React from "react"; function isValidEmail(email) { - return /\S+@\S+\.\S+/.test(email); + if (/\S+@\S+\.\S+/.test(email)) { + return true; + } else { + return false; + } +} +function wordsNumber(paragraph) { + if (paragraph.length > 500) { + return true; + } else { + return false; + } } -export default isValidEmail; +export { isValidEmail, wordsNumber }; diff --git a/src/services/postData.js b/src/services/postData.js new file mode 100644 index 0000000..336fe60 --- /dev/null +++ b/src/services/postData.js @@ -0,0 +1,24 @@ +/* eslint-disable no-console */ +import React from "react" +import { + useMutation, + QueryClient, + useQueryClient, +} from "@tanstack/react-query"; +import { wordsNumber, isValidEmail } from './ValidationFunctions' +import axios from "axios"; + +async function PostData(data) { + + + + if (wordsNumber(data.message) && isValidEmail(data.message)) { + + const response = await axios.patch('http://localhost:8000/adminDashboard/1', data); + } + else { + console.log('what') + } +} +export default PostData; + From 44ae0199909aaff76d8fa92805b77703cbe5e577 Mon Sep 17 00:00:00 2001 From: mustafa Rast Date: Sat, 20 Aug 2022 15:27:02 +0300 Subject: [PATCH 03/11] feat : Update Post Req --- data/db.json | 12 +- .../__snapshots__/ContactUs.test.jsx.snap | 142 ------------------ .../EditInfoForm.jsx | 29 ++-- .../NgoProfilePageHeroSection.jsx | 4 +- .../NgoProfilePageHeroSection.test.jsx | 15 -- .../NgoProfilePageHeroSection.test.jsx.snap | 83 ---------- src/components/OurValues/OurValues.jsx | 27 ++-- .../Navbar/__snapshots__/Navbar.test.jsx.snap | 12 +- src/index.js | 2 +- 9 files changed, 43 insertions(+), 283 deletions(-) delete mode 100644 src/components/ContactUs/__snapshots__/ContactUs.test.jsx.snap delete mode 100644 src/components/NgoProfilePageHeroSection/NgoProfilePageHeroSection.test.jsx delete mode 100644 src/components/NgoProfilePageHeroSection/__snapshots__/NgoProfilePageHeroSection.test.jsx.snap diff --git a/data/db.json b/data/db.json index a7f490b..2ae89f6 100644 --- a/data/db.json +++ b/data/db.json @@ -2,12 +2,12 @@ "adminDashboard": [ { "id": 1, - "website": "mustafa", - "name": "Mustafa Rastanawi", - "location": "wd", - "date": "10/12/1997", - "email": "mustafarastanaw@gmail.com", - "phone": "+53216121303", + "website": "www. Reach.com", + "name": "John Doe", + "location": "Istanbul", + "date": "10/12/1979", + "email": "mu@mail.com", + "phone": "53216121303", "message": "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.\n\n" } ], diff --git a/src/components/ContactUs/__snapshots__/ContactUs.test.jsx.snap b/src/components/ContactUs/__snapshots__/ContactUs.test.jsx.snap deleted file mode 100644 index 85f2a24..0000000 --- a/src/components/ContactUs/__snapshots__/ContactUs.test.jsx.snap +++ /dev/null @@ -1,142 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -
-
-
-
-

- Contact Us -

-

- Get the understanding you need to channel the books of spells you have always been smitten with, and boost sales which cartoon rabbits love to steal! Get the understanding you need to -

-
-
- Location icon -

- 9094 Bay Meadows Street Conyers, GA 30012 -

-
-
- Phone icon -

- +229-955-5388-336 -

-

- +229-955-5373-360 -

-
-
- Contact icon -

- support@mail.com -

-

- office@mail.com -

-
-
-
-
-
-
-
-
-
- - -
-
-
- - -
-
- -