PrintPage Added
parent
d7e8b21fad
commit
4d1f2a6082
2
.env
2
.env
|
|
@ -1 +1 @@
|
||||||
NEXT_PUBLIC_BASE_URL_APP="https://oyoonapi.yazd.ir/"
|
NEXT_PUBLIC_BASE_URL_APP="https://sootzaniapi.shetabdahi.ir/"
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
/* 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 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
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,14 +9,13 @@ 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();
|
||||||
|
|
@ -27,14 +26,17 @@ export default function Result() {
|
||||||
setPassword(pw);
|
setPassword(pw);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// useEffect(() => {
|
// const handlePrint = useReactToPrint({
|
||||||
// const content1 = componentRef.current?.innerText || "";
|
// content: () => componentRef.current,
|
||||||
// const content2 = componentRef2.current?.innerText || "";
|
// });
|
||||||
// setComponentData(<div>{content1 + content2}</div>);
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
|
const contentRef = useRef<any>();
|
||||||
const handlePrint = useReactToPrint({
|
const handlePrint = useReactToPrint({
|
||||||
content: () => componentRef.current,
|
// content: () => contentRef.current,
|
||||||
|
content: () => {
|
||||||
|
console.log(contentRef.current); // Log the content to the console
|
||||||
|
return contentRef.current;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// const [fetchedContent, setFetchedContent] = useState("");
|
// const [fetchedContent, setFetchedContent] = useState("");
|
||||||
|
|
@ -54,12 +56,13 @@ export default function Result() {
|
||||||
return (
|
return (
|
||||||
<div
|
<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')]
|
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
|
<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 */}
|
||||||
|
|
@ -87,32 +90,17 @@ 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
|
<div className="hidden">
|
||||||
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
<PrintPage
|
||||||
3xl:text-base 3xl:font-bold "
|
contentRef={contentRef}
|
||||||
>
|
fetchedContent={fetchedContent}
|
||||||
کد پیگیری :
|
trackingNumber={trackingNumber}
|
||||||
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
|
password={password}
|
||||||
</p>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p
|
<PrintButton handlePrint={handlePrint} />
|
||||||
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>
|
</div>
|
||||||
{/* <Image
|
{/* <Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
// 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.
|
After Width: | Height: | Size: 645 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 202 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 737 KiB |
Loading…
Reference in New Issue