"use client"; import React, { useEffect, useRef, useState } from "react"; import ReactDOM from "react-dom"; import Image from "next/image"; import Resultimg from "../public/img/result.png"; import { useQuery, useQueryClient } from "@tanstack/react-query"; 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 [title, setTitle] = useState("AfterRegistration"); const router = useRouter(); useEffect(() => { const tn = localStorage.getItem("trackingNumber"); const pw = localStorage.getItem("password"); setTrackingNumber(tn); setPassword(pw); }, []); // const handlePrint = useReactToPrint({ // content: () => componentRef.current, // }); const contentRef = useRef(); const handlePrint = useReactToPrint({ // content: () => contentRef.current, content: () => { console.log(contentRef.current); // Log the content to the console return contentRef.current; }, }); // const [fetchedContent, setFetchedContent] = useState(""); const { data, isLoading, isError, refetch } = useQuery({ queryKey: ["WebContents", title], queryFn: () => getSingleWebContents(title), refetchOnWindowFocus: false, }); useEffect(() => { refetch(); }, [title, refetch]); const fetchedContent = data?.content || ""; return (
{/* Display fetched content */}

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

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

{/* icon */}
{/* icon */}
); }