aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
index a16389709..ce4c7236d 100644
--- a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
@@ -14,7 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Amounts, TalerErrorDetail } from "@gnu-taler/taler-util";
+import { AbsoluteTime, Amounts, TalerErrorDetail, TalerProtocolTimestamp } from "@gnu-taler/taler-util";
import { TalerError } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
@@ -22,7 +22,7 @@ import * as wxApi from "../../wxApi.js";
import { Props, State } from "./index.js";
export function useComponentState(
- { talerPayPushUri }: Props,
+ { talerPayPushUri, onClose }: Props,
api: typeof wxApi,
): State {
const hook = useAsyncAsHook(async () => {
@@ -45,13 +45,18 @@ export function useComponentState(
};
}
- const { amount, peerPushPaymentIncomingId } = hook.response
+ const { amount: purseAmount, contractTerms, peerPushPaymentIncomingId } = hook.response
+
+ const amount: string = contractTerms?.amount
+ const summary: string | undefined = contractTerms?.summary
+ const expiration: TalerProtocolTimestamp | undefined = contractTerms?.purse_expiration
async function accept(): Promise<void> {
try {
const resp = await api.acceptPeerPushPayment({
peerPushPaymentIncomingId
})
+ await onClose()
} catch (e) {
if (e instanceof TalerError) {
setOperationError(e.errorDetail)
@@ -67,6 +72,11 @@ export function useComponentState(
accept: {
onClick: accept
},
+ summary,
+ expiration: expiration ? AbsoluteTime.fromTimestamp(expiration) : undefined,
+ cancel: {
+ onClick: onClose
+ },
operationError
}
}