-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove rredundant transaction form variants
- Loading branch information
1 parent
d1e566e
commit 46b6b24
Showing
10 changed files
with
186 additions
and
283 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
...ss-stack/components/transaction-screen.transaction-form.progress-stack.burn-variant-a.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...ss-stack/components/transaction-screen.transaction-form.progress-stack.burn-variant-b.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...ss-stack/components/transaction-screen.transaction-form.progress-stack.burn-variant-c.tsx
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
...ss-stack/components/transaction-screen.transaction-form.progress-stack.mint-variant-a.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...ss-stack/components/transaction-screen.transaction-form.progress-stack.mint-variant-b.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...ss-stack/components/transaction-screen.transaction-form.progress-stack.mint-variant-c.tsx
This file was deleted.
Oops, something went wrong.
154 changes: 154 additions & 0 deletions
154
...ion-form.progress-stack/components/transaction-screen.transaction-form.progress-stack.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { HStack, VStack } from '@chakra-ui/react'; | ||
import { VaultVerticalProgressBar } from '@components/vault/components/vault-vertical-progress-bar'; | ||
import { TransactionFormAPI } from '@models/form.models'; | ||
|
||
import { TransactionFormInputField } from '../../transaction-screen.transaction-form.input'; | ||
import { TransactionFormProgressStackItem } from '../../transaction-screen.transaction-form.progress-step-stack-item'; | ||
|
||
interface ProgressStackItemProps { | ||
label: string; | ||
assetLogo: string; | ||
assetSymbol: string; | ||
} | ||
|
||
const componentsMap = { | ||
mint: { | ||
A: { label: 'Deposit', assetLogo: '/images/logos/bitcoin-logo.svg', assetSymbol: 'BTC' }, | ||
B: { label: 'Mint', assetLogo: '/images/logos/dlc-btc-logo.svg', assetSymbol: 'dlcBTC' }, | ||
}, | ||
burn: { | ||
A: { label: 'Burn', assetLogo: '/images/logos/dlc-btc-logo.svg', assetSymbol: 'dlcBTC' }, | ||
B: { label: 'Withdraw', assetLogo: '/images/logos/bitcoin-logo.svg', assetSymbol: 'BTC' }, | ||
}, | ||
}; | ||
|
||
interface ProgressStackProps { | ||
formAPI: TransactionFormAPI; | ||
isIncludeForm: boolean; | ||
flow: 'mint' | 'burn'; | ||
currentStep: number; | ||
activeStackItem: 0 | 1; | ||
currentBitcoinPrice: number; | ||
components: { A: ProgressStackItemProps; B: ProgressStackItemProps }; | ||
} | ||
|
||
const ProgressStack = ({ | ||
formAPI, | ||
isIncludeForm, | ||
flow, | ||
currentStep, | ||
activeStackItem, | ||
currentBitcoinPrice, | ||
components, | ||
}: ProgressStackProps): React.JSX.Element => { | ||
const { A, B } = components; | ||
|
||
return ( | ||
<VStack w="85%"> | ||
{isIncludeForm ? ( | ||
<> | ||
<TransactionFormInputField | ||
formAPI={formAPI} | ||
currentStep={currentStep} | ||
currentBitcoinPrice={currentBitcoinPrice} | ||
formType={flow} | ||
/> | ||
<TransactionFormProgressStackItem | ||
label={B.label} | ||
assetLogo={B.assetLogo} | ||
assetSymbol={B.assetSymbol} | ||
isActive={activeStackItem === 1} | ||
/> | ||
</> | ||
) : ( | ||
<> | ||
<TransactionFormProgressStackItem | ||
label={A.label} | ||
assetLogo={A.assetLogo} | ||
assetSymbol={A.assetSymbol} | ||
isActive={activeStackItem === 0} | ||
/> | ||
<TransactionFormProgressStackItem | ||
label={B.label} | ||
assetLogo={B.assetLogo} | ||
assetSymbol={B.assetSymbol} | ||
isActive={activeStackItem === 1} | ||
/> | ||
</> | ||
)} | ||
</VStack> | ||
); | ||
}; | ||
|
||
interface ProgressStackByFlowProps { | ||
formAPI: TransactionFormAPI; | ||
flow: 'mint' | 'burn'; | ||
currentStep: number; | ||
confirmations?: number; | ||
currentBitcoinPrice: number; | ||
} | ||
|
||
const ProgressStackByFlow = ({ | ||
formAPI, | ||
flow, | ||
currentStep, | ||
confirmations = 0, | ||
currentBitcoinPrice, | ||
}: ProgressStackByFlowProps): React.JSX.Element => { | ||
const components = componentsMap[flow]; | ||
const isIncludeForm = flow === 'mint' ? currentStep === 1 : currentStep === 0; | ||
const activeStackItem = isIncludeForm || (flow === 'mint' && confirmations < 6) ? 0 : 1; | ||
|
||
return ( | ||
<ProgressStack | ||
formAPI={formAPI} | ||
isIncludeForm={isIncludeForm} | ||
flow={flow} | ||
currentStep={currentStep} | ||
activeStackItem={activeStackItem} | ||
currentBitcoinPrice={currentBitcoinPrice} | ||
components={components} | ||
/> | ||
); | ||
}; | ||
|
||
interface TransactionFormProgressStackBurnVariantAProps { | ||
formAPI: TransactionFormAPI; | ||
flow: 'mint' | 'burn'; | ||
currentBitcoinPrice: number; | ||
currentStep: number; | ||
confirmations?: number; | ||
} | ||
|
||
export const TransactionFormProgressStack = ({ | ||
formAPI, | ||
flow, | ||
currentStep, | ||
confirmations = 0, | ||
currentBitcoinPrice, | ||
}: TransactionFormProgressStackBurnVariantAProps): React.JSX.Element => { | ||
return ( | ||
<HStack | ||
w="100%" | ||
p="15px 15px 15px 0" | ||
bg="white.04" | ||
border="1px solid" | ||
borderColor="white.03" | ||
borderRadius="md" | ||
justifyContent="space-between" | ||
> | ||
<VaultVerticalProgressBar | ||
currentStep={currentStep} | ||
flow={flow} | ||
confirmations={confirmations} | ||
/> | ||
<ProgressStackByFlow | ||
formAPI={formAPI} | ||
flow={flow} | ||
currentStep={currentStep} | ||
confirmations={confirmations} | ||
currentBitcoinPrice={currentBitcoinPrice} | ||
/> | ||
</HStack> | ||
); | ||
}; |
Oops, something went wrong.