From e4ea2019430fb3c4b788f67427fbd743f604b7e5 Mon Sep 17 00:00:00 2001
From: Sebastian
Date: Sat, 14 May 2022 18:09:33 -0300
Subject: feat: awaiting refund
---
.../taler-wallet-webextension/src/cta/Refund.tsx | 70 ++++++++++++++++------
1 file changed, 51 insertions(+), 19 deletions(-)
(limited to 'packages/taler-wallet-webextension/src/cta/Refund.tsx')
diff --git a/packages/taler-wallet-webextension/src/cta/Refund.tsx b/packages/taler-wallet-webextension/src/cta/Refund.tsx
index f69fc4311..5387a1782 100644
--- a/packages/taler-wallet-webextension/src/cta/Refund.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Refund.tsx
@@ -34,7 +34,6 @@ import { LoadingError } from "../components/LoadingError.js";
import { LogoHeader } from "../components/LogoHeader.js";
import { Part } from "../components/Part.js";
import {
- Button,
ButtonSuccess,
SubTitle,
WalletAction,
@@ -99,6 +98,12 @@ export function View({ state }: ViewProps): VNode {
Total to refund}
+ text={}
+ kind="negative"
+ />
+ Refunded}
text={}
kind="negative"
/>
@@ -108,9 +113,9 @@ export function View({ state }: ViewProps): VNode {
) : undefined}
- */}
);
}
@@ -128,6 +133,14 @@ export function View({ state }: ViewProps): VNode {
this refund is already accepted.
+
+ Total to refunded}
+ text={}
+ kind="negative"
+ />
+
);
}
@@ -150,9 +163,23 @@ export function View({ state }: ViewProps): VNode {
Total to refund}
+ title={Order amount}
text={}
- kind="negative"
+ kind="neutral"
+ />
+ {Amounts.isNonZero(state.granted) && (
+ Already refunded}
+ text={}
+ kind="neutral"
+ />
+ )}
+ Refund offered}
+ text={}
+ kind="positive"
/>
{state.products && state.products.length ? (
@@ -164,9 +191,6 @@ export function View({ state }: ViewProps): VNode {
Confirm refund
-
);
@@ -184,6 +208,8 @@ interface Ready {
merchantName: string;
products: Product[] | undefined;
amount: AmountJson;
+ awaitingAmount: AmountJson;
+ granted: AmountJson;
accept: ButtonHandler;
ignore: ButtonHandler;
orderId: string;
@@ -199,7 +225,8 @@ interface InProgress {
merchantName: string;
products: Product[] | undefined;
amount: AmountJson;
- progress: number;
+ awaitingAmount: AmountJson;
+ granted: AmountJson;
}
interface Completed {
status: "completed";
@@ -207,6 +234,7 @@ interface Completed {
merchantName: string;
products: Product[] | undefined;
amount: AmountJson;
+ granted: AmountJson;
}
export function useComponentState(
@@ -253,25 +281,27 @@ export function useComponentState(
};
}
- const pending = refund.total > refund.applied + refund.failed;
- const completed = refund.total > 0 && refund.applied === refund.total;
+ const awaitingAmount = Amounts.parseOrThrow(refund.awaiting);
- if (pending) {
+ if (Amounts.isZero(awaitingAmount)) {
return {
- status: "in-progress",
+ status: "completed",
hook: undefined,
- amount: Amounts.parseOrThrow(info.response.refund.amountEffectivePaid),
+ amount: Amounts.parseOrThrow(info.response.refund.effectivePaid),
+ granted: Amounts.parseOrThrow(info.response.refund.granted),
merchantName: info.response.refund.info.merchant.name,
products: info.response.refund.info.products,
- progress: (refund.applied + refund.failed) / refund.total,
};
}
- if (completed) {
+ if (refund.pending) {
return {
- status: "completed",
+ status: "in-progress",
hook: undefined,
- amount: Amounts.parseOrThrow(info.response.refund.amountEffectivePaid),
+ awaitingAmount,
+ amount: Amounts.parseOrThrow(info.response.refund.effectivePaid),
+ granted: Amounts.parseOrThrow(info.response.refund.granted),
+
merchantName: info.response.refund.info.merchant.name,
products: info.response.refund.info.products,
};
@@ -280,7 +310,9 @@ export function useComponentState(
return {
status: "ready",
hook: undefined,
- amount: Amounts.parseOrThrow(info.response.refund.amountEffectivePaid),
+ amount: Amounts.parseOrThrow(info.response.refund.effectivePaid),
+ granted: Amounts.parseOrThrow(info.response.refund.granted),
+ awaitingAmount,
merchantName: info.response.refund.info.merchant.name,
products: info.response.refund.info.products,
orderId: info.response.refund.info.orderId,
--
cgit v1.2.3