Skip to content

Commit

Permalink
Apply recommendedIdentificationLevel deprecation (#1087)
Browse files Browse the repository at this point in the history
Identification are now less relevant but let's keep the logic for
**not** showing the "Identify" button when the last identification is
processing. That avoids a deceptive effect.
  • Loading branch information
bloodyowl authored Feb 4, 2025
1 parent 2a86255 commit a0fb2ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 43 deletions.
14 changes: 7 additions & 7 deletions clients/banking/src/components/AccountArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type Props = {
accountMembership: NonNullable<AccountAreaQuery["accountMembership"]>;
user: NonNullable<AccountAreaQuery["user"]>;
projectInfo: NonNullable<AccountAreaQuery["projectInfo"]>;
lastRelevantIdentification: Option<IdentificationFragment>;
lastIdentification: Option<IdentificationFragment>;
shouldDisplayIdVerification: boolean;
requireFirstTransfer: boolean;
activationTag: AccountActivationTag;
Expand All @@ -169,7 +169,7 @@ export const AccountArea = ({
projectInfo,
user,
activationTag,
lastRelevantIdentification,
lastIdentification,
shouldDisplayIdVerification,
requireFirstTransfer,
reload,
Expand Down Expand Up @@ -458,7 +458,7 @@ export const AccountArea = ({
<AccountActivationPage
requireFirstTransfer={requireFirstTransfer}
hasRequiredIdentificationLevel={hasRequiredIdentificationLevel}
lastRelevantIdentification={lastRelevantIdentification}
lastIdentification={lastIdentification}
accentColor={accentColor}
accountMembershipId={accountMembershipId}
additionalInfo={additionalInfo}
Expand All @@ -474,7 +474,7 @@ export const AccountArea = ({
account?.balances?.available.value != null
? Number(account?.balances?.available.value)
: null,
lastRelevantIdentification: lastRelevantIdentification.map(
lastIdentification: lastIdentification.map(
getIdentificationLevelStatusInfo,
),
})
Expand Down Expand Up @@ -540,7 +540,7 @@ export const AccountArea = ({
idVerifiedMatchError: true,
},
},
lastRelevantIdentification: Option.P.Some({ status: "Pending" }),
lastIdentification: Option.P.Some({ status: "Pending" }),
},
() => (
<ResponsiveContainer breakpoint={breakpoints.large}>
Expand Down Expand Up @@ -833,7 +833,7 @@ export const AccountArea = ({
permissions.canReadAccountDetails ? (
<AccountActivationPage
hasRequiredIdentificationLevel={hasRequiredIdentificationLevel}
lastRelevantIdentification={lastRelevantIdentification}
lastIdentification={lastIdentification}
requireFirstTransfer={requireFirstTransfer}
accentColor={accentColor}
accountMembershipId={accountMembershipId}
Expand Down Expand Up @@ -867,7 +867,7 @@ export const AccountArea = ({

{largeViewport ? null : (
<NavigationTabBar
identificationStatusInfo={lastRelevantIdentification.map(
identificationStatusInfo={lastIdentification.map(
getIdentificationLevelStatusInfo,
)}
hasRequiredIdentificationLevel={hasRequiredIdentificationLevel}
Expand Down
35 changes: 16 additions & 19 deletions clients/banking/src/components/AccountMembershipArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useCallback, useEffect, useMemo } from "react";
import { match, P } from "ts-pattern";
import {
AccountAreaDocument,
LastRelevantIdentificationDocument,
LastIdentificationDocument,
UpdateAccountLanguageDocument,
} from "../graphql/partner";
import { PermissionProvider } from "../hooks/usePermissions";
Expand All @@ -24,8 +24,8 @@ const COOKIE_REFRESH_INTERVAL = 30000; // 30s

export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
const [data, { query }] = useDeferredQuery(AccountAreaDocument);
const [lastRelevantIdentification, { query: queryLastRelevantIdentification }] = useDeferredQuery(
LastRelevantIdentificationDocument,
const [lastIdentification, { query: queryLastIdentification }] = useDeferredQuery(
LastIdentificationDocument,
);

const [updateAccountLanguage] = useMutation(UpdateAccountLanguageDocument);
Expand All @@ -45,7 +45,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
Router.replace("ProjectRootRedirect");
}

const { account, recommendedIdentificationLevel, legalRepresentative } = accountMembership;
const { account, legalRepresentative } = accountMembership;
const { id: accountId, language, IBAN, bankDetails } = account ?? {};

if (
Expand All @@ -62,21 +62,19 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
accountMembership.hasRequiredIdentificationLevel ?? undefined;

if (hasRequiredIdentificationLevel === false) {
return queryLastRelevantIdentification({
return queryLastIdentification({
accountMembershipId,
identificationProcess: recommendedIdentificationLevel,
});
}
});

return () => request.cancel();
}, [accountMembershipId, query, queryLastRelevantIdentification, updateAccountLanguage]);
}, [accountMembershipId, query, queryLastIdentification, updateAccountLanguage]);

const reload = useCallback(() => {
query({ accountMembershipId }).tapOk(({ accountMembership }) => {
const hasRequiredIdentificationLevel =
accountMembership?.hasRequiredIdentificationLevel ?? undefined;
const recommendedIdentificationLevel = accountMembership?.recommendedIdentificationLevel;

const accountId = accountMembership?.account?.id;
const language = accountMembership?.account?.language;
Expand All @@ -88,13 +86,12 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
}

if (hasRequiredIdentificationLevel === false) {
queryLastRelevantIdentification({
queryLastIdentification({
accountMembershipId,
identificationProcess: recommendedIdentificationLevel,
});
}
});
}, [accountMembershipId, query, queryLastRelevantIdentification, updateAccountLanguage]);
}, [accountMembershipId, query, queryLastIdentification, updateAccountLanguage]);

// Call API to extend cookie TTL
useEffect(() => {
Expand All @@ -111,7 +108,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
() =>
data
.flatMapOk(data =>
match(lastRelevantIdentification)
match(lastIdentification)
.with(AsyncData.P.Loading, () => AsyncData.Loading())
.with(AsyncData.P.Done(Result.P.Error(P.select())), error =>
AsyncData.Done(Result.Error(error)),
Expand All @@ -120,7 +117,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
AsyncData.Done(
Result.Ok({
data,
lastRelevantIdentification: lastRelevantIdentification
lastIdentification: lastIdentification
.toOption()
.flatMap(result => result.toOption())
.flatMap(value =>
Expand All @@ -132,7 +129,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
),
),
)
.mapOkToResult(({ data, lastRelevantIdentification }) => {
.mapOkToResult(({ data, lastIdentification }) => {
return match(data)
.with(
{
Expand Down Expand Up @@ -187,7 +184,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
documentCollectionStatus,
documentCollectMode,
hasTransactions,
identificationStatusInfo: lastRelevantIdentification.map(
identificationStatusInfo: lastIdentification.map(
getIdentificationLevelStatusInfo,
),
accountHolderType: account?.holder.info.__typename,
Expand Down Expand Up @@ -273,7 +270,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
accountMembership,
user,
projectInfo,
lastRelevantIdentification,
lastIdentification,
shouldDisplayIdVerification,
requireFirstTransfer,

Expand All @@ -283,7 +280,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
)
.otherwise(() => Result.Error(undefined));
}),
[data, lastRelevantIdentification],
[data, lastIdentification],
);

return match(info)
Expand All @@ -297,7 +294,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
projectInfo,
shouldDisplayIdVerification,
requireFirstTransfer,
lastRelevantIdentification,
lastIdentification,
activationTag,
}) => (
<PermissionProvider
Expand All @@ -313,7 +310,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
accountMembership={accountMembership}
projectInfo={projectInfo}
shouldDisplayIdVerification={shouldDisplayIdVerification}
lastRelevantIdentification={lastRelevantIdentification}
lastIdentification={lastIdentification}
requireFirstTransfer={requireFirstTransfer}
activationTag={activationTag}
reload={reload}
Expand Down
15 changes: 2 additions & 13 deletions clients/banking/src/graphql/partner.gql
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,12 @@ fragment TrustedBeneficiaryDetails on TrustedBeneficiary {

# Queries

query LastRelevantIdentification(
$accountMembershipId: ID!
$identificationProcess: [IdentificationProcess!]
) {
query LastIdentification($accountMembershipId: ID!) {
accountMembership(id: $accountMembershipId) {
id
user {
id
identifications(
first: 1
orderBy: { field: updatedAt, direction: Desc }
filters: { processes: $identificationProcess }
) {
identifications(first: 1, orderBy: { field: updatedAt, direction: Desc }) {
edges {
node {
...Identification
Expand Down Expand Up @@ -927,7 +920,6 @@ query CardPage($cardId: ID!) {
accountMembership {
id
canManageAccountMembership
recommendedIdentificationLevel
hasRequiredIdentificationLevel
canViewAccount
canManageBeneficiaries
Expand Down Expand Up @@ -1083,7 +1075,6 @@ query CardTransactionsPage(
}
accountMembership {
id
recommendedIdentificationLevel
statusInfo {
__typename
... on AccountMembershipBindingUserErrorStatusInfo {
Expand Down Expand Up @@ -1260,7 +1251,6 @@ fragment AccountMembership on AccountMembership {
updatedAt
email
legalRepresentative
recommendedIdentificationLevel
hasRequiredIdentificationLevel
language
statusInfo {
Expand Down Expand Up @@ -1403,7 +1393,6 @@ query ProfilePage {
query AccountActivationPage($accountMembershipId: ID!) {
accountMembership(id: $accountMembershipId) {
id
recommendedIdentificationLevel
account {
id
IBAN
Expand Down
8 changes: 4 additions & 4 deletions clients/banking/src/pages/AccountActivationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ type Props = {
refetchAccountAreaQuery: () => void;
requireFirstTransfer: boolean;
hasRequiredIdentificationLevel: boolean | undefined;
lastRelevantIdentification: Option<IdentificationFragment>;
lastIdentification: Option<IdentificationFragment>;
};

export const AccountActivationPage = ({
Expand All @@ -307,7 +307,7 @@ export const AccountActivationPage = ({
refetchAccountAreaQuery,
requireFirstTransfer,
hasRequiredIdentificationLevel,
lastRelevantIdentification,
lastIdentification,
}: Props) => {
const documentsFormRef = useRef<SupportingDocumentsFormRef>(null);

Expand Down Expand Up @@ -377,7 +377,7 @@ export const AccountActivationPage = ({
hasRequiredIdentificationLevel: false,
},
() =>
match(lastRelevantIdentification.map(getIdentificationLevelStatusInfo))
match(lastIdentification.map(getIdentificationLevelStatusInfo))
.returnType<Step | undefined>()
// this branch shouldn't occur but is required to typecheck
.with(Option.P.Some({ status: P.union("Valid", "NotSupported") }), () => undefined)
Expand Down Expand Up @@ -528,7 +528,7 @@ export const AccountActivationPage = ({
<Space height={32} />

<LakeButton mode="primary" color="partner" onPress={handleProveIdentity}>
{lastRelevantIdentification.map(isReadyToSign).getOr(false)
{lastIdentification.map(isReadyToSign).getOr(false)
? t("accountActivation.identity.button.signVerification")
: t("accountActivation.identity.button.verifyMyIdentity")}
</LakeButton>
Expand Down

0 comments on commit a0fb2ad

Please sign in to comment.