diff --git a/.env b/.env index d82fc5d..2d0c1a9 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -NEXT_PUBLIC_BASE_URL_APP="https://oyoonapi.yazd.ir/" \ No newline at end of file +NEXT_PUBLIC_BASE_URL_APP="https://sootzaniapi.shetabdahi.ir/" \ No newline at end of file diff --git a/app/print-styles.css b/app/print-styles.css deleted file mode 100644 index 80d5fc1..0000000 --- a/app/print-styles.css +++ /dev/null @@ -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 */ - } -} \ No newline at end of file diff --git a/components/PrintButton.tsx b/components/PrintButton.tsx new file mode 100644 index 0000000..3ceef9f --- /dev/null +++ b/components/PrintButton.tsx @@ -0,0 +1,18 @@ +import React from "react"; + +interface PrintButtonProps { + handlePrint: () => void; +} + +const PrintButton: React.FC = ({ handlePrint }) => { + return ( + + ); +}; + +export default PrintButton; diff --git a/components/RequestResult.tsx b/components/RequestResult.tsx index 176e53c..adcd52e 100644 --- a/components/RequestResult.tsx +++ b/components/RequestResult.tsx @@ -9,14 +9,13 @@ 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(); const [password, setPassword] = useState(); const componentRef = useRef(null); - // const componentRef2 = useRef(null); - // const [componentData, setComponentData] = useState(null); - const [title, setTitle] = useState("AfterRegistration"); const router = useRouter(); @@ -27,14 +26,17 @@ export default function Result() { setPassword(pw); }, []); - // useEffect(() => { - // const content1 = componentRef.current?.innerText || ""; - // const content2 = componentRef2.current?.innerText || ""; - // setComponentData(
{content1 + content2}
); - // }, []); + // const handlePrint = useReactToPrint({ + // content: () => componentRef.current, + // }); + const contentRef = useRef(); 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(""); @@ -54,12 +56,13 @@ export default function Result() { return (
{/* Display fetched content */} @@ -87,32 +90,17 @@ export default function Result() { /> */}
- {/*
-

- کد پیگیری : - {`${trackingNumber}`} -

+ +
+ +
-

- رمز عبور : - {`${password}`} -

-
*/} - - +
{/* icon; + fetchedContent: string; + trackingNumber: string; + password: string; +} + +const PrintPage: React.FC = ({ + contentRef, + fetchedContent, + trackingNumber, + password, +}) => { + return ( +
+
+ +

+ کد پیگیری : {trackingNumber} +

+ +

+ رمز عبور : {password} +

+
+ ); +}; + +export default PrintPage; diff --git a/public/img/bg-print.jpg b/public/img/bg-print.jpg new file mode 100644 index 0000000..e6b89a1 Binary files /dev/null and b/public/img/bg-print.jpg differ diff --git a/public/img/bg-print1.png b/public/img/bg-print1.png new file mode 100644 index 0000000..b9de362 Binary files /dev/null and b/public/img/bg-print1.png differ diff --git a/public/img/logo-print.png b/public/img/logo-print.png new file mode 100644 index 0000000..1cfa036 Binary files /dev/null and b/public/img/logo-print.png differ diff --git a/public/img/pattern-print.png b/public/img/pattern-print.png new file mode 100644 index 0000000..d902b7c Binary files /dev/null and b/public/img/pattern-print.png differ