From 5b06bfb94327b79f349717a8645a188d69dcf2a5 Mon Sep 17 00:00:00 2001 From: Hossein Rahmani Date: Thu, 25 Jan 2024 20:39:25 +0330 Subject: [PATCH] News added + Bugs fixed --- app/News/[newsId]/page.tsx | 7 ++ app/components/Landing.tsx | 158 ++++++++++++++---------- app/globals.css | 4 +- components/AboutUs.tsx | 6 - components/FollowResult.tsx | 12 +- components/Footer.tsx | 30 +++-- components/InspectorOperations.tsx | 6 +- components/News.tsx | 187 ++++++++++------------------- components/NewsDetail.tsx | 71 +++++++++++ components/Profile.tsx | 49 +++++--- components/SubmitRequest.tsx | 2 +- utils/commonApi.ts | 14 +-- 12 files changed, 307 insertions(+), 239 deletions(-) create mode 100644 app/News/[newsId]/page.tsx create mode 100644 components/NewsDetail.tsx diff --git a/app/News/[newsId]/page.tsx b/app/News/[newsId]/page.tsx new file mode 100644 index 0000000..faa3cda --- /dev/null +++ b/app/News/[newsId]/page.tsx @@ -0,0 +1,7 @@ +import NewsDetail from "@/components/NewsDetail"; +import React from "react"; + +export default function page({ params }: { params: any }) { + const id = params.newsId; + return ; +} diff --git a/app/components/Landing.tsx b/app/components/Landing.tsx index 1076756..e15d680 100644 --- a/app/components/Landing.tsx +++ b/app/components/Landing.tsx @@ -5,7 +5,7 @@ import Counter from "../../components/Counter"; import SubmitRequest from "../../components/SubmitRequest"; import { boxItems, newsItems } from "@/constants"; import Image from "next/image"; -import { cn } from "@/lib/utils"; +import { cn, convertDate } from "@/lib/utils"; import Link from "next/link"; import bgimg from "../../public/img/bg-slide.jpg"; import Footer from "@/components/Footer"; @@ -19,7 +19,27 @@ import "swiper/css/pagination"; import { Autoplay, Pagination, Navigation } from "swiper/modules"; import { sliderItems } from "@/constants"; import { useQuery } from "@tanstack/react-query"; -import { getSliders , getNews} from "@/utils/commonApi"; +import { getSliders, getNews } from "@/utils/commonApi"; + +interface News { + id: string; + image: { + id: string; + url: string; + url2: string; + url3: string; + url4: string; + alternateText: string; + title: string; + mediaType: 0; + }; + title: string; + description: string; + dateTime: string; + url: string; + content: string; + isDeleted: boolean; +} export default function Landing() { const { data, isLoading, refetch } = useQuery({ @@ -29,12 +49,18 @@ export default function Landing() { }); console.log(data); - const { data:NewsData, isLoading:NewsisLoading, isError:NewsisError, refetch:Newsrefetch } = useQuery({ + const { + data: NewsData, + isLoading: NewsIsLoading, + isError: NewsIsError, + refetch: NewsRefetch, + } = useQuery({ queryKey: ["News"], queryFn: () => getNews(), refetchOnWindowFocus: false, }); - console.log("NewsData"+ NewsData); + + return (
@@ -127,7 +153,7 @@ export default function Landing() { } }} > -

+

{item.description}

@@ -165,75 +191,79 @@ export default function Landing() {

آخرین اخبار
-
+
{/* Right News */} -
-
- picture -
- -
-

- اخبار -

-

- 24 آذر ماه 1402 -

-

- شروع به کار سامانه عیون -

-

- این سامانه با هدف نظارت بر عملکرد پرسنل و نهادهای مرتبط با امور - مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده - است ... -

- - بیشتر بخوانید{" "} - -
-
- {/* Left News */} -
- {newsItems.map((item, index) => { - return ( -
-
-

- {item.title} +

+ picture +
+ +
+
+

+ اخبار

-

- {item.date} +

+ {convertDate(NewsData[0]?.dataTime)} +

+

+ {NewsData[0]?.title} +

+

+ {NewsData[0]?.description ? NewsData[0]?.description : ""}

-

- {item.content} -

+ + بیشتر بخوانید{" "} +
- ); - })} -
+
+ {/* Left News */} +
+ {NewsData.slice(1, 4).map((item: News, index: number) => { + return ( +
+
+

+ {item.title} +

+

+ {convertDate(item.dateTime)} +

+
+

+ {item?.description} +

+
+ ); + })} +
+ + )}
{/* Counter */} - + {/* */} {/*SubmitRequest */} {/* Footer */} diff --git a/app/globals.css b/app/globals.css index 94b427c..a0b8850 100644 --- a/app/globals.css +++ b/app/globals.css @@ -101,4 +101,6 @@ border: 2px solid black; } - +.footer span{ + color: white !important; +} \ No newline at end of file diff --git a/components/AboutUs.tsx b/components/AboutUs.tsx index 95cd90e..6f81b10 100644 --- a/components/AboutUs.tsx +++ b/components/AboutUs.tsx @@ -18,12 +18,6 @@ export default function AboutUs() { refetch(); }, [title, refetch]); - if (isLoading) { - return

Loading...

; - } - if (isError) { - return

Error fetching content.

; - } const fetchedContent = data?.content || ""; // Assuming your API response has a 'content' property diff --git a/components/FollowResult.tsx b/components/FollowResult.tsx index cc45bb8..181d323 100644 --- a/components/FollowResult.tsx +++ b/components/FollowResult.tsx @@ -26,6 +26,7 @@ import { useReactToPrint } from "react-to-print"; import "../app/print-styles.css"; import ComplainsDetails from "./ComplainsDetails"; import { toast } from "sonner"; +import { ArrowRight } from "lucide-react"; export default function FollowResult() { const router = useRouter(); @@ -88,9 +89,18 @@ export default function FollowResult() { console.log(complaintPrintMutation?.data); return ( <> -
+
{complaintPrintMutation?.data ? ( <> + {/*
diff --git a/components/Footer.tsx b/components/Footer.tsx index 6f9cb65..aa232ab 100644 --- a/components/Footer.tsx +++ b/components/Footer.tsx @@ -5,32 +5,37 @@ import img2 from "../public/img/footerImg2.png"; import { footerItems } from "@/constants"; import { aboutFooterItems } from "@/constants"; import Link from "next/link"; +import { getSingleWebContents } from "@/utils/commonApi"; +import { useQuery } from "@tanstack/react-query"; export default function Footer() { + const { data, isLoading, isError } = useQuery({ + queryKey: ["WebContents", "AboutUs"], + queryFn: () => getSingleWebContents("AboutUs"), + refetchOnWindowFocus: false, + }); + const fetchedContent = data?.content || ""; + console.log(data); return ( //