"use client" import { useState } from "react" export function PortalButton() { const [loading, setLoading] = useState(false) async function handleClick() { setLoading(true) const res = await fetch("/api/stripe/portal", { method: "POST" }) const data = await res.json() if (data.url) window.location.href = data.url else setLoading(false) } return ( ) }