Compare commits
No commits in common. "f9130e9ec28d940bf2fe78195c1940f69dcc2f96" and "0fee5b0379029a78e1d9c2194de54ca2f96391b1" have entirely different histories.
f9130e9ec2
...
0fee5b0379
|
|
@ -0,0 +1,13 @@
|
|||
/* styles/print-styles.css */
|
||||
|
||||
@media print {
|
||||
|
||||
/* Add styles for the print window */
|
||||
body {
|
||||
font-size: larger;
|
||||
color: red;
|
||||
background-color: aquamarine;
|
||||
padding: 2em;
|
||||
/* Add any other print-specific styles */
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import React from "react";
|
||||
|
||||
interface PrintButtonProps {
|
||||
handlePrint: () => void;
|
||||
}
|
||||
|
||||
const PrintButton: React.FC<PrintButtonProps> = ({ handlePrint }) => {
|
||||
return (
|
||||
<button
|
||||
onClick={handlePrint}
|
||||
className="w-full sm:w-fit bg-blue text-white p-2 rounded-xl text-center "
|
||||
>
|
||||
پرینت
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrintButton;
|
||||
|
|
@ -9,13 +9,14 @@ import { useRouter } from "next/navigation";
|
|||
import { Button } from "./ui/button";
|
||||
import { useReactToPrint } from "react-to-print";
|
||||
import { getSingleWebContents } from "@/utils/commonApi";
|
||||
import PrintButton from "./PrintButton";
|
||||
import PrintPage from "./printPage";
|
||||
|
||||
export default function Result() {
|
||||
const [trackingNumber, setTrackingNumber] = useState<any>();
|
||||
const [password, setPassword] = useState<any>();
|
||||
const componentRef = useRef<HTMLDivElement | null>(null);
|
||||
// const componentRef2 = useRef<HTMLDivElement | null>(null);
|
||||
// const [componentData, setComponentData] = useState<React.ReactNode | null>(null);
|
||||
|
||||
const [title, setTitle] = useState("AfterRegistration");
|
||||
|
||||
const router = useRouter();
|
||||
|
|
@ -26,17 +27,14 @@ export default function Result() {
|
|||
setPassword(pw);
|
||||
}, []);
|
||||
|
||||
// const handlePrint = useReactToPrint({
|
||||
// content: () => componentRef.current,
|
||||
// });
|
||||
// useEffect(() => {
|
||||
// const content1 = componentRef.current?.innerText || "";
|
||||
// const content2 = componentRef2.current?.innerText || "";
|
||||
// setComponentData(<div>{content1 + content2}</div>);
|
||||
// }, []);
|
||||
|
||||
const contentRef = useRef<any>();
|
||||
const handlePrint = useReactToPrint({
|
||||
// content: () => contentRef.current,
|
||||
content: () => {
|
||||
console.log(contentRef.current); // Log the content to the console
|
||||
return contentRef.current;
|
||||
},
|
||||
content: () => componentRef.current,
|
||||
});
|
||||
|
||||
// const [fetchedContent, setFetchedContent] = useState("");
|
||||
|
|
@ -56,13 +54,12 @@ export default function Result() {
|
|||
return (
|
||||
<div
|
||||
className={`w-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 sm:bg-[url('/img/Result1.png')]
|
||||
h-[85vh] bg-50% bg-no-repeat bg-center flex flex-col gap-4`}
|
||||
h-[85vh] bg-50% bg-no-repeat bg-center flex flex-col gap-4`}
|
||||
>
|
||||
<div
|
||||
className=" flex flex-col justify-center font-[yekan] sm:pt-12 px-3 text-justify
|
||||
text-[#7C838A] dark:text-white text-sm font-medium leading-6 tracking-wide 3xl:text-base 3xl:font-bold"
|
||||
// ref={componentRef}
|
||||
ref={contentRef}
|
||||
ref={componentRef}
|
||||
dir="rtl"
|
||||
>
|
||||
{/* Display fetched content */}
|
||||
|
|
@ -90,17 +87,32 @@ export default function Result() {
|
|||
/> */}
|
||||
</div>
|
||||
<div className=" w-full flex flex-col justify-between items-end mt-2">
|
||||
|
||||
<div className="hidden">
|
||||
<PrintPage
|
||||
contentRef={contentRef}
|
||||
fetchedContent={fetchedContent}
|
||||
trackingNumber={trackingNumber}
|
||||
password={password}
|
||||
/>
|
||||
</div>
|
||||
{/* <div className="pr-4">
|
||||
<p
|
||||
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
||||
3xl:text-base 3xl:font-bold "
|
||||
>
|
||||
کد پیگیری :
|
||||
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
|
||||
</p>
|
||||
|
||||
<PrintButton handlePrint={handlePrint} />
|
||||
<p
|
||||
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
||||
3xl:text-base 3xl:font-bold "
|
||||
>
|
||||
رمز عبور :
|
||||
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
||||
</p>
|
||||
</div> */}
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
type="submit"
|
||||
onClick={handlePrint}
|
||||
className="w-full sm:w-fit bg-blue text-white p-2 rounded-xl text-center "
|
||||
>
|
||||
پرینت
|
||||
</Button>
|
||||
</div>
|
||||
{/* <Image
|
||||
alt="icon"
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
// components/PrintPage.tsx
|
||||
import React from "react";
|
||||
|
||||
interface PrintPageProps {
|
||||
contentRef: React.RefObject<any>;
|
||||
fetchedContent: string;
|
||||
trackingNumber: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
const PrintPage: React.FC<PrintPageProps> = ({
|
||||
contentRef,
|
||||
fetchedContent,
|
||||
trackingNumber,
|
||||
password,
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
ref={contentRef}
|
||||
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"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: fetchedContent }} className=" " />
|
||||
|
||||
<p >
|
||||
کد پیگیری : <span>{trackingNumber}</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
رمز عبور : <span>{password}</span>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrintPage;
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 645 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 202 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 737 KiB |
Loading…
Reference in New Issue