diff --git a/src/components/App.tsx b/src/components/App.tsx index b9af1fa..ecb5c22 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -8,9 +8,10 @@ import { Navigate } from 'react-router-dom'; interface AppProps extends React.PropsWithChildren<{}> { runtimeURL: string; + scanURL: string; } -const App: React.FC = ({runtimeURL}) => { +const App: React.FC = ({ runtimeURL, scanURL }) => { const hasSelectedAWalletExtension = localStorage.getItem('walletProvider'); const [toasts, setToasts] = useState([]); @@ -28,7 +29,7 @@ const App: React.FC = ({runtimeURL}) => { : } /> - : } /> + : } />
{toasts.map(toast => ( diff --git a/src/components/Payouts.tsx b/src/components/Payouts.tsx index 78276b0..f250cd1 100644 --- a/src/components/Payouts.tsx +++ b/src/components/Payouts.tsx @@ -13,13 +13,13 @@ import './Payouts.scss'; import { formatAssets, intersperse, shortViewTxOutRef } from './Format'; import { SupportedWallet } from '@marlowe.io/wallet/browser'; -const marloweScanURL = `${process.env.MARLOWE_SCAN_URL}`; type PayoutsProps = { setAndShowToast: (title: string, message: any, isDanger: boolean) => void - runtimeURL: string + runtimeURL: string, + scanURL: string }; -const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { +const Payouts: React.FC = ({ setAndShowToast, runtimeURL, scanURL }) => { const navigate = useNavigate(); const selectedAWalletExtension = localStorage.getItem('walletProvider'); if (!selectedAWalletExtension) { navigate('/'); } @@ -37,7 +37,7 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { const [secondTabContentClassNames, setSecondTabContentClassNames] = useState('tab-pane fade d-none'); const payoutsToBeWithdrawn = availablePayouts.filter(payout => payoutIdsToBeWithdrawn.includes(unPayoutId(payout.payoutId))) - + const toggleTabContentClassNames = () => { setFirstTabContentClassNames(firstTabContentClassNames === 'tab-pane fade show active' ? 'tab-pane fade d-none' : 'tab-pane fade show active'); setSecondTabContentClassNames(secondTabContentClassNames === 'tab-pane fade d-none' ? 'tab-pane fade show active' : 'tab-pane fade d-none'); @@ -63,7 +63,7 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { setPayoutIdsToBeWithdrawn([]); setIsLoading(false); }; - + useEffect(() => { const fetchData = async () => { const runtimeLifecycleParameters: BrowserRuntimeLifecycleOptions = { @@ -89,15 +89,15 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { } fetchData() - .catch(err => - { console.log("Error", err); - const error = JSON.parse(err); - const { message } = error; - setAndShowToast( - 'Failed Retrieving Payouts Infornation', - {message}, - true) - }) + .catch(err => { + console.log("Error", err); + const error = JSON.parse(err); + const { message } = error; + setAndShowToast( + 'Failed Retrieving Payouts Infornation', + {message}, + true) + }) const intervalId = setInterval(() => { fetchData().catch(err => console.error(err)); @@ -167,7 +167,7 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { const handleWithdrawals = async () => { if (runtimeLifecycle) { - try { + try { setIsLoading(true) setAndShowToast( 'Please sign your transaction', @@ -176,17 +176,17 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => {
, false ) - + await runtimeLifecycle.payouts.withdraw(payoutsToBeWithdrawn.map(payout => payout.payoutId)) - + closeModalAndClearPayouts() setAndShowToast( 'Payouts withdrawn', Successfully withdrawn payouts., false - ) - } catch (err : any) - { console.log("Error", err); + ) + } catch (err: any) { + console.log("Error", err); const error = JSON.parse(err); const { message } = error; closeModalAndClearPayouts() @@ -198,7 +198,10 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { , true - )}}} + ) + } + } + } const payoutSelectedToBeWithdrawn = (payoutId: string) => { return payoutIdsToBeWithdrawn.includes(payoutId); @@ -271,7 +274,7 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { + href={`${scanURL}/contractView?tab=info&contractId=` + encodeURIComponent(unContractId(payout.contractId))}> {truncateString(unContractId(payout.contractId), 5, 60)} @@ -280,13 +283,13 @@ const Payouts: React.FC = ({ setAndShowToast, runtimeURL }) => { {isLoading && payoutSelectedToBeWithdrawn(unPayoutId(payout.payoutId)) ? + + Loading... + + Processing... + :