diff --git a/src/components/Send/ShowUtxos.tsx b/src/components/Send/ShowUtxos.tsx old mode 100755 new mode 100644 index 0abb009b..c4e6dbc5 --- a/src/components/Send/ShowUtxos.tsx +++ b/src/components/Send/ShowUtxos.tsx @@ -106,7 +106,7 @@ const UtxoRow = ({ utxo, onToggle, showBackgroundColor, settings, walletInfo, t ) -}) +} type SelectableUtxoTableRowData = SelectableUtxo & Pick @@ -290,4 +290,4 @@ const ShowUtxos = ({ isOpen, onCancel, onConfirm, isLoading, utxos, alert }: Sho ) } -export { ShowUtxos } +export { ShowUtxos, UtxoListDisplay } diff --git a/src/components/Send/SourceJarSelector.tsx b/src/components/Send/SourceJarSelector.tsx index ba89a914..a6e8e516 100644 --- a/src/components/Send/SourceJarSelector.tsx +++ b/src/components/Send/SourceJarSelector.tsx @@ -36,10 +36,6 @@ export const SourceJarSelector = ({ disabled = false, }: SourceJarSelectorProps) => { const { t } = useTranslation() -<<<<<<< HEAD -======= - ->>>>>>> a5e21fb (Fixed Undefined tag issue , Refactor Jar Selection logic & some minor css) const [field] = useField(name) const form = useFormikContext() const reloadCurrentWalletInfo = useReloadCurrentWalletInfo() @@ -149,7 +145,7 @@ export const SourceJarSelector = ({ walletInfo.balanceSummary.calculatedTotalBalanceInSats, )} variant={it.accountIndex === field.value ? variant : undefined} - onClick={(jarIndex: number) => { + onClick={(jarIndex) => { form.setFieldValue(field.name, jarIndex, true) if ( it.accountIndex === field.value && diff --git a/src/components/fb2/FidelityBondSteps.tsx b/src/components/fb2/FidelityBondSteps.tsx index 221cd943..71323c17 100644 --- a/src/components/fb2/FidelityBondSteps.tsx +++ b/src/components/fb2/FidelityBondSteps.tsx @@ -11,9 +11,8 @@ import { CopyButton } from '../CopyButton' import LockdateForm, { LockdateFormProps } from './LockdateForm' import * as fb from './utils' import styles from './FidelityBondSteps.module.css' -import { UtxoListDisplay, Divider } from '../Send/ShowUtxos' - -type UtxoList = Array +import { UtxoListDisplay } from '../Send/ShowUtxos' +import Divider from '../Divider' type SelectDateProps = { description: string @@ -90,13 +89,27 @@ const SelectJar = ({ ) } +type SelectableUtxo = Utxo & { checked: boolean; selectable: boolean } + const SelectUtxos = ({ selectedUtxos, utxos, onUtxoSelected, onUtxoDeselected }: SelectUtxosProps) => { const settings = useSettings() - // const [alert, setAlert] = useState(undefined) - const [showFrozenUtxos, setShowFrozenUtxos] = useState(false) - const [unFrozenUtxos, setUnFrozenUtxos] = useState([]) - const [frozenUtxos, setFrozenUtxos] = useState([]) - // const [isLoading, setisLoading] = useState(true) + const upperUtxos = utxos + .filter((it) => !it.frozen) + .filter((it) => !it.locktime) + .map((it) => + fb.utxo.isInList(it, selectedUtxos) + ? { + ...it, + checked: true, + selectable: true, + } + : { + ...it, + checked: false, + selectable: true, + }, + ) + .sort((a, b) => a.confirmations - b.confirmations) const frozenNonTimelockedUtxos = utxos .filter((it) => it.frozen) @@ -125,7 +138,7 @@ const SelectUtxos = ({ selectedUtxos, utxos, onUtxoSelected, onUtxoDeselected }: const [showFrozenUtxos, setShowFrozenUtxos] = useState(upperUtxos.length === 0 && lowerUtxos.length > 0) - const handleToggle = (utxoIndex: number, utxo: Utxo) => { + const handleToggle = (utxo: SelectableUtxo) => { utxo.checked = !utxo.checked if (utxo.checked) { onUtxoSelected(utxo) @@ -137,28 +150,16 @@ const SelectUtxos = ({ selectedUtxos, utxos, onUtxoSelected, onUtxoDeselected }: return ( <>
- - {frozenUtxos.length > 0 && ( + + {upperUtxos.length > 0 && lowerUtxos.length > 0 && ( setShowFrozenUtxos((current) => !current)} className={`mt-4 ${showFrozenUtxos && 'mb-4'}`} /> )} {showFrozenUtxos && ( - + )}
diff --git a/src/components/jars/Jar.tsx b/src/components/jars/Jar.tsx index 514cd313..1e3b6282 100644 --- a/src/components/jars/Jar.tsx +++ b/src/components/jars/Jar.tsx @@ -39,16 +39,6 @@ export type SelectableSendJarProps = JarProps & { onClick: (index: JarIndex) => void } -export type SelectableSendJarProps = JarProps & { - tooltipText: string - isSelectable: boolean - isSelected: boolean - variant?: 'default' | 'warning' - showingUTXOS: showingUTXOS - setshowingUTXOS: (val: showingUTXOS) => void - onClick: (index: JarIndex) => void -} - export type OpenableJarProps = Omit & { tooltipText: string onClick: () => void