()
| 3 | import Layout from "../components/layout" |
| 4 | |
| 5 | export default function Page() { |
| 6 | const { status } = useSession({ |
| 7 | required: true, |
| 8 | }) |
| 9 | const [content, setContent] = useState() |
| 10 | |
| 11 | // Fetch content from protected route |
| 12 | useEffect(() => { |
| 13 | if (status === "loading") return |
| 14 | const fetchData = async () => { |
| 15 | const res = await fetch("/api/examples/protected") |
| 16 | const json = await res.json() |
| 17 | if (json.content) { |
| 18 | setContent(json.content) |
| 19 | } |
| 20 | } |
| 21 | fetchData() |
| 22 | }, [status]) |
| 23 | |
| 24 | if (status === "loading") return <Layout>Loading...</Layout> |
| 25 | |
| 26 | // If session exists, display content |
| 27 | return ( |
| 28 | <Layout> |
| 29 | <h1>Protected Page</h1> |
| 30 | <p> |
| 31 | <strong>{content}</strong> |
| 32 | </p> |
| 33 | </Layout> |
| 34 | ) |
| 35 | } |
nothing calls this directly
no test coverage detected