diff --git a/public/locales/ar/homepage.json b/public/locales/ar/homepage.json index 8edbcf7..c723ec2 100644 --- a/public/locales/ar/homepage.json +++ b/public/locales/ar/homepage.json @@ -20,7 +20,8 @@ "chatText": "تحتاج إلى التحدث مع شخص ما؟ يمكنك التحدث مع المعالج الخاص بك" }, "blogs": { - "heading": "المدونات" + "heading": "المدوّنات", + "more": "اقرأ المزيد" }, "tickets": { "heading1": "خيارات الشراء لدينا", diff --git a/public/locales/en/homepage.json b/public/locales/en/homepage.json index 1b7b877..b590f28 100644 --- a/public/locales/en/homepage.json +++ b/public/locales/en/homepage.json @@ -20,7 +20,8 @@ "chatText": "Need to talk? Let your therapist listen." }, "blogs": { - "heading": "RECENT BLOGS" + "heading": "RECENT BLOGS", + "more": "Read more" }, "tickets": { "heading1": "OUR PLAN OPTIONS", diff --git a/src/components/Cards/BlogCard.jsx b/src/components/Cards/BlogCard.jsx index 42914be..4b6d1ae 100644 --- a/src/components/Cards/BlogCard.jsx +++ b/src/components/Cards/BlogCard.jsx @@ -1,13 +1,17 @@ -import Link from "next/link"; import Image from "next/image"; - +import Link from "next/link"; +import { useRouter } from "next/router"; +import { useTranslation } from "next-i18next"; const Card = ({ title, text, imgSrc, url }) => { + const { t } = useTranslation("homepage"); + const router = useRouter(); + return ( -
-
+
+
-
+
{title}
@@ -17,8 +21,7 @@ const Card = ({ title, text, imgSrc, url }) => { href={url} className='underline flex justify-end mr-5 mt-2 text-teal-100 hover:text-teal-400 group-hover:animate-bounce text-base' > - {" "} - Read more + {t("blogs.more")}
diff --git a/src/components/Cards/__test__/__snapshots__/BlogCard.test.js.snap b/src/components/Cards/__test__/__snapshots__/BlogCard.test.js.snap index ffce470..d49bc53 100644 --- a/src/components/Cards/__test__/__snapshots__/BlogCard.test.js.snap +++ b/src/components/Cards/__test__/__snapshots__/BlogCard.test.js.snap @@ -2,17 +2,17 @@ exports[`renders correctly 1`] = `
- - Read more + blogs.more
diff --git a/src/components/Home/HomePageWrapper.jsx b/src/components/Home/HomePageWrapper.jsx index 36bcc60..cbd1df3 100644 --- a/src/components/Home/HomePageWrapper.jsx +++ b/src/components/Home/HomePageWrapper.jsx @@ -4,13 +4,13 @@ import HeroSection from "@/components/Home/HeroSection"; import RecentBlogsSection from "@/components/Home/RecentBlogsSection"; import TicketsSection from "@/components/Home/TicketsSection"; -const HomePageWrapper = () => { +const HomePageWrapper = ({ posts }) => { return ( <> - + ); diff --git a/src/components/Home/RecentBlogsSection.jsx b/src/components/Home/RecentBlogsSection.jsx index d480080..33f1cac 100644 --- a/src/components/Home/RecentBlogsSection.jsx +++ b/src/components/Home/RecentBlogsSection.jsx @@ -1,47 +1,15 @@ +import { useTranslation } from "next-i18next"; import Slider from "react-slick"; import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; import Card from "../Cards/BlogCard"; - -import { useTranslation } from "next-i18next"; import Reveal from "../utils/Reveal"; +import { urlForImage } from "../../../sanity/lib/image"; -const RecentBlogsSection = () => { +const RecentBlogsSection = ({ posts }) => { const { t } = useTranslation("homepage"); - const blogs = [ - { - title: "Mental Health and technology", - body: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem", - url: "", - blogImg: "/Images/blog-img-placeholder.svg", - }, - { - title: "Mental Health and technology", - body: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem", - url: "", - blogImg: "/Images/blog-img-placeholder.svg", - }, - { - title: "Mental Health and technology", - body: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem", - url: "", - blogImg: "/Images/blog-img-placeholder.svg", - }, - { - title: "Mental Health and technology", - body: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem", - url: "", - blogImg: "/Images/blog-img-placeholder.svg", - }, - { - title: "Mental Health and technology", - body: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem", - url: "", - blogImg: "/Images/blog-img-placeholder.svg", - }, - ]; const settings = { dots: true, @@ -65,7 +33,7 @@ const RecentBlogsSection = () => { }, }, { - breakpoint: 600, + breakpoint: 820, settings: { slidesToShow: 2, slidesToScroll: 2, @@ -82,21 +50,24 @@ const RecentBlogsSection = () => { ], }; return ( -
+
-

+

{t("blogs.heading")}

- - - {blogs.map((blog, index) => ( + + + {posts?.map((post) => ( ))} diff --git a/src/components/Home/__test__/RecentBlogsSection.test.js b/src/components/Home/__test__/RecentBlogsSection.test.js index a23bce0..22993d6 100644 --- a/src/components/Home/__test__/RecentBlogsSection.test.js +++ b/src/components/Home/__test__/RecentBlogsSection.test.js @@ -1,4 +1,5 @@ import renderer from "react-test-renderer"; + import TicketsSection from "@/components/Home/TicketsSection"; it("renders correctly", () => { diff --git a/src/components/Home/__test__/__snapshots__/HomePageWrapper.test.js.snap b/src/components/Home/__test__/__snapshots__/HomePageWrapper.test.js.snap index 13fc0fd..2be40c8 100644 --- a/src/components/Home/__test__/__snapshots__/HomePageWrapper.test.js.snap +++ b/src/components/Home/__test__/__snapshots__/HomePageWrapper.test.js.snap @@ -1190,7 +1190,7 @@ Array [
,

blogs.heading

@@ -1232,36 +1232,10 @@ Array [ } >
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
-
-
-
-
-
-
- Mental Health and technology -
-
-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem -

- - - Read more - -
-
-
-
- Mental Health and technology -
-
-
-
+ />
- -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index 86b146c..1373641 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,19 +1,21 @@ -import Link from "next/link"; +import { motion, useMotionValueEvent, useScroll } from "framer-motion"; import Image from "next/image"; -import { useEffect, useState } from "react"; -import { useTranslation } from "next-i18next"; +import Link from "next/link"; import { useRouter } from "next/router"; -import { UserAuth } from "@/context/AuthContext"; -import { TbUserCircle } from "react-icons/tb"; +import { useTranslation } from "next-i18next"; +import { useEffect, useState } from "react"; +import { HiMenu } from "react-icons/hi"; import { IoLanguage } from "react-icons/io5"; -import UserDropdown from "./dropdowns/UserDropdown"; -import AboutDropdown from "./dropdowns/AboutDropdown"; import { MdArrowDropDown } from "react-icons/md"; -import LangDropdown from "./dropdowns/LangDropdown"; -import { HiMenu } from "react-icons/hi"; import { MdOutlineClose } from "react-icons/md"; +import { TbUserCircle } from "react-icons/tb"; + +import { UserAuth } from "@/context/AuthContext"; + +import AboutDropdown from "./dropdowns/AboutDropdown"; +import LangDropdown from "./dropdowns/LangDropdown"; +import UserDropdown from "./dropdowns/UserDropdown"; import Button from "../elements/Button"; -import { motion, useScroll, useMotionValueEvent } from "framer-motion"; export default function Navbar() { const router = useRouter(); @@ -53,108 +55,24 @@ export default function Navbar() { }} animate={hidden ? "hidden" : "visible"} transition={{ duration: 0.35, ease: "easeInOut" }} - className='sticky bg-white top-0 z-50 md:h-20 md:pt-4 p-0 md:px-12 border-b' + className='z-50 sticky top-0 bg-white ' > -
-
-
- {/* LOGO */} - - logo - -
- {!user ? ( -
- -
- ) : ( -
-
- -
-
- {isDropdownOpen && } -
-
- )} - -
-
-
-
-
-
    -
  • - setNavbar(!navbar)} - > - {t("navbar.home")} - -
  • -
  • - setNavbar(!navbar)} - > - {t("navbar.blogs")} - -
  • -
  • -
    - - -
    - -
    -
    -
  • -
  • - setNavbar(!navbar)} - > - {t("navbar.contact")} - -
  • - {!user ? ( -
  • -
    +
    +
    +
    +
    + {/* LOGO */} + + logo + +
    + {!user ? ( +
    + ) : ( +
    +
    + +
    +
    + {isDropdownOpen && } +
    +
    + )} + +
    +
    +
    +
    +
    +
      +
    • + setNavbar(!navbar)} + > + {t("navbar.home")} +
    • - ) : ( -
      -
      + setNavbar(!navbar)} > - + {t("navbar.blogs")} + + +
    • +
      + + +
      + +
      -
      - {isDropdownOpen && } +
    • +
    • + setNavbar(!navbar)} + > + {t("navbar.contact")} + +
    • + {!user ? ( +
    • +
      + +
      +
    • + ) : ( +
      +
      + +
      +
      + {isDropdownOpen && } +
      -
      - )} -
    • -
      - + )} +
    • +
      + -
      - +
      + +
      -
      -
    • -
    • -
      - +
    • +
    • +
      + -
      - +
      + +
      -
      -
    • -
    +
  • +
+
diff --git a/src/components/Navbar/__test__/__snapshots__/Navbar.test.js.snap b/src/components/Navbar/__test__/__snapshots__/Navbar.test.js.snap index 523e7d3..535bd13 100644 --- a/src/components/Navbar/__test__/__snapshots__/Navbar.test.js.snap +++ b/src/components/Navbar/__test__/__snapshots__/Navbar.test.js.snap @@ -2,164 +2,62 @@ exports[`renders correctly 1`] = `
- - + + +
diff --git a/src/components/ProfileImage.jsx b/src/components/ProfileImage.jsx index a008911..6b503bc 100644 --- a/src/components/ProfileImage.jsx +++ b/src/components/ProfileImage.jsx @@ -47,11 +47,9 @@ const ProfileImage = () => { src={ uploading ? Spinner - : localStorage.getItem( - `therapist_image_${user.uid}` - ) || - user.photoURL || - ProfileImage || + : localStorage.getItem(`profile_${user.uid}`) ?? + user.photoURL ?? + ProfileImage ?? Profile } alt='profile preview' diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 5beebee..0e28cd1 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,25 +1,35 @@ import { useTranslation } from "next-i18next"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import { groq } from "next-sanity"; import * as React from "react"; import HomePageWrapper from "@/components/Home/HomePageWrapper"; import Layout from "@/layout/Layout"; -export default function HomePage() { +import { client } from "../../sanity/lib/client"; + +export default function HomePage({ posts }) { const { t } = useTranslation("common"); return ( - + ); } export async function getStaticProps({ locale }) { + const query = groq`*[_type == "post" && language == $locale]{ + ..., + author->, + categories[]-> + | order(created_At desc)}[0..9]`; + const posts = await client.fetch(query, { locale: locale }); return { props: { ...(await serverSideTranslations(locale, ["common", "homepage"])), + posts, }, }; }