Skip to content

Commit

Permalink
v3.0.4: fix admin preview of the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Dec 1, 2024
1 parent 02d22c0 commit d7cff80
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 39 deletions.
2 changes: 1 addition & 1 deletion block.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"category": "widgets",
"description": "Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…",
"keywords": [ "payments", "crypto", "web3", "DePay", "USDC" ],
"version": "3.0.3",
"version": "3.0.4",
"textdomain": "depay-payments",
"example": {},
"editorScript": "depay-payments-script",
Expand Down
2 changes: 1 addition & 1 deletion core/includes/assets/js/admin.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions depay-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: DePay for Wordpress
* Plugin URI: https://depay.com/plugins/wordpress
* Description: Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…
* Version: 3.0.3
* Version: 3.0.4
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Author: DePay
Expand All @@ -29,7 +29,7 @@
define( 'DEPAYPAYMENTS_NAME', 'DePay for Wordpress' );

// Plugin version
define( 'DEPAYPAYMENTS_VERSION', '3.0.3' );
define( 'DEPAYPAYMENTS_VERSION', '3.0.4' );

// Plugin Root File
define( 'DEPAYPAYMENTS_PLUGIN_FILE', __FILE__ );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-wordpress-depay",
"moduleName": "WordpressDePayPayments",
"version": "3.0.3",
"version": "3.0.4",
"description": "Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…",
"main": "./dist/umd/index.js",
"module": "./dist/esm/index.js",
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: depayfi
Tags: web3, crypto, payments, DePay, USDC
Requires at least: 5.0
Tested up to: 6.7
Stable tag: 3.0.3
Stable tag: 3.0.4
Requires PHP: 5.6
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -70,6 +70,9 @@ Start for free. Pay-as-you-go 1.5% per transaction.

== Changelog ==

= 2024-12-1 - v3.0.4 =
* fix admin preview of the widget

= 2024-12-1 - v3.0.3 =
* fix block configuration amountType

Expand Down
40 changes: 7 additions & 33 deletions src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,14 @@

useEffect(()=>{

if(amount === 'fix') {

LocalCurrency.Currency.rate({ from: amountCurrency || 'USD', to: 'USD' }).then((rate)=>{
setUsdValue((fixAmount/rate).toFixed(2))
})
LocalCurrency.Currency.rate({ from: amountCurrency || 'USD', to: 'USD' }).then((rate)=>{
setUsdValue((fixAmount/rate).toFixed(2))
})

LocalCurrency.Currency.rate({ from: amountCurrency || 'USD', to: (displayedCurrency === 'local') ? undefined : displayedCurrency }).then((rate)=>{
setDisplayedCurrencyExample(new LocalCurrency.Currency({ amount: fixAmount/rate, code: (displayedCurrency === 'local') ? undefined : displayedCurrency }).toString())
})
LocalCurrency.Currency.rate({ from: amountCurrency || 'USD', to: (displayedCurrency === 'local') ? undefined : displayedCurrency }).then((rate)=>{
setDisplayedCurrencyExample(new LocalCurrency.Currency({ amount: fixAmount/rate, code: (displayedCurrency === 'local') ? undefined : displayedCurrency }).toString())
})

} else { // free

setDisplayedCurrencyExample(new LocalCurrency.Currency({ amount: startValue || 1, code: (displayedCurrency === 'local') ? undefined : displayedCurrency }).toString())

if(displayedCurrency === 'local' || displayedCurrency === undefined || displayedCurrency?.length < 3) {
LocalCurrency.Currency.rate({ from: new LocalCurrency.Currency({ amount: 0 }).code, to: 'USD' }).then((rate)=>{
setUsdValue(((startValue || 1)/rate).toFixed(2))
})
} else {
LocalCurrency.Currency.rate({
from: 'USD',
to: displayedCurrency?.length >= 2 ? displayedCurrency : undefined,
}).then((rate)=>{
setUsdValue(((startValue || 1)*rate).toFixed(2))
})
}
}
}, [displayedCurrency, startValue, amount, fixAmount, amountCurrency])

if(!settingsAreLoaded) { return null }
Expand Down Expand Up @@ -405,17 +386,10 @@
</div>
</div>
<div className="widget-example"><div className="ReactDialog ReactDialogOpen"><div className="ReactDialogRow"><div className="ReactDialogCell"><div className="ReactDialogStack active forward"><div className="ReactDialogStackRow"><div className="ReactDialogStackCell"><div className="ReactDialogAnimation"><div className="Dialog"><div className="DialogHeader"><div className="DialogHeaderTitle"><div className="PaddingTopS PaddingLeftM PaddingRightM"><div className="FontSizeL TextLeft">Payment</div></div></div><div className="DialogHeaderActionRight PaddingTopS PaddingLeftS PaddingRightS"><button className="ButtonCircular" title="Close dialog"><svg className="CloseIcon Icon" height="24" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg></button></div></div><div className="DialogBody"><div className="PaddingLeftM PaddingRightM PaddingBottomXS">
{
amount === 'free' &&
<div className="Card" title="Change amount"><div className="CardBody"><div className="CardBodyWrapper"><div className="CardTitle">Amount</div><div className="CardText"><div className="TokenAmountRow"><span className="TokenAmountCell">{ displayedCurrencyExample }</span></div></div></div></div><div className="CardAction"><svg className="ChevronRight Icon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" fill-rule="evenodd" stroke-width="1"></path></svg></div></div>
}
<div className="Card" title="Change payment"><div className="CardImage"><img className="js-widget-payment-example-image" src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png"/></div><div className="CardBody"><div className="CardBodyWrapper"><h2 className="CardText">

<div className="TokenAmountRow"><span className="TokenSymbolCell js-widget-example-symbol">USDT</span><span className="TokenAmountCell js-widget-example-amount">{usdValue}</span></div>
{
amount === 'fix' &&
<div class="TokenAmountRow small grey"><span class="TokenSymbolCell">{ displayedCurrencyExample }</span></div>
}
<div class="TokenAmountRow small grey"><span class="TokenSymbolCell">{ displayedCurrencyExample }</span></div>
</h2></div></div><div className="CardAction"><svg className="ChevronRight Icon" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" fill-rule="evenodd" stroke-width="1"></path></svg></div></div></div></div><div className="DialogFooter"><div className="PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"><div><button className="ButtonPrimary" style={{ color: widgetButtonText, backgroundColor: widgetPrimary, borderRadius: `${widgetButtonRadius}px` }}>Pay</button></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
</td>
Expand Down

0 comments on commit d7cff80

Please sign in to comment.