diff --git a/src/components/fb2/CreateFidelityBond.tsx b/src/components/fb2/CreateFidelityBond.tsx index 6073d5b7..de903337 100644 --- a/src/components/fb2/CreateFidelityBond.tsx +++ b/src/components/fb2/CreateFidelityBond.tsx @@ -458,6 +458,7 @@ const CreateFidelityBond2 = ({ otherFidelityBondExists, wallet, walletInfo, onDo setLockDate(date)} /> {bondWithSelectedLockDateAlreadyExists && ( diff --git a/src/components/fb2/FidelityBondSteps.tsx b/src/components/fb2/FidelityBondSteps.tsx index 71323c17..d121a866 100644 --- a/src/components/fb2/FidelityBondSteps.tsx +++ b/src/components/fb2/FidelityBondSteps.tsx @@ -43,13 +43,13 @@ interface ConfirmationProps { timelockedAddress: Api.BitcoinAddress } -const SelectDate = ({ description, yearsRange, disabled, onChange }: SelectDateProps) => { +const SelectDate = ({ description, yearsRange, lockdate, disabled, onChange }: SelectDateProps) => { return (
{description}
- +
) diff --git a/src/components/fb2/LockdateForm.test.tsx b/src/components/fb2/LockdateForm.test.tsx index 5360b815..06fcfa69 100644 --- a/src/components/fb2/LockdateForm.test.tsx +++ b/src/components/fb2/LockdateForm.test.tsx @@ -9,10 +9,11 @@ import LockdateForm, { _minMonth, _selectableMonths, _selectableYears } from './ describe('', () => { const now = new Date(Date.UTC(2009, 0, 3)) + const lockdate = null const setup = (onChange: (lockdate: Api.Lockdate | null) => void) => { render( - + , ) } diff --git a/src/components/fb2/LockdateForm.tsx b/src/components/fb2/LockdateForm.tsx index fef84ce4..bf1ed430 100644 --- a/src/components/fb2/LockdateForm.tsx +++ b/src/components/fb2/LockdateForm.tsx @@ -59,17 +59,21 @@ export const _selectableYears = (yearsRange: fb.YearsRange, now = new Date()): n export interface LockdateFormProps { onChange: (lockdate: Api.Lockdate | null) => void + lockdate: Api.Lockdate | null yearsRange?: fb.YearsRange now?: Date disabled?: boolean } -const LockdateForm = ({ onChange, now, yearsRange, disabled }: LockdateFormProps) => { +const LockdateForm = ({ onChange, now, lockdate, yearsRange, disabled }: LockdateFormProps) => { const { i18n } = useTranslation() const _now = useMemo(() => now || new Date(), [now]) const _yearsRange = useMemo(() => yearsRange || fb.DEFAULT_TIMELOCK_YEARS_RANGE, [yearsRange]) - const initialValue = useMemo(() => fb.lockdate.initial(_now, _yearsRange), [_now, _yearsRange]) + const initialValue = useMemo(() => { + if (lockdate) return lockdate + return fb.lockdate.initial(_now, _yearsRange) + }, [_now, _yearsRange, lockdate]) const initialDate = useMemo(() => new Date(fb.lockdate.toTimestamp(initialValue)), [initialValue]) const initialYear = useMemo(() => initialDate.getUTCFullYear(), [initialDate]) const initialMonth = useMemo(() => (initialDate.getUTCMonth() + 1) as Month, [initialDate]) diff --git a/src/components/fb2/SpendFidelityBondModal.tsx b/src/components/fb2/SpendFidelityBondModal.tsx index 9f41412c..976af011 100644 --- a/src/components/fb2/SpendFidelityBondModal.tsx +++ b/src/components/fb2/SpendFidelityBondModal.tsx @@ -372,6 +372,7 @@ const RenewFidelityBondModal = ({