Skip to content

Commit

Permalink
Feedback + update schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrine-ds committed Dec 24, 2024
1 parent f08ec2e commit 18b7bac
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 105 deletions.
50 changes: 19 additions & 31 deletions clients/banking/src/components/MerchantProfilePaymentArea.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Array, AsyncData, Option, 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 { AutoWidthImage } from "@swan-io/lake/src/components/AutoWidthImage";
Expand All @@ -19,7 +19,7 @@ import { useDisclosure } from "@swan-io/lake/src/hooks/useDisclosure";
import { isNotNullish, nullishOrEmptyToUndefined } from "@swan-io/lake/src/utils/nullish";
import { useCallback, useMemo, useRef, useState } from "react";
import { StyleSheet } from "react-native";
import { match, P } from "ts-pattern";
import { isMatching, match, P } from "ts-pattern";
import {
MerchantPaymentFragment,
MerchantPaymentMethodType,
Expand Down Expand Up @@ -152,25 +152,17 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {

const filters: MerchantPaymentFilters = useMemo(() => {
return {
paymentMethod: isNotNullish(params.paymentMethod)
? Array.filterMap(params.paymentMethod, item =>
match(item)
.with("Card", "Check", "DirectDebit", value => Option.Some(value))
.otherwise(() => Option.None()),
)
: undefined,
status: isNotNullish(params.status)
? Array.filterMap(params.status, item =>
match(item)
.with("Authorized", "Captured", "Initiated", "Rejected", item => Option.Some(item))
.otherwise(() => Option.None()),
)
: undefined,
paymentMethod: params.paymentMethod?.filter(
isMatching(P.union("Card", "Check", "DirectDebit")),
),
status: params.status?.filter(
isMatching(P.union("Authorized", "Captured", "Initiated", "Rejected")),
),
} as const;
}, [params.paymentMethod, params.status]);

const search = nullishOrEmptyToUndefined(params.search);
const hasSearch =
const hasSearchOrFilters =
isNotNullish(search) || isNotNullish(params.paymentMethod) || isNotNullish(params.status);

const [data, { isLoading, reload, setVariables }] = useQuery(MerchantPaymentsDocument, {
Expand Down Expand Up @@ -216,10 +208,9 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
[accountMembershipId, merchantProfileId],
);

const activePaymentLinkId =
route?.name === "AccountMerchantsProfilePaymentsDetails"
? (route.params.paymentId ?? null)
: null;
const activePaymentLinkId = match(route)
.with({ name: "AccountMerchantsProfilePaymentsDetails" }, ({ params }) => params.paymentId)
.otherwise(() => null);

const { shouldEnableCheckTile, shouldEnablePaymentLinkTile } = useMemo(() => {
const enabledPaymentMethods = data
Expand All @@ -228,17 +219,14 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
.flatMap(({ merchantProfile }) =>
Option.fromNullable(merchantProfile?.merchantPaymentMethods),
)
.map(methods => methods.filter(method => method.statusInfo.status === "Enabled"));
.map(methods => methods.filter(method => method.statusInfo.status === "Enabled"))
.getOr([]);

return {
shouldEnableCheckTile: enabledPaymentMethods
.map(methods => methods.some(method => method.type === "Check"))
.getOr(false),

shouldEnablePaymentLinkTile: enabledPaymentMethods
.map(methods => methods.some(method => ALLOWED_PAYMENT_METHODS.has(method.type)))

.getOr(false),
shouldEnableCheckTile: enabledPaymentMethods.some(method => method.type === "Check"),
shouldEnablePaymentLinkTile: enabledPaymentMethods.some(method =>
ALLOWED_PAYMENT_METHODS.has(method.type),
),
};
}, [data]);

Expand Down Expand Up @@ -348,7 +336,7 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
}
}}
renderEmptyList={() =>
hasSearch || !canCreateMerchantPaymentLinks ? (
hasSearchOrFilters || !canCreateMerchantPaymentLinks ? (
<EmptyView
icon="lake-transfer"
borderedIcon={true}
Expand Down
57 changes: 28 additions & 29 deletions clients/banking/src/components/MerchantProfilePaymentList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionCell, Cell, CopyableTextCell, HeaderCell } from "@swan-io/lake/src/components/Cells";
import { Cell, CopyableTextCell, HeaderCell } from "@swan-io/lake/src/components/Cells";
import { Icon } from "@swan-io/lake/src/components/Icon";
import { LakeText } from "@swan-io/lake/src/components/LakeText";
import {
Expand Down Expand Up @@ -46,15 +46,18 @@ const PaymentCell = ({ payment }: { payment: MerchantPaymentFragment }) => {
return (
<View style={[styles.cell, styles.paddedCell]}>
<View style={styles.transactionSummary}>
{isNullishOrEmpty(payment.label) ? (
<LakeText variant="smallRegular" color={colors.gray[500]}>
{"-"}
</LakeText>
) : (
<LakeText variant="smallRegular" color={colors.gray[900]} style={styles.overflowingText}>
{payment.label}
</LakeText>
)}
<LakeText variant="smallRegular" color={colors.gray[900]} style={styles.overflowingText}>
{match(payment.paymentMethod.type)
.with("Card", () => t("merchantProfile.paymentLink.paymentMethod.card"))
.with("Check", () => t("merchantProfile.paymentLink.paymentMethod.check"))
.with("InternalDirectDebitB2b", "InternalDirectDebitStandard", () =>
t("merchantProfile.paymentLink.paymentMethod.internalDirectDebit"),
)
.with("SepaDirectDebitB2b", "SepaDirectDebitCore", () =>
t("merchantProfile.paymentLink.paymentMethod.sepaDirectDebit"),
)
.exhaustive()}
</LakeText>

<LakeText variant="regular" color={colors.gray[900]}>
{formatCurrency(Number(payment.amount.value), payment.amount.currency)}
Expand Down Expand Up @@ -121,7 +124,7 @@ const columns: ColumnConfig<MerchantPaymentFragment, ExtraInfo>[] = [
},
{
id: "externalReference",
width: 200,
width: "grow",
title: t("merchantProfile.payments.externalReference"),
renderTitle: ({ title }) => <HeaderCell text={title} />,
renderCell: ({ item }) =>
Expand Down Expand Up @@ -167,7 +170,7 @@ const columns: ColumnConfig<MerchantPaymentFragment, ExtraInfo>[] = [
{
id: "amount",
width: 150,
title: t("transactions.amount"),
title: t("merchantProfile.payments.list.amount"),
renderTitle: ({ title }) => <HeaderCell text={title} align="right" />,
renderCell: ({ item }) => (
<Cell align="right">
Expand All @@ -184,30 +187,28 @@ const columns: ColumnConfig<MerchantPaymentFragment, ExtraInfo>[] = [
renderTitle: () => null,
renderCell: ({ isHovered }) => (
<Cell align="right">
<ActionCell>
<Icon
name="chevron-right-filled"
color={isHovered ? colors.gray[900] : colors.gray[500]}
size={16}
/>
</ActionCell>
<Icon
name="chevron-right-filled"
color={isHovered ? colors.gray[900] : colors.gray[500]}
size={16}
/>
</Cell>
),
},
];

const smallColumns: ColumnConfig<MerchantPaymentFragment, ExtraInfo>[] = [
{
id: "label",
id: "paymentMethod",
width: "grow",
title: t("merchantProfile.paymentLink.list.label"),
title: t("merchantProfile.payments.paymentMethod"),
renderTitle: () => null,
renderCell: ({ item }) => <PaymentCell payment={item} />,
},
{
id: "status",
width: 120,
title: t("merchantProfile.paymentLink.list.status"),
title: t("merchantProfile.payments.status"),
renderTitle: ({ title }) => <HeaderCell text={title} align="right" />,
renderCell: ({ item }) => (
<Cell align="right">
Expand Down Expand Up @@ -235,13 +236,11 @@ const smallColumns: ColumnConfig<MerchantPaymentFragment, ExtraInfo>[] = [
renderTitle: () => null,
renderCell: ({ isHovered }) => (
<Cell align="right">
<ActionCell>
<Icon
name="chevron-right-filled"
color={isHovered ? colors.gray[700] : colors.gray[200]}
size={16}
/>
</ActionCell>
<Icon
name="chevron-right-filled"
color={isHovered ? colors.gray[700] : colors.gray[200]}
size={16}
/>
</Cell>
),
},
Expand Down
73 changes: 41 additions & 32 deletions scripts/graphql/dist/partner-admin-schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ type AccountHolder {
"""Account holder onboarding"""
onboarding: Onboarding

"""Account holder risk info"""
riskInfo: AccountHolderRiskInfo

"""
A list of Payment Mandates for an account holder.
Expand Down Expand Up @@ -432,6 +435,13 @@ type AccountHolderConnection implements Connection {
edges: [AccountHolderEdge!]!
}

enum AccountHolderDueDiligenceLevel {
Simplified
Common
Enhanced
Refused
}

"""Implements the Relay Edge interface."""
type AccountHolderEdge implements Edge {
"""Opaque identifier pointing to this node in the pagination mechanism"""
Expand Down Expand Up @@ -570,6 +580,12 @@ type AccountHolderRefusedVerificationStatusInfo implements AccountHolderVerifica
reason: String!
}

type AccountHolderRiskInfo {
amlRiskLevel: AmlRiskLevel
amlScore: Int
dueDiligenceLevel: AccountHolderDueDiligenceLevel
}

"""Account holder status."""
enum AccountHolderStatus {
"""When the account holder is enabled."""
Expand Down Expand Up @@ -719,8 +735,11 @@ type AccountMembership {
"""List of accepted identification level"""
acceptedIdentificationLevels: [IdentificationLevel]!

"""Recommended identification level"""
recommendedIdentificationLevel: IdentificationLevel!
"""
Recommended identification level
@deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")
"""
recommendedIdentificationLevel: IdentificationLevel! @deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")

"""
Indicate if the identity bound to the account membership has required identification level
Expand Down Expand Up @@ -1194,6 +1213,13 @@ type AllowedValue {
name: String!
}

enum AmlRiskLevel {
Low
Medium
High
TooHigh
}

"""Amount with its currency"""
type Amount {
"""currency"""
Expand Down Expand Up @@ -5654,8 +5680,11 @@ type Onboarding {
"""List of accepted identification level for the legal representative"""
legalRepresentativeAcceptedIdentificationLevels: [IdentificationLevel]!

"""Recommended identification level for the legal representative"""
legalRepresentativeRecommendedIdentificationLevel: IdentificationLevel!
"""
Recommended identification level for the legal representative
@deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")
"""
legalRepresentativeRecommendedIdentificationLevel: IdentificationLevel! @deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")
}

"""The onboarding could be for an Individual or a company"""
Expand Down Expand Up @@ -5861,8 +5890,11 @@ type OnboardingInfo {
"""List of accepted identification level for the legal representative"""
legalRepresentativeAcceptedIdentificationLevels: [IdentificationLevel]!

"""Recommended identification level for the legal representative"""
legalRepresentativeRecommendedIdentificationLevel: IdentificationLevel!
"""
Recommended identification level for the legal representative
@deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")
"""
legalRepresentativeRecommendedIdentificationLevel: IdentificationLevel! @deprecated(reason: "Please use the `identificationLevel=Auto` query parameter when building your Swan OAuth2 URLs. [announcement](https://docs.swan.io/changelog/28-november-2024/)")

"""Swan TCU URL"""
tcuUrl: String!
Expand Down Expand Up @@ -8543,35 +8575,9 @@ union SimulateOutgoingCardAuthorizationPayload = SimulateOutgoingCardAuthorizati
"""Reject payload type"""
type SimulateOutgoingCardAuthorizationRejectPayload {
transactionId: ID!
reason: SimulateOutgoingCardAuthorizationRejectPayloadReason! @deprecated(reason: "Use rejectedReason instead")
rejectedReason: String!
}

"""Reject payload reason"""
enum SimulateOutgoingCardAuthorizationRejectPayloadReason {
AccountSuspended
CardExpired
CardSuspended
InsufficientFunds
NotHeld
PartnerRefused
PartnerTechnicalErrorOccurred
PeriodAmountLimitExceeded
SwanRefused
TransactionTypeNotAllowed
ThreeDsError
PeriodTransactionNumberLimitExceeded
MissingExpirationDate
MissingPin
DigitalWalletDeactivated
DigitalWalletEnrolmentInvalid
DigitalWalletTokenInvalid
DigitalWalletRefusal
DigitalWalletSuspended
InvalidAmount
CardholderCancellation
}

"""Input to simulate a release of a card authorization"""
input SimulateOutgoingCardAuthorizationReleaseInput {
transactionId: ID!
Expand Down Expand Up @@ -10210,6 +10216,9 @@ type User {
"""birth city"""
birthCity: String

"""birth country"""
birthCountry: CCA3

"""the methods used to authenticate this user"""
authenticators: [Authenticator!]

Expand Down
Loading

0 comments on commit 18b7bac

Please sign in to comment.