Skip to content

Commit

Permalink
Remove direct debit from transfer list (#492)
Browse files Browse the repository at this point in the history
* Remove direct debit from transfer list

Closes FRONT-795

* Remove unused
  • Loading branch information
bloodyowl authored Dec 12, 2023
1 parent 7a48264 commit e46cd92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
51 changes: 11 additions & 40 deletions clients/banking/src/components/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { match } from "ts-pattern";
import { ErrorView } from "../components/ErrorView";
import { TransactionDetail } from "../components/TransactionDetail";
import { TransactionList } from "../components/TransactionList";
import { PaymentProduct, TransactionListPageDocument } from "../graphql/partner";
import { TransactionListPageDocument } from "../graphql/partner";
import { t } from "../utils/i18n";
import { Router } from "../utils/routes";
import {
Expand Down Expand Up @@ -50,7 +50,6 @@ type Props = {
params: {
isAfterUpdatedAt?: string | undefined;
isBeforeUpdatedAt?: string | undefined;
paymentProduct?: string[] | undefined;
search?: string | undefined;
transactionStatus?: string[] | undefined;
};
Expand All @@ -63,14 +62,6 @@ const DEFAULT_STATUSES = [
"Rejected" as const,
];

const DEFAULT_PRODUCTS = [
"SEPACreditTransfer" as const,
"InternalCreditTransfer" as const,
"InternationalCreditTransfer" as const,
"SEPADirectDebit" as const,
"InternalDirectDebit" as const,
];

export const TransferList = ({
accountId,
accountMembershipId,
Expand All @@ -83,13 +74,7 @@ export const TransferList = ({
includeRejectedWithFallback: false,
isAfterUpdatedAt: params.isAfterUpdatedAt,
isBeforeUpdatedAt: params.isBeforeUpdatedAt,
paymentProduct: isNotNullish(params.paymentProduct)
? Array.filterMap(params.paymentProduct, item =>
match(item)
.with("CreditTransfer", "DirectDebit", value => Option.Some(value))
.otherwise(() => Option.None()),
)
: undefined,
paymentProduct: undefined,
search: params.search,
status: isNotNullish(params.transactionStatus)
? Array.filterMap(params.transactionStatus, item =>
Expand All @@ -101,32 +86,17 @@ export const TransferList = ({
)
: undefined,
} as const;
}, [
params.isAfterUpdatedAt,
params.isBeforeUpdatedAt,
params.paymentProduct,
params.search,
params.transactionStatus,
]);
}, [params.isAfterUpdatedAt, params.isBeforeUpdatedAt, params.search, params.transactionStatus]);

const hasFilters = Object.values(filters).some(isNotNullish);

const paymentProduct = useMemo(() => {
const actualPaymentProduct: PaymentProduct[] = [];
filters.paymentProduct?.forEach(item => {
const items = match(item)
.returnType<PaymentProduct[]>()
.with("CreditTransfer", () => [
"SEPACreditTransfer",
"InternalCreditTransfer",
"InternationalCreditTransfer",
])
.with("DirectDebit", () => ["SEPADirectDebit", "InternalDirectDebit"])
.otherwise(() => []);
actualPaymentProduct.push(...items);
});
return actualPaymentProduct.length > 0 ? actualPaymentProduct : DEFAULT_PRODUCTS;
}, [filters]);
return [
"SEPACreditTransfer" as const,
"InternalCreditTransfer" as const,
"InternationalCreditTransfer" as const,
];
}, []);

const { data, nextData, reload, setAfter } = useUrqlPaginatedQuery(
{
Expand Down Expand Up @@ -178,12 +148,13 @@ export const TransferList = ({
}
onRefresh={reload}
large={large}
available={["isAfterUpdatedAt", "isBeforeUpdatedAt", "status"]}
filtersDefinition={{
...defaultFiltersDefinition,
paymentProduct: {
...defaultFiltersDefinition.paymentProduct,
items: defaultFiltersDefinition.paymentProduct.items.filter(({ value }) =>
["CreditTransfer", "DirectDebit"].includes(value),
["CreditTransfer"].includes(value),
),
},
}}
Expand Down
2 changes: 1 addition & 1 deletion clients/banking/src/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const routes = {

...createGroup("Payments", "/payments?:standingOrder&:consentId&:status", {
Area: "/*",
Root: "/?:isAfterUpdatedAt&:isBeforeUpdatedAt&:paymentProduct[]&:search&:transactionStatus[]",
Root: "/?:isAfterUpdatedAt&:isBeforeUpdatedAt&:search&:transactionStatus[]",
New: "/new?:type",
RecurringTransferList: "/recurring-transfer/list",
RecurringTransferNew: "/recurring-transfer/new",
Expand Down

0 comments on commit e46cd92

Please sign in to comment.