Skip to content

Commit

Permalink
merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barrytra committed Aug 20, 2024
2 parents fe9a1c5 + 2f0e5d9 commit 2f878e9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/components/Send/ShowUtxos.tsx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const UtxoRow = ({ utxo, onToggle, showBackgroundColor, settings, walletInfo, t
</Cell>
</Row>
)
})
}

type SelectableUtxoTableRowData = SelectableUtxo & Pick<TableTypes.TableNode, 'id'>

Expand Down Expand Up @@ -290,4 +290,4 @@ const ShowUtxos = ({ isOpen, onCancel, onConfirm, isLoading, utxos, alert }: Sho
)
}

export { ShowUtxos }
export { ShowUtxos, UtxoListDisplay }
6 changes: 1 addition & 5 deletions src/components/Send/SourceJarSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<JarIndex>(name)
const form = useFormikContext<any>()
const reloadCurrentWalletInfo = useReloadCurrentWalletInfo()
Expand Down Expand Up @@ -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 &&
Expand Down
53 changes: 27 additions & 26 deletions src/components/fb2/FidelityBondSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utxo>
import { UtxoListDisplay } from '../Send/ShowUtxos'
import Divider from '../Divider'

type SelectDateProps = {
description: string
Expand Down Expand Up @@ -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<SimpleAlert | undefined>(undefined)
const [showFrozenUtxos, setShowFrozenUtxos] = useState<boolean>(false)
const [unFrozenUtxos, setUnFrozenUtxos] = useState<UtxoList>([])
const [frozenUtxos, setFrozenUtxos] = useState<UtxoList>([])
// const [isLoading, setisLoading] = useState<boolean>(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)
Expand Down Expand Up @@ -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)
Expand All @@ -137,28 +150,16 @@ const SelectUtxos = ({ selectedUtxos, utxos, onUtxoSelected, onUtxoDeselected }:
return (
<>
<div className="d-flex flex-column gap-4">
<UtxoListDisplay
utxos={unFrozenUtxos}
onToggle={handleToggle}
settings={settings}
showRadioButton={true}
showBackgroundColor={true}
/>
{frozenUtxos.length > 0 && (
<UtxoListDisplay utxos={upperUtxos} onToggle={handleToggle} settings={settings} showBackgroundColor={true} />
{upperUtxos.length > 0 && lowerUtxos.length > 0 && (
<Divider
isState={showFrozenUtxos}
setIsState={setShowFrozenUtxos}
toggled={showFrozenUtxos}
onToggle={() => setShowFrozenUtxos((current) => !current)}
className={`mt-4 ${showFrozenUtxos && 'mb-4'}`}
/>
)}
{showFrozenUtxos && (
<UtxoListDisplay
utxos={frozenUtxos}
onToggle={handleToggle}
settings={settings}
showRadioButton={true}
showBackgroundColor={true}
/>
<UtxoListDisplay utxos={lowerUtxos} onToggle={handleToggle} settings={settings} showBackgroundColor={true} />
)}
</div>
</>
Expand Down
10 changes: 0 additions & 10 deletions src/components/jars/Jar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<JarProps, 'isOpen'> & {
tooltipText: string
onClick: () => void
Expand Down

0 comments on commit 2f878e9

Please sign in to comment.