Skip to content

Commit

Permalink
feat: update RadioCards to use monthlyBoostCost for dynamic pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Oct 20, 2024
1 parent b9f89aa commit 952e006
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions apps/renderer/src/modules/boost/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const BoostModalContent = ({ feedId }: { feedId: string }) => {
const dPowerBigInt = BigInt(myWalletData?.dailyPowerToken ?? 0)
const cPowerBigInt = BigInt(myWalletData?.cashablePowerToken ?? 0)
const balanceBigInt = cPowerBigInt + dPowerBigInt
const [amount, setAmount] = useState<number>(80)
const [amount, setAmount] = useState<number>(0)
const amountBigInt = from(amount, 18)[0]
const wrongNumberRange = amountBigInt > balanceBigInt || amountBigInt <= BigInt(0)

Expand Down Expand Up @@ -71,7 +71,11 @@ export const BoostModalContent = ({ feedId }: { feedId: string }) => {
</small>

<BoostProgress {...boostStatus} />
<RadioCards value={amount} onValueChange={setAmount} />
<RadioCards
monthlyBoostCost={boostStatus.monthlyBoostCost}
value={amount}
onValueChange={setAmount}
/>
</div>

<Button
Expand Down
14 changes: 8 additions & 6 deletions apps/renderer/src/modules/boost/radio-cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ import { RadioCard } from "~/components/ui/radio-group/RadioCard"
const radios = [
{
name: "1 Month",
amount: 80,
value: 1,
},
{
name: "3 Months",
amount: 240,
value: 3,
},
{
name: "6 Months",
amount: 480,
value: 6,
},
{
name: "1 Year",
amount: 960,
value: 12,
},
]

export const RadioCards = ({
monthlyBoostCost,
value,
onValueChange,
}: {
monthlyBoostCost: number
value: number
onValueChange: (value: number) => void
}) => {
Expand All @@ -34,12 +36,12 @@ export const RadioCards = ({
<RadioCard
key={item.name}
wrapperClassName="justify-center"
value={item.amount.toString()}
value={(item.value * monthlyBoostCost).toString()}
label={
<div>
<h3 className="pr-3 font-medium leading-none">{item.name}</h3>
<p className="mt-1 flex items-center justify-center gap-1 text-sm text-theme-vibrancyFg">
{item.amount}
{item.value * monthlyBoostCost}
<i className="i-mgc-power text-accent" />
</p>
</div>
Expand Down

0 comments on commit 952e006

Please sign in to comment.