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

modal instead of dropdown for new FB creation form #762

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 20 additions & 11 deletions src/components/fb/CreateFidelityBond.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
const reloadCurrentWalletInfo = useReloadCurrentWalletInfo()
const feeConfigValues = useFeeConfigValues()[0]

const [isExpanded, setIsExpanded] = useState(false)
const [showCreateFidelityBondModal, setShowCreateFidelityBondModal] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [alert, setAlert] = useState<SimpleAlert>()
const [step, setStep] = useState(steps.selectDate)
Expand Down Expand Up @@ -107,7 +107,7 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon

const reset = () => {
setIsLoading(false)
setIsExpanded(false)
setShowCreateFidelityBondModal(false)
setStep(steps.selectDate)
setSelectedJar(undefined)
setSelectedUtxos([])
Expand All @@ -129,7 +129,7 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
}, [fidelityBonds, lockDate])

useEffect(() => {
if (!isExpanded) {
if (!showCreateFidelityBondModal) {
reset()
} else {
setIsLoading(true)
Expand All @@ -146,7 +146,7 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
})
return () => abortCtrl.abort()
}
}, [isExpanded, reloadCurrentWalletInfo, t])
}, [showCreateFidelityBondModal, reloadCurrentWalletInfo, t])

const freezeUtxos = (utxos: Utxos) => {
changeUtxoFreeze(utxos, true)
Expand Down Expand Up @@ -645,14 +645,14 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
</PaymentConfirmModal>
)}

<div className={styles.header} onClick={() => setIsExpanded(!isExpanded)}>
<div className={styles.header} onClick={() => setShowCreateFidelityBondModal(!showCreateFidelityBondModal)}>
<div className="d-flex justify-content-between align-items-center">
<div className={styles.title}>
{otherFidelityBondExists
? t('earn.fidelity_bond.title_fidelity_bond_exists')
: t('earn.fidelity_bond.title')}
</div>
<Sprite symbol={isExpanded ? 'caret-up' : 'plus'} width="20" height="20" />
<Sprite symbol={'plus'} width="20" height="20" />
</div>
<div className={styles.subtitle}>
{otherFidelityBondExists ? (
Expand All @@ -673,9 +673,18 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
)}
</div>
</div>
<rb.Collapse in={isExpanded}>
<div>
<hr />
<rb.Modal
show={showCreateFidelityBondModal}
animation={true}
backdrop="static"
centered={true}
keyboard={false}
onHide={() => setShowCreateFidelityBondModal(false)}
>
<rb.Modal.Header closeButton>
<rb.Modal.Title>{t('earn.fidelity_bond.create_fidelity_bond.title')}</rb.Modal.Title>
</rb.Modal.Header>
<rb.Modal.Body>
<div className="mb-5">{stepComponent(step)}</div>
<div className="d-flex flex-column gap-2">
{!isLoading && primaryButtonText(step) !== null && (
Expand All @@ -697,8 +706,8 @@ const CreateFidelityBond = ({ otherFidelityBondExists, wallet, walletInfo, onDon
</rb.Button>
)}
</div>
</div>
</rb.Collapse>
</rb.Modal.Body>
</rb.Modal>
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
"label_selected_utxos": "UTXOs that will be time-locked:"
},
"create_fidelity_bond": {
"title": "Create Fidelity Bond",
"success_text": "Fidelity bond created!",
"text_primary_button": "Done",
"text_primary_button_unfreeze": "Unfreeze UTXOs",
Expand Down
Loading