Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dApp: Action details update #792

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ function StakeDetails({ currency }: { currency: CurrencyType }) {

return (
<List spacing={3} mt={10}>
<TransactionDetailsAmountItem
label="Amount to be deposited"
from={{
currency,
amount: details.amount,
}}
to={{
currency: "usd",
}}
/>
<FeesDetailsAmountItem
label="Fees"
// TODO: Add `Bitcoin Network fee` (funding transaction fee selected by
Expand All @@ -48,15 +38,13 @@ function StakeDetails({ currency }: { currency: CurrencyType }) {
currency: "usd",
}}
/>

<TransactionDetailsAmountItem
label="Approximate staked tokens"
label="You will deposit"
from={{
currency,
amount: details.estimatedAmount,
}}
to={{
currency: "usd",
}}
/>
</List>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,11 @@ function UnstakeDetails({
const { total, ...restFees } = details.transactionFee

return (
<Flex flexDirection="column" gap={10} mt={4}>
<Flex flexDirection="column" gap={10} mt={10}>
{featureFlags.GAMIFICATION_ENABLED && (
<WithdrawWarning balance={balance} currency={currency} />
)}
<List spacing={3}>
<TransactionDetailsAmountItem
label="Withdraw from pool"
from={{
currency,
amount: details.amount,
}}
to={{
currency: "usd",
}}
/>

<FeesDetailsAmountItem
label="Fees"
// TODO: Add `Bitcoin Network fee` (funding transaction fee selected by
Expand All @@ -67,9 +56,6 @@ function UnstakeDetails({
currency,
amount: details.estimatedAmount,
}}
to={{
currency: "usd",
}}
/>
</List>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function UnstakeFormModal({
defaultAmount={defaultAmount}
>
<UnstakeDetails balance={balance} currency="bitcoin" />
<FormSubmitButton mt={10}>Withdraw</FormSubmitButton>
<FormSubmitButton mt={8}>Withdraw</FormSubmitButton>
</TokenAmountForm>
)
}
Expand Down
33 changes: 19 additions & 14 deletions dapp/src/components/shared/TransactionDetails/AmountItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React, { ComponentProps } from "react"
import { Flex } from "@chakra-ui/react"
import { Optional } from "#/types"
import TransactionDetailsItem, { TransactionDetailsItemProps } from "."
import { CurrencyBalanceWithConversion } from "../CurrencyBalanceWithConversion"
import { CurrencyBalance } from "../CurrencyBalance"

type TransactionDetailsAmountItemProps = ComponentProps<
typeof CurrencyBalanceWithConversion
type TransactionDetailsAmountItemProps = Optional<
ComponentProps<typeof CurrencyBalanceWithConversion>,
"to"
> &
Pick<TransactionDetailsItemProps, "label">

Expand All @@ -13,21 +16,23 @@ function TransactionDetailsAmountItem({
from,
to,
}: TransactionDetailsAmountItemProps) {
const fromProps: TransactionDetailsAmountItemProps["from"] = {
size: "md",
...from,
}

const toProps: TransactionDetailsAmountItemProps["to"] = to
? { size: "sm", fontWeight: "medium", color: "grey.500", ...to }
: undefined

return (
<TransactionDetailsItem label={label} alignItems="start">
<Flex flexDirection="column" alignItems="end">
<CurrencyBalanceWithConversion
from={{
size: "md",
...from,
}}
to={{
size: "sm",
fontWeight: "medium",
color: "grey.500",
...to,
}}
/>
{toProps ? (
<CurrencyBalanceWithConversion from={fromProps} to={toProps} />
) : (
<CurrencyBalance {...fromProps} />
)}
</Flex>
</TransactionDetailsItem>
)
Expand Down
2 changes: 2 additions & 0 deletions dapp/src/types/core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type Tuple<T> = [T, T]

export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }

export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
Loading