Skip to content

Commit

Permalink
conditional description
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Jan 15, 2025
1 parent ec3f8c8 commit 6b44925
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions packages/keychain/src/components/funding/PurchaseCredits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ enum PurchaseState {
}

type PurchaseCreditsProps = {
isSlot?: boolean;
onBack?: () => void;
};

export function PurchaseCredits({ onBack }: PurchaseCreditsProps) {
export function PurchaseCredits({ isSlot, onBack }: PurchaseCreditsProps) {
const { controller, closeModal } = useConnection();

const [clientSecret, setClientSecret] = useState("");
Expand Down Expand Up @@ -120,7 +121,11 @@ export function PurchaseCredits({ onBack }: PurchaseCreditsProps) {
<ErrorAlert
variant=""
title="WHAT ARE CREDITS"
description="Credits can be used to play games or pay for slot deployments. They are not tokens and cannot be transferred or refunded."
description={
"Credits can be used " +
(isSlot ? "for slot deployments" : "to play games") +
". They are not tokens and cannot be transferred or refunded."
}
isExpanded
/>
</Content>
Expand Down
17 changes: 9 additions & 8 deletions packages/keychain/src/components/funding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ const enum FundingState {

export type FundingProps = {
title?: React.ReactElement | string;
creditsOnly?: boolean;
isSlot?: boolean;
onComplete?: (deployHash?: string) => void;
};

export function Funding({ title, creditsOnly, onComplete }: FundingProps) {
export function Funding({ title, isSlot, onComplete }: FundingProps) {
const { controller } = useConnection();
const [state, setState] = useState<FundingState>(FundingState.SHOW_OPTIONS);
const showBalances: BalanceType[] = creditsOnly
? ["credits"]
: ["credits", "eth"];
const showBalances: BalanceType[] = isSlot ? ["credits"] : ["credits", "eth"];
const showCredits =
(typeof document !== "undefined" && document.cookie.includes("credits=")) ||
creditsOnly;
isSlot;

if (state === FundingState.FUND_ETH) {
return (
Expand All @@ -45,7 +43,10 @@ export function Funding({ title, creditsOnly, onComplete }: FundingProps) {

if (state === FundingState.FUND_CREDITS) {
return (
<PurchaseCredits onBack={() => setState(FundingState.SHOW_OPTIONS)} />
<PurchaseCredits
isSlot={isSlot}
onBack={() => setState(FundingState.SHOW_OPTIONS)}
/>
);
}

Expand All @@ -65,7 +66,7 @@ export function Funding({ title, creditsOnly, onComplete }: FundingProps) {
<CoinsIcon variant="line" size="sm" /> Purchase Credits
</Button>
)}
{!creditsOnly && (
{!isSlot && (
<Button
onClick={() => setState(FundingState.FUND_ETH)}
variant="secondary"
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/slot/fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function Fund() {
}
}, [navigate, pathname]);

return <Funding title="Fund Credits for Slot" creditsOnly={true} />;
return <Funding title="Fund Credits for Slot" isSlot />;
}

0 comments on commit 6b44925

Please sign in to comment.