diff --git a/srcv2/components/SendBonus.js b/srcv2/components/SendBonus.js index 349168ec..028cc89b 100644 --- a/srcv2/components/SendBonus.js +++ b/srcv2/components/SendBonus.js @@ -22,6 +22,7 @@ const SendBonus = (props) => { const [bonusPayments, setBonusPayments] = useState([]) const [selectedBonusSplitType, setSelectedBonusSplitType] = useState(0) const [sentBonuses, setSentBonuses] = useState(0) + const [selectedCurrency, setSelectedCurrency] = useState('s ') const buttonText = ['Continue', 'Send bonuses', 'Finish'] @@ -34,7 +35,7 @@ const SendBonus = (props) => { throw new Error('User does not have a wallet setup') } if (bp.contributor.wallet.invoice_macaroon != null || bp.contributor.wallet.onchain_address != null) { - contributorsWithWallets.push({ contributor_id: bp.contributor.id, amount_to_pay: Math.round(bp.satsBonusAmount) }) + contributorsWithWallets.push({ contributor_id: bp.contributor.id, amount_to_pay: Math.round(selectedCurrency == 's ' ? bp.amount : bp.satsBonusAmount) }) } } catch (error) { console.log('An error occurred: ' + error) @@ -124,17 +125,21 @@ const SendBonus = (props) => { setBonusPayments={setBonusPayments} selectedBonusSplitType={selectedBonusSplitType} setSelectedBonusSplitType={setSelectedBonusSplitType} + selectedCurrency={selectedCurrency} + setSelectedCurrency={setSelectedCurrency} /> } {screenIndex == 1 && } {screenIndex == 2 && }
diff --git a/srcv2/components/SendBonusAmount.js b/srcv2/components/SendBonusAmount.js index 72159ada..26cf1c50 100644 --- a/srcv2/components/SendBonusAmount.js +++ b/srcv2/components/SendBonusAmount.js @@ -25,7 +25,9 @@ const SendBonusAmount = (props) => { bonusPayments, setBonusPayments, selectedBonusSplitType, - setSelectedBonusSplitType + setSelectedBonusSplitType, + selectedCurrency, + setSelectedCurrency } = props return ( @@ -60,6 +62,8 @@ const SendBonusAmount = (props) => { setSelectedContributors={setSelectedContributors} bonusAmount={bonusAmount} setBonusAmount={setBonusAmount} + selectedCurrency={selectedCurrency} + setSelectedCurrency={setSelectedCurrency} /> ) : ( { const { bonusPayments, - selectedBonusSplitType + selectedBonusSplitType, + selectedCurrency } = props const renderSenders = () => { @@ -21,11 +22,16 @@ const SendBonusConfirmation = (props) => {

- {`${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS`} -

-

- {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} + {selectedCurrency == 's ' + ? `${Intl.NumberFormat().format(Math.trunc(bp.amount))} SATS` + : `${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS` + }

+ {selectedCurrency != 's ' && +

+ {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} +

+ }
) @@ -46,11 +52,16 @@ const SendBonusConfirmation = (props) => { {selectedBonusSplitType == 0 && <>

- {`${Intl.NumberFormat().format(Math.trunc(bonusPayments[0].satsBonusAmount))} SATS`} + {selectedCurrency == 's ' + ? `${Intl.NumberFormat().format(Math.trunc(bonusPayments[0].amount))} SATS` + : `${Intl.NumberFormat().format(Math.trunc(bonusPayments[0].satsBonusAmount))} SATS` + }

-

- {`~ ${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bonusPayments[0].amount))}`} -

+ {selectedCurrency != 's ' && +

+ {`~ ${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bonusPayments[0].amount))}`} +

+ } }

diff --git a/srcv2/components/SendBonusEqualy.js b/srcv2/components/SendBonusEqualy.js index d4beda81..8782813e 100644 --- a/srcv2/components/SendBonusEqualy.js +++ b/srcv2/components/SendBonusEqualy.js @@ -9,21 +9,24 @@ const SendBonusEqualy = (props) => { const { setSelectedContributors, project, - setBonusAmount + setBonusAmount, + selectedCurrency, + setSelectedCurrency } = props const [selectedContributorsIdx, setSelectedContributorsIdx] = useState([]) + const currencyInformation = selectCurrencyInformation({ + currency: project.expected_budget_currency + ? project.expected_budget_currency + : 'SATS' + }) + useEffect(() => { const contributors = project.contributors.filter((c, idx) => selectedContributorsIdx.includes(idx)) setSelectedContributors(contributors) }, [selectedContributorsIdx]) - const currencyInformation = - selectCurrencyInformation({ - currency: 'USD' - }) - const selectContributor = (idx) => { if (selectedContributorsIdx.includes(idx)) { setSelectedContributorsIdx( @@ -73,18 +76,31 @@ const SendBonusEqualy = (props) => { return (

-
+
handleBonusAmountChange(event.target.value)} /> +

diff --git a/srcv2/components/SendBonusSuccessful.js b/srcv2/components/SendBonusSuccessful.js index c3ef0770..bb2b171e 100644 --- a/srcv2/components/SendBonusSuccessful.js +++ b/srcv2/components/SendBonusSuccessful.js @@ -6,7 +6,8 @@ import { const SendBonusSuccessful = (props) => { const { - sentBonuses + sentBonuses, + selectedCurrency } = props const renderSuccessfulTransactions = (payments) => { @@ -20,11 +21,16 @@ const SendBonusSuccessful = (props) => {

- {`${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS`} -

-

- {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} + {selectedCurrency == 's ' + ? `${Intl.NumberFormat().format(Math.trunc(bp.amount))} SATS` + : `${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS` + }

+ {selectedCurrency != 's ' && +

+ {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} +

+ }
) @@ -42,10 +48,17 @@ const SendBonusSuccessful = (props) => {

- {`${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS`} + {selectedCurrency == 's ' + ? `${Intl.NumberFormat().format(Math.trunc(bp.amount))} SATS` + : `${Intl.NumberFormat().format(Math.trunc(bp.satsBonusAmount))} SATS` + }

- {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} + {selectedCurrency != 's ' && +

+ {`${Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD' }).format(Math.trunc(bp.amount))}`} +

+ }