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 { Button } from "./ui/button";
|
||||||
import { useReactToPrint } from "react-to-print";
|
import { useReactToPrint } from "react-to-print";
|
||||||
import { getSingleWebContents } from "@/utils/commonApi";
|
import { getSingleWebContents } from "@/utils/commonApi";
|
||||||
import PrintButton from "./PrintButton";
|
|
||||||
import PrintPage from "./printPage";
|
|
||||||
|
|
||||||
export default function Result() {
|
export default function Result() {
|
||||||
const [trackingNumber, setTrackingNumber] = useState<any>();
|
const [trackingNumber, setTrackingNumber] = useState<any>();
|
||||||
const [password, setPassword] = useState<any>();
|
const [password, setPassword] = useState<any>();
|
||||||
const componentRef = useRef<HTMLDivElement | null>(null);
|
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 [title, setTitle] = useState("AfterRegistration");
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -26,17 +27,14 @@ export default function Result() {
|
||||||
setPassword(pw);
|
setPassword(pw);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// const handlePrint = useReactToPrint({
|
// useEffect(() => {
|
||||||
// content: () => componentRef.current,
|
// const content1 = componentRef.current?.innerText || "";
|
||||||
// });
|
// const content2 = componentRef2.current?.innerText || "";
|
||||||
|
// setComponentData(<div>{content1 + content2}</div>);
|
||||||
|
// }, []);
|
||||||
|
|
||||||
const contentRef = useRef<any>();
|
|
||||||
const handlePrint = useReactToPrint({
|
const handlePrint = useReactToPrint({
|
||||||
// content: () => contentRef.current,
|
content: () => componentRef.current,
|
||||||
content: () => {
|
|
||||||
console.log(contentRef.current); // Log the content to the console
|
|
||||||
return contentRef.current;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// const [fetchedContent, setFetchedContent] = useState("");
|
// const [fetchedContent, setFetchedContent] = useState("");
|
||||||
|
|
@ -61,8 +59,7 @@ export default function Result() {
|
||||||
<div
|
<div
|
||||||
className=" flex flex-col justify-center font-[yekan] sm:pt-12 px-3 text-justify
|
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"
|
text-[#7C838A] dark:text-white text-sm font-medium leading-6 tracking-wide 3xl:text-base 3xl:font-bold"
|
||||||
// ref={componentRef}
|
ref={componentRef}
|
||||||
ref={contentRef}
|
|
||||||
dir="rtl"
|
dir="rtl"
|
||||||
>
|
>
|
||||||
{/* Display fetched content */}
|
{/* Display fetched content */}
|
||||||
|
|
@ -90,17 +87,32 @@ export default function Result() {
|
||||||
/> */}
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
<div className=" w-full flex flex-col justify-between items-end mt-2">
|
<div className=" w-full flex flex-col justify-between items-end mt-2">
|
||||||
|
{/* <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>
|
||||||
|
|
||||||
<div className="hidden">
|
<p
|
||||||
<PrintPage
|
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
||||||
contentRef={contentRef}
|
3xl:text-base 3xl:font-bold "
|
||||||
fetchedContent={fetchedContent}
|
>
|
||||||
trackingNumber={trackingNumber}
|
رمز عبور :
|
||||||
password={password}
|
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
||||||
/>
|
</p>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
<PrintButton handlePrint={handlePrint} />
|
<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>
|
</div>
|
||||||
{/* <Image
|
{/* <Image
|
||||||
alt="icon"
|
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