PrintPage Modified

Kahdooei
yasaman 2024-02-03 15:00:35 +03:30
parent e3c4d1ebf8
commit 6655175c0d
5 changed files with 35 additions and 9 deletions

View File

@ -29,7 +29,7 @@ export default function Footer() {
</h2> </h2>
<div> <div>
<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 text-justify">
<div <div
className=" !text-white footer" className=" !text-white footer"
dangerouslySetInnerHTML={{ __html: fetchedContent }} dangerouslySetInnerHTML={{ __html: fetchedContent }}

View File

@ -30,7 +30,7 @@ export default function Navbar() {
setAuth(false); setAuth(false);
} }
}, [isAuth, token]); }, [isAuth, token]);
console.log(pathname);
return ( return (
<div className={` left-0 right-0 top-0 z-20 fixed`}> <div className={` left-0 right-0 top-0 z-20 fixed`}>
{/* <TopNav /> */} {/* <TopNav /> */}

View File

@ -33,8 +33,7 @@ export default function Result() {
const contentRef = useRef<any>(); const contentRef = useRef<any>();
const handlePrint = useReactToPrint({ const handlePrint = useReactToPrint({
// content: () => contentRef.current, // content: () => contentRef.current,
content: () => { content: () => {
console.log(contentRef.current); // Log the content to the console
return contentRef.current; return contentRef.current;
}, },
}); });

View File

@ -130,9 +130,13 @@ export default function RequestStep2() {
mutationKey: ["authorizedComplaintSubmit"], mutationKey: ["authorizedComplaintSubmit"],
mutationFn: postAuthorizedComplaintSubmit, mutationFn: postAuthorizedComplaintSubmit,
onSuccess: (res) => { onSuccess: (res) => {
const currentDate = new Date();
const formattedDate = currentDate.toISOString()
localStorage.setItem("trackingNumber", res.trackingNumber); localStorage.setItem("trackingNumber", res.trackingNumber);
localStorage.setItem("password", res.password); localStorage.setItem("password", res.password);
localStorage.setItem("registeredAt", res.registeredAt); // localStorage.setItem("registeredAt", res.registeredAt);
localStorage.setItem("registeredAt", formattedDate);
localStorage.removeItem("authorized"); localStorage.removeItem("authorized");
localStorage.removeItem("unknown"); localStorage.removeItem("unknown");
router.push("/RequestResult"); router.push("/RequestResult");

View File

@ -1,5 +1,7 @@
// components/PrintPage.tsx "use client";
import React from "react"; import React, { useEffect } from "react";
// import { convertDate } from "@/lib/utils";
import dayjs from "dayjs";
interface PrintPageProps { interface PrintPageProps {
contentRef: React.RefObject<any>; contentRef: React.RefObject<any>;
@ -8,6 +10,17 @@ interface PrintPageProps {
password: string; password: string;
} }
// Convert Date
function convertDate(date: string) {
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format("YYYY/M/DD");
return convertedDate;
}
const registeredAt = localStorage.getItem("registeredAt");
const convertedDate = registeredAt ? convertDate(registeredAt) : "Invalid Date";
const PrintPage: React.FC<PrintPageProps> = ({ const PrintPage: React.FC<PrintPageProps> = ({
contentRef, contentRef,
fetchedContent, fetchedContent,
@ -20,9 +33,19 @@ const PrintPage: React.FC<PrintPageProps> = ({
className="w-screen h-screen border-2 border-spacing-6 p-36 bg-slate-200 bg-[url('/img/bg-print.jpg')] bg-no-repeat bg-bottom bg-cover font-[yekan]" className="w-screen h-screen border-2 border-spacing-6 p-36 bg-slate-200 bg-[url('/img/bg-print.jpg')] bg-no-repeat bg-bottom bg-cover font-[yekan]"
dir="rtl" dir="rtl"
> >
<div dangerouslySetInnerHTML={{ __html: fetchedContent }} className=" mt-16 text-justify" /> <div className="flex flex-col absolute top-7 left-28 text-xs gap-1">
<p>سامانه نظارت شهرداری یزد</p>
<p>
تاریخ: <span>{convertedDate}</span>
</p>
</div>
<p > <div
dangerouslySetInnerHTML={{ __html: fetchedContent }}
className=" mt-16 text-justify"
/>
<p>
کد پیگیری : <span>{trackingNumber}</span> کد پیگیری : <span>{trackingNumber}</span>
</p> </p>