()
| 4 | |
| 5 | |
| 6 | export function Print() { |
| 7 | const router = useRouter(); |
| 8 | |
| 9 | useEffect(() => { |
| 10 | // Open all <details> elements |
| 11 | document.querySelectorAll("details").forEach((e) => (e.open = true)); |
| 12 | |
| 13 | |
| 14 | const closeWindow = () => { |
| 15 | console.log("PDF has been printed."); |
| 16 | window.close(); |
| 17 | }; |
| 18 | |
| 19 | // Add event listener for 'afterprint' event |
| 20 | window.addEventListener("afterprint", closeWindow); |
| 21 | |
| 22 | // Print the document |
| 23 | print(); |
| 24 | |
| 25 | // Clean up: Remove the event listener when component unmounts |
| 26 | return () => { |
| 27 | window.removeEventListener("afterprint", closeWindow); |
| 28 | }; |
| 29 | }, [router]); |
| 30 | |
| 31 | return null; |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected