diff --git a/clients/banking/src/components/MerchantProfilePaymentArea.tsx b/clients/banking/src/components/MerchantProfilePaymentArea.tsx index e1fdaf144..84b3c0341 100644 --- a/clients/banking/src/components/MerchantProfilePaymentArea.tsx +++ b/clients/banking/src/components/MerchantProfilePaymentArea.tsx @@ -1,4 +1,4 @@ -import { AsyncData, Result } from "@swan-io/boxed"; +import { AsyncData, Option, Result } from "@swan-io/boxed"; import { Link } from "@swan-io/chicane"; import { useQuery } from "@swan-io/graphql-client"; import { Box } from "@swan-io/lake/src/components/Box"; @@ -13,12 +13,12 @@ import { Space } from "@swan-io/lake/src/components/Space"; import { LinkConfig } from "@swan-io/lake/src/components/VirtualizedList"; import { spacings } from "@swan-io/lake/src/constants/design"; import { nullishOrEmptyToUndefined } from "@swan-io/lake/src/utils/nullish"; -import { useCallback, useMemo, useRef, useState } from "react"; +import { useCallback, useRef, useState } from "react"; import { StyleSheet } from "react-native"; import { match, P } from "ts-pattern"; import { - MerchantPaymentFiltersInput, MerchantPaymentFragment, + MerchantPaymentMethodType, MerchantPaymentsDocument, } from "../graphql/partner"; import { t } from "../utils/i18n"; @@ -45,6 +45,12 @@ const styles = StyleSheet.create({ const PER_PAGE = 20; +const ALLOWED_PAYMENT_METHODS = new Set([ + "Card", + "SepaDirectDebitB2b", + "SepaDirectDebitCore", +]); + type Props = { params: GetRouteParams<"AccountMerchantsProfilePaymentsArea">; large: boolean; @@ -58,17 +64,9 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => { "AccountMerchantsProfilePaymentsDetails", ]); - const filters: MerchantPaymentFiltersInput = useMemo(() => { - return { - status: params.status, - search: nullishOrEmptyToUndefined(params.search), - } as const; - }, [params]); - const [data, { isLoading, reload, setVariables }] = useQuery(MerchantPaymentsDocument, { merchantProfileId, first: PER_PAGE, - filters, }); const panelRef = useRef(null); @@ -100,16 +98,29 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => { const search = nullishOrEmptyToUndefined(params.search); + const shouldEnableNewButton = data + .toOption() + .flatMap(result => result.toOption()) + .flatMap(({ merchantProfile }) => Option.fromNullable(merchantProfile)) + .map(merchant => { + const paymentMethods = merchant.merchantPaymentMethods ?? []; + return paymentMethods.some( + paymentMethod => + ALLOWED_PAYMENT_METHODS.has(paymentMethod.type) && + paymentMethod.statusInfo.status === "Enabled", + ); + }); + return ( <> {!large && ( { }) } > - {t("merchantProfile.payments.button.new")} //TODO + {t("merchantProfile.paymentLink.button.new")} @@ -135,11 +146,11 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => { {large && ( <> { {/* // TODO USE FILL */} - - {} - // Router.push("AccountMerchantsProfilePaymentLinkList", { - // new: "true", - // accountMembershipId, - // merchantProfileId, - // }) - } - > - {t("merchantProfile.payments.button.refund")} - - - )} diff --git a/clients/banking/src/components/MerchantProfilePaymentDetail.tsx b/clients/banking/src/components/MerchantProfilePaymentDetail.tsx index 07e290f8d..c9120f898 100644 --- a/clients/banking/src/components/MerchantProfilePaymentDetail.tsx +++ b/clients/banking/src/components/MerchantProfilePaymentDetail.tsx @@ -194,19 +194,18 @@ export const MerchantProfilePaymentDetail = ({ paymentLinkId, paymentId, large } )} /> - ( - TODO - {/* {formatCurrency( - Number(payment.balance.availableToCancel.value), - payment.balance.availableToCancel.currency, - )} */} + {formatCurrency( + Number(payment.balance.chargebackBalance.value), + payment.balance.chargebackBalance.currency, + )} )} - /> + /> */}