From 76e664c9432822c4f5ba717af7f421b7cd015bf3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 4 May 2020 18:52:54 +0530 Subject: update withdrawal page when something changes --- src/webex/pages/withdraw.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/webex/pages/withdraw.tsx') diff --git a/src/webex/pages/withdraw.tsx b/src/webex/pages/withdraw.tsx index 1647a7065..5ef4376f7 100644 --- a/src/webex/pages/withdraw.tsx +++ b/src/webex/pages/withdraw.tsx @@ -28,9 +28,9 @@ import { WithdrawDetails } from "../../types/walletTypes"; import { WithdrawDetailView, renderAmount } from "../renderHtml"; import React, { useState, useEffect } from "react"; -import { getWithdrawDetails, acceptWithdrawal } from "../wxApi"; +import { getWithdrawDetails, acceptWithdrawal, onUpdateNotification } from "../wxApi"; -function NewExchangeSelection(props: { +function WithdrawalDialog(props: { talerWithdrawUri: string; }): JSX.Element { const [details, setDetails] = useState(); @@ -42,6 +42,14 @@ function NewExchangeSelection(props: { const [selecting, setSelecting] = useState(false); const [customUrl, setCustomUrl] = useState(""); const [errMsg, setErrMsg] = useState(""); + const [updateCounter, setUpdateCounter] = useState(1); + + useEffect(() => { + return onUpdateNotification(() => { + setUpdateCounter(updateCounter + 1); + }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) useEffect(() => { const fetchData = async (): Promise => { @@ -65,7 +73,7 @@ function NewExchangeSelection(props: { setDetails(d); }; fetchData(); - }, [selectedExchange, errMsg, selecting, talerWithdrawUri]); + }, [selectedExchange, errMsg, selecting, talerWithdrawUri, updateCounter]); if (errMsg) { return ( @@ -214,5 +222,5 @@ export function createWithdrawPage(): JSX.Element { if (!talerWithdrawUri) { throw Error("withdraw URI required"); } - return ; + return ; } -- cgit v1.2.3