"use client";
import type { WhopElementsOptions } from "@whop/embedded-components-vanilla-js/types";
import {
BalanceElement,
Elements,
PayoutsSession,
WithdrawButtonElement,
} from "@whop/embedded-components-react-js";
import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
const elements = loadWhopElements();
const appearance: WhopElementsOptions["appearance"] = {
classes: {
".Button": {
height: "40px",
"border-radius": "8px",
},
".Button:disabled": {
"background-color": "gray",
},
".Container": {
"border-radius": "12px",
},
},
};
export function BalancePage({ companyId }: { companyId: string }) {
return (
<Elements appearance={appearance} elements={elements}>
<PayoutsSession
token={() =>
fetch(`/api/token?companyId=${companyId}`)
.then((res) => res.json())
.then((data) => data.token)
}
>
<section
style={{ display: "flex", flexDirection: "column", gap: "8px" }}
>
<div
style={{ height: "95.5px", width: "100%", position: "relative" }}
>
<BalanceElement fallback={<div>Loading...</div>} />
</div>
<div style={{ height: "40px", width: "100%", position: "relative" }}>
<WithdrawButtonElement fallback={<div>Loading...</div>} />
</div>
</section>
</PayoutsSession>
</Elements>
);
}