News added + Bugs fixed

Kahdooei
Hossein Rahmani 2024-01-25 20:39:25 +03:30
parent 1e0ca5c229
commit 5b06bfb943
12 changed files with 307 additions and 239 deletions

View File

@ -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 <NewsDetail id={id} />;
}

View File

@ -5,7 +5,7 @@ import Counter from "../../components/Counter";
import SubmitRequest from "../../components/SubmitRequest"; import SubmitRequest from "../../components/SubmitRequest";
import { boxItems, newsItems } from "@/constants"; import { boxItems, newsItems } from "@/constants";
import Image from "next/image"; import Image from "next/image";
import { cn } from "@/lib/utils"; import { cn, convertDate } from "@/lib/utils";
import Link from "next/link"; import Link from "next/link";
import bgimg from "../../public/img/bg-slide.jpg"; import bgimg from "../../public/img/bg-slide.jpg";
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
@ -21,6 +21,26 @@ import { sliderItems } from "@/constants";
import { useQuery } from "@tanstack/react-query"; 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() { export default function Landing() {
const { data, isLoading, refetch } = useQuery({ const { data, isLoading, refetch } = useQuery({
queryKey: ["Sliders"], queryKey: ["Sliders"],
@ -29,12 +49,18 @@ export default function Landing() {
}); });
console.log(data); 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"], queryKey: ["News"],
queryFn: () => getNews(), queryFn: () => getNews(),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
console.log("NewsData"+ NewsData);
return ( return (
<div className="overflow-x-hidden max-md:-mt-8"> <div className="overflow-x-hidden max-md:-mt-8">
@ -127,7 +153,7 @@ export default function Landing() {
} }
}} }}
> >
<p className="text-xs text-center font-medium text-gray hidden group-hover:flex "> <p className="text-xs text-center font-medium text-gray hidden group-hover:flex group-hover:text-white">
{item.description} {item.description}
</p> </p>
<p className=" z-10 text-base text-black group-hover:text-white max-md:text-sm"> <p className=" z-10 text-base text-black group-hover:text-white max-md:text-sm">
@ -165,9 +191,11 @@ export default function Landing() {
<div className=" border mt-6 mx-auto py-3 px-4 rounded-lg"> <div className=" border mt-6 mx-auto py-3 px-4 rounded-lg">
آخرین اخبار آخرین اخبار
</div> </div>
<div <div className=" w-full mt-6 flex flex-row gap-8 mb-14 max-lg:flex-col max-lg:gap-4 ">
className=" w-full mt-6 flex flex-row gap-8 mb-14 max-lg:flex-col max-lg:gap-4 ">
{/* Right News */} {/* Right News */}
{NewsData && (
<>
{" "}
<div <div
className=" w-1/2 max-lg:w-full border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all className=" w-1/2 max-lg:w-full border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
max-lg:h-[14em] max-md:h-[12em] max-sm:h-[22em] max-sm:flex-col max-sm:gap-[3px]" max-lg:h-[14em] max-md:h-[12em] max-sm:h-[22em] max-sm:flex-col max-sm:gap-[3px]"
@ -175,7 +203,7 @@ export default function Landing() {
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full"> <div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
<Image <Image
alt="picture" alt="picture"
src="/img/pic1.png" src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${NewsData[0]?.image?.url}`}
height={500} height={500}
width={500} width={500}
quality={100} quality={100}
@ -184,20 +212,20 @@ export default function Landing() {
</div> </div>
<div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full"> <div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
<div className=" flex flex-col gap-2">
<p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded "> <p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded ">
اخبار اخبار
</p> </p>
<p className="text-xs font-medium text-right text-black"> <p className="text-xs font-medium text-right text-black">
24 آذر ماه 1402 {convertDate(NewsData[0]?.dataTime)}
</p> </p>
<p className="text-base font-medium text-right text-black line-clamp-1"> <p className="text-base font-medium text-right text-black line-clamp-1">
شروع به کار سامانه عیون {NewsData[0]?.title}
</p> </p>
<p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2"> <p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2">
این سامانه با هدف نظارت بر عملکرد پرسنل و نهادهای مرتبط با امور {NewsData[0]?.description ? NewsData[0]?.description : ""}
مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده
است ...
</p> </p>
</div>
<Link <Link
href="#" href="#"
className="text-[10px] font-normal text-blue text-left" className="text-[10px] font-normal text-blue text-left"
@ -208,7 +236,7 @@ export default function Landing() {
</div> </div>
{/* Left News */} {/* Left News */}
<div className=" w-1/2 max-lg:w-full flex flex-col gap-[2px] max-lg:gap-4"> <div className=" w-1/2 max-lg:w-full flex flex-col gap-[2px] max-lg:gap-4">
{newsItems.map((item, index) => { {NewsData.slice(1, 4).map((item: News, index: number) => {
return ( return (
<div <div
className=" w-full h-1/3 flex flex-col border rounded-lg justify-between px-8 py-[10px] hover:shadow-[0px_0px_8px_0px_#00000040] transition-all className=" w-full h-1/3 flex flex-col border rounded-lg justify-between px-8 py-[10px] hover:shadow-[0px_0px_8px_0px_#00000040] transition-all
@ -220,20 +248,22 @@ export default function Landing() {
{item.title} {item.title}
</p> </p>
<p className="text-xs font-medium text-right text-black max-sm:self-end"> <p className="text-xs font-medium text-right text-black max-sm:self-end">
{item.date} {convertDate(item.dateTime)}
</p> </p>
</div> </div>
<p className="text-sm font-normal text-justify text-[#3C3C43D9] max-md:line-clamp-2"> <p className="text-sm font-normal text-justify text-[#3C3C43D9] max-md:line-clamp-3 md:line-clamp-2">
{item.content} {item?.description}
</p> </p>
</div> </div>
); );
})} })}
</div> </div>
</>
)}
</div> </div>
</div> </div>
{/* Counter */} {/* Counter */}
<Counter /> {/* <Counter /> */}
{/*SubmitRequest */} {/*SubmitRequest */}
<SubmitRequest /> <SubmitRequest />
{/* Footer */} {/* Footer */}

View File

@ -101,4 +101,6 @@
border: 2px solid black; border: 2px solid black;
} }
.footer span{
color: white !important;
}

View File

@ -18,12 +18,6 @@ export default function AboutUs() {
refetch(); refetch();
}, [title, refetch]); }, [title, refetch]);
if (isLoading) {
return <p>Loading...</p>;
}
if (isError) {
return <p>Error fetching content.</p>;
}
const fetchedContent = data?.content || ""; // Assuming your API response has a 'content' property const fetchedContent = data?.content || ""; // Assuming your API response has a 'content' property

View File

@ -26,6 +26,7 @@ import { useReactToPrint } from "react-to-print";
import "../app/print-styles.css"; import "../app/print-styles.css";
import ComplainsDetails from "./ComplainsDetails"; import ComplainsDetails from "./ComplainsDetails";
import { toast } from "sonner"; import { toast } from "sonner";
import { ArrowRight } from "lucide-react";
export default function FollowResult() { export default function FollowResult() {
const router = useRouter(); const router = useRouter();
@ -88,9 +89,18 @@ export default function FollowResult() {
console.log(complaintPrintMutation?.data); console.log(complaintPrintMutation?.data);
return ( return (
<> <>
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] max-sm:mt-16 pt-12 mx-auto mb-10"> <div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] pt-6 mx-auto mb-10">
{complaintPrintMutation?.data ? ( {complaintPrintMutation?.data ? (
<> <>
<button
onClick={() => router.push("/FollowUp")}
className="flex gap-1 cursor-pointer text-blue"
>
<span>
<ArrowRight />
</span>
<p>بازگشت</p>
</button>
{/* <div className="flex justify-center gap-2 mb-2 sm:justify-end"> {/* <div className="flex justify-center gap-2 mb-2 sm:justify-end">
<AlertDialog> <AlertDialog>
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>

View File

@ -5,32 +5,37 @@ import img2 from "../public/img/footerImg2.png";
import { footerItems } from "@/constants"; import { footerItems } from "@/constants";
import { aboutFooterItems } from "@/constants"; import { aboutFooterItems } from "@/constants";
import Link from "next/link"; import Link from "next/link";
import { getSingleWebContents } from "@/utils/commonApi";
import { useQuery } from "@tanstack/react-query";
export default function Footer() { 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 ( return (
// <div classNameName="flex justify-center items-center w-full bg-blue "> // <div classNameName="flex justify-center items-center w-full bg-blue ">
<footer className="bg-blue dark:bg-gray-900"> <footer className="bg-blue dark:bg-gray-900">
<div className="mx-auto w-full max-w-screen-3xl px-4 py-7 md:px-8 md:py-8 lg:pt-14 lg:pb-7 lg:px-11 "> <div className="mx-auto w-full max-w-screen-3xl px-4 py-7 md:px-8 md:py-8 lg:pt-14 lg:pb-7 lg:px-11 ">
<div className="md:flex md:justify-between w-full "> <div className="md:flex md:justify-between w-full ">
<div className="grid gap-10 sm:gap-16 md:gap-20 lg:gap-28 grid-cols-1 w-full md:grid-cols-2 md:w-3/4 lg:w-2/4"> <div className="grid gap-10 sm:gap-16 md:gap-20 lg:gap-28 grid-cols-1 w-full">
<div> <div>
<h2 className="text-white text-sm sm:text-base font-bold mb-4 "> <h2 className="text-white text-sm sm:text-base font-bold mb-4 ">
درباره سامانه عیون درباره سامانه عیون
</h2> </h2>
{aboutFooterItems.map((item) => { <div>
return (
<div key={item.id}>
<p className=" text-white text-xs md:text-sm font-normal md:leading-7"> <p className=" text-white text-xs md:text-sm font-normal md:leading-7">
{item.name} <div className=" !text-white footer" dangerouslySetInnerHTML={{ __html: fetchedContent }} />
</p> </p>
</div> </div>
);
})}
</div> </div>
<div> {/* <div>
<h2 className="text-white text-sm sm:text-base font-bold mb-4"> <h2 className="text-white text-sm sm:text-base font-bold mb-4">
دسترسی سریع دسترسی سریع
</h2> </h2>
@ -45,7 +50,7 @@ export default function Footer() {
); );
})} })}
</ul> </ul>
</div> </div> */}
</div> </div>
{/* <div className=" max-md:mt-6 flex flex-row justify-center md:justify-end items-start w-full md:w-1/4 "> {/* <div className=" max-md:mt-6 flex flex-row justify-center md:justify-end items-start w-full md:w-1/4 ">
@ -70,7 +75,6 @@ export default function Footer() {
/> />
</div> </div>
</div> */} </div> */}
</div> </div>
<hr className=" border-gray-200 sm:mx-auto dark:border-gray-700 mt-5 sm:mt-10" /> <hr className=" border-gray-200 sm:mx-auto dark:border-gray-700 mt-5 sm:mt-10" />

View File

@ -99,11 +99,7 @@ export default function InspectorOperations({
formData.append("text", data.text); formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber); formData.append("trackingNumber", complaintData.trackingNumber);
formData.append("Operation", data.operation); formData.append("Operation", data.operation);
if (role == "Inspector") {
formData.append("EncodedKey", password);
} else {
formData.append("password", localStorage.getItem("password2") as string); formData.append("password", localStorage.getItem("password2") as string);
}
if (data?.media && data?.media?.length > 0) { if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) { for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]); formData.append("Medias", data.media[i]);

View File

@ -5,30 +5,43 @@ import { getNews } from "@/utils/commonApi";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import { convertFullTime } from "@/lib/utils";
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 News() { export default function News() {
const { data, isLoading, isError, refetch } = useQuery({ const { data, isLoading, isError, refetch } = useQuery({
queryKey: ["News"], queryKey: ["News"],
queryFn: () => getNews(), queryFn: () => getNews(),
refetchOnWindowFocus: false,
}); });
console.log(data); console.log(data);
if (isLoading) {
return <p>Loading...</p>;
}
if (isError) {
return <p>Error fetching content.</p>;
}
return ( return (
<div className="bg-white dark:bg-gray-900 w-screen pt-8"> <div className="bg-white dark:bg-gray-900 pt-8 container">
<div className="container w-full flex flex-wrap lg:flex-row gap-8 mb-14 flex-col max-lg:gap-4"> <h2 className=" w-full font-bold mb-2">اخبار</h2>
<div className="w-full flex flex-wrap lg:flex-row gap-8 mb-14 flex-col max-lg:gap-4">
{/* {data.map((item: any, index: number) => { {/* {data.map((item: any, index: number) => {
return <p key={index}>News</p>; return <p key={index}>News</p>;
})} */} })} */}
{data?.map((item: News) => {
return (
<div <div
className="w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all className="w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]" h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]"
@ -36,7 +49,7 @@ export default function News() {
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full"> <div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
<Image <Image
alt="picture" alt="picture"
src="/img/pic1.png" src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
height={500} height={500}
width={500} width={500}
quality={100} quality={100}
@ -45,106 +58,30 @@ export default function News() {
</div> </div>
<div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full"> <div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
<p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded "> {/* <p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded ">
اخبار اخبار
</p> </p> */}
<div className=" flex flex-col gap-1">
<p className="text-xs font-medium text-right text-black"> <p className="text-xs font-medium text-right text-black">
24 آذر ماه 1402 {convertFullTime(item.dateTime)}
</p> </p>
<p className="text-base font-medium text-right text-black line-clamp-1"> <p className="text-base font-medium text-right text-black line-clamp-1">
شروع به کار سامانه عیون {item.title}
</p> </p>
<p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2"> <p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2">
این سامانه با هدف نظارت بر عملکرد پرسنل و نهادهای مرتبط با امور {item?.description}
مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است
...
</p> </p>
</div>
<Link <Link
href="#" href={`News/${item.id}`}
className="text-[10px] font-normal text-blue text-left" className="text-[11px] font-normal text-blue text-left hover:underline"
>
بیشتر بخوانید{" "}
</Link>
</div>
</div>
<div
className="w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]"
>
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
<Image
alt="picture"
src="/img/pic1.png"
height={500}
width={500}
quality={100}
className="w-full h-full rounded-r-lg bg-cover object-cover object-center"
/>
</div>
<div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
<p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded ">
اخبار
</p>
<p className="text-xs font-medium text-right text-black">
24 آذر ماه 1402
</p>
<p className="text-base font-medium text-right text-black line-clamp-1">
شروع به کار سامانه عیون
</p>
<p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2">
این سامانه با هدف نظارت بر عملکرد پرسنل و نهادهای مرتبط با امور
مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است
...
</p>
<Link
href="#"
className="text-[10px] font-normal text-blue text-left"
>
بیشتر بخوانید{" "}
</Link>
</div>
</div>
<div
className=" w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]"
>
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
<Image
alt="picture"
src="/img/pic1.png"
height={500}
width={500}
quality={100}
className="w-full h-full rounded-r-lg bg-cover object-cover object-center"
/>
</div>
<div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
<p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded ">
اخبار
</p>
<p className="text-xs font-medium text-right text-black">
24 آذر ماه 1402
</p>
<p className="text-base font-medium text-right text-black line-clamp-1">
شروع به کار سامانه عیون
</p>
<p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2">
این سامانه با هدف نظارت بر عملکرد پرسنل و نهادهای مرتبط با امور
مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است
...
</p>
<Link
href="#"
className="text-[10px] font-normal text-blue text-left"
> >
بیشتر بخوانید{" "} بیشتر بخوانید{" "}
</Link> </Link>
</div> </div>
</div> </div>
);
})}
</div> </div>
</div> </div>
); );

71
components/NewsDetail.tsx Normal file
View File

@ -0,0 +1,71 @@
"use client";
import { convertFullTime } from "@/lib/utils";
import { getNewsById } from "@/utils/commonApi";
import { useQuery } from "@tanstack/react-query";
import { ArrowRight } from "lucide-react";
import Image from "next/image";
import { useRouter } from "next/navigation";
import React from "react";
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 NewsDetail({ id }: { id: any }) {
const router = useRouter();
const { data, isLoading, isError, refetch } = useQuery({
queryKey: ["News", id],
queryFn: () => getNewsById(id),
});
return (
<div className="mt-10 w-full md:w-1/2 max-md:px-3">
{data && (
<>
<div className=" text-blue gap-1 mb-2 bg-gray-100 rounded-md p-2">
<div
className=" flex items-center cursor-pointer"
onClick={() => router.push("/News")}
>
<span>
<ArrowRight />
</span>
<span>بازگشت</span>
</div>
</div>
<p className=" font-bold mb-2">{data?.title}</p>
<div className=" w-full border ">
<Image
alt="picture"
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${data?.image?.url}`}
height={500}
width={500}
quality={100}
className="w-full h-auto bg-cover object-cover rounded-md"
/>
</div>
<div className=" text-gray-500 mt-2">
{convertFullTime(data.dateTime)}
</div>
<div className="">{data.content}</div>
</>
)}
</div>
);
}

View File

@ -22,6 +22,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { editProfile, getProfile } from "@/utils/authenticateApi"; import { editProfile, getProfile } from "@/utils/authenticateApi";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { toast } from "sonner"; import { toast } from "sonner";
import { Oval } from "react-loader-spinner";
const FormSchema = z.object({ const FormSchema = z.object({
firstName: z.string().min(1, { firstName: z.string().min(1, {
@ -63,8 +64,10 @@ export default function Profile() {
mutationKey: ["editProfile"], mutationKey: ["editProfile"],
mutationFn: editProfile, mutationFn: editProfile,
onSuccess: (res) => { onSuccess: (res) => {
router.push("/RequestStep2"); refetch();
localStorage.setItem("authorized", "true"); toast("پروفایل شما با موفقیت ویرایش شد.", {
className: "!bg-green-500 !text-white",
});
}, },
onError: (err: any | string) => { onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, { toast(<>{err.response.data.detail}</>, {
@ -86,15 +89,9 @@ export default function Profile() {
}, [profileData]); }, [profileData]);
console.log(form.getValues()); console.log(form.getValues());
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
// toast({ console.log(data);
// title: "You submitted the following values:",
// description: (
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
// <code className="text-white">{JSON.stringify(data, null, 2)}</code>
// </pre>
// ),
// });
const strNationalId = String(data.nationalId); const strNationalId = String(data.nationalId);
const payload = { ...data, nationalId: strNationalId }; const payload = { ...data, nationalId: strNationalId };
console.log(data); console.log(data);
@ -104,13 +101,14 @@ export default function Profile() {
return ( return (
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8"> <div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4"> <div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
<h2 className=" w-full font-bold">پروفایل کاربری</h2>
{profileData && ( {profileData && (
<Form {...form}> <Form {...form}>
<form <form
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col w-full mt-6 " className="flex flex-col w-full mt-6 "
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between border p-4 rounded-md">
<FormField <FormField
control={form.control} control={form.control}
name="firstName" name="firstName"
@ -123,7 +121,6 @@ export default function Profile() {
<Input <Input
placeholder="نام خود را وارد نمایید" placeholder="نام خود را وارد نمایید"
{...field} {...field}
readOnly={true}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -142,7 +139,6 @@ export default function Profile() {
<Input <Input
placeholder="نام خانوادگی خود را وارد نمایید" placeholder="نام خانوادگی خود را وارد نمایید"
{...field} {...field}
readOnly={true}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -162,7 +158,6 @@ export default function Profile() {
type="text" type="text"
placeholder="کد ملی خود را وارد نمایید " placeholder="کد ملی خود را وارد نمایید "
{...field} {...field}
readOnly={true}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -170,6 +165,30 @@ export default function Profile() {
)} )}
/> />
</div> </div>
<div className="flex justify-end w-full gap-2 mt-8">
<Button
disabled={editProfileMutation.isPending}
type="submit"
className="w-32 p-2 text-white transition bg-blue hover:bg-blue/90 rounded-xl"
>
{editProfileMutation.isPending ? (
<div className="flex items-center justify-center gap-2">
<Oval
visible={true}
height="20"
width="20"
color="#fff"
ariaLabel="oval-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
"ذخیره"
)}
{/* ورود */}
</Button>
</div>
</form> </form>
</Form> </Form>
)} )}

View File

@ -24,7 +24,7 @@ export default function SubmitRequest() {
درخواست و پیگیری آن را مشاهده می کنید. درخواست و پیگیری آن را مشاهده می کنید.
</p> </p>
<Link <Link
href="#" href="/RequestStep2"
className="text-sm font-bold text-blue text-left underline underline-offset-4" className="text-sm font-bold text-blue text-left underline underline-offset-4"
> >
برای شروع ارسال درخواست کلیک کنید. برای شروع ارسال درخواست کلیک کنید.

View File

@ -15,33 +15,31 @@ export async function getOrganizations() {
// Get Captcha // Get Captcha
export async function getCaptcha() { export async function getCaptcha() {
const data = await axios.get("api/Common/Captcha", { responseType: "blob" }); const data = await axios.get("api/Common/Captcha", { responseType: "blob" });
console.log(data);
return data; return data;
} }
export async function getSliders() { export async function getSliders() {
const data = await axios.get("api/Common/Sliders"); const data = await axios.get("api/Common/Sliders");
console.log(data);
return data.data; return data.data;
} }
export async function getWebContents() { export async function getWebContents() {
const data = await axios.get("api/Common/Contents"); const data = await axios.get("api/Common/Contents");
console.log(data);
return data.data; return data.data;
} }
export async function getSingleWebContents(title: string) { export async function getSingleWebContents(title: string) {
const data = await axios.get(`api/Common/Contents/${title}`); const data = await axios.get(`api/Common/Contents/${title}`);
console.log(data);
return data.data; return data.data;
} }
// News // News
export async function getNews() { export async function getNews() {
const data = await axios.get("api/Common/News"); const data = await axios.get("api/Common/News");
console.log(data);
return data.data; return data.data;
} }
export async function getNewsById(id: number) {
const data = await axios.get(`api/Common/News/${id}`);
return data.data;
}