summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-09-16 14:29:35 -0300
committerSebastian <sebasjm@gmail.com>2022-09-16 14:29:35 -0300
commit6ddb2de84245ae3914c92b2b2eb7399e7f04500e (patch)
tree425cc377daf053e5283bee6986f6f437f25d7584 /packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
parent860f10e6f004668d3109b5a1d96ddb2b26ddc2f5 (diff)
downloadwallet-core-6ddb2de84245ae3914c92b2b2eb7399e7f04500e.tar.gz
wallet-core-6ddb2de84245ae3914c92b2b2eb7399e7f04500e.tar.bz2
wallet-core-6ddb2de84245ae3914c92b2b2eb7399e7f04500e.zip
pretty
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts50
1 files changed, 31 insertions, 19 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
index ce4c7236d..d4c863608 100644
--- a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
@@ -14,7 +14,12 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { AbsoluteTime, Amounts, TalerErrorDetail, TalerProtocolTimestamp } 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";
@@ -28,15 +33,17 @@ export function useComponentState(
const hook = useAsyncAsHook(async () => {
return await api.checkPeerPushPayment({
talerUri: talerPayPushUri,
- })
- }, [])
- const [operationError, setOperationError] = useState<TalerErrorDetail | undefined>(undefined)
+ });
+ }, []);
+ const [operationError, setOperationError] = useState<
+ TalerErrorDetail | undefined
+ >(undefined);
if (!hook) {
return {
status: "loading",
error: undefined,
- }
+ };
}
if (hook.hasError) {
return {
@@ -45,24 +52,29 @@ export function useComponentState(
};
}
- const { amount: purseAmount, contractTerms, 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
+ 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()
+ peerPushPaymentIncomingId,
+ });
+ await onClose();
} catch (e) {
if (e instanceof TalerError) {
- setOperationError(e.errorDetail)
+ setOperationError(e.errorDetail);
}
- console.error(e)
- throw Error("error trying to accept")
+ console.error(e);
+ throw Error("error trying to accept");
}
}
return {
@@ -70,13 +82,13 @@ export function useComponentState(
amount: Amounts.parseOrThrow(amount),
error: undefined,
accept: {
- onClick: accept
+ onClick: accept,
},
summary,
expiration: expiration ? AbsoluteTime.fromTimestamp(expiration) : undefined,
cancel: {
- onClick: onClose
+ onClick: onClose,
},
- operationError
- }
+ operationError,
+ };
}