Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query transactions when opening details #661

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clients/banking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"@sentry/react": "7.106.1",
"@swan-io/boxed": "2.1.0",
"@swan-io/chicane": "2.0.0-rc.2",
"@swan-io/lake": "7.1.3",
"@swan-io/lake": "7.1.4",
"@swan-io/request": "1.0.1",
"@swan-io/shared-business": "7.1.3",
"@swan-io/shared-business": "7.1.4",
"@swan-io/use-form": "2.0.0-rc.2",
"@urql/devtools": "2.0.3",
"@urql/exchange-graphcache": "6.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ export const CardItemTransactionList = ({
onClose={() => setActiveTransactionId(null)}
items={transactions}
render={(transaction, large) => (
<TransactionDetail large={large} transaction={transaction} />
<TransactionDetail
large={large}
transactionId={transaction.id}
canQueryCardOnTransaction={true}
canViewAccount={canViewAccount}
/>
)}
closeLabel={t("common.closeButton")}
previousLabel={t("common.previous")}
Expand Down
55 changes: 42 additions & 13 deletions clients/banking/src/components/TransactionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
import { LakeText } from "@swan-io/lake/src/components/LakeText";
import { ListRightPanelContent } from "@swan-io/lake/src/components/ListRightPanel";
import { LoadingView } from "@swan-io/lake/src/components/LoadingView";
import { ReadOnlyFieldList } from "@swan-io/lake/src/components/ReadOnlyFieldList";
import { Space } from "@swan-io/lake/src/components/Space";
import { Tag } from "@swan-io/lake/src/components/Tag";
import { Tile } from "@swan-io/lake/src/components/Tile";
import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
import { colors } from "@swan-io/lake/src/constants/design";
import { useUrqlQuery } from "@swan-io/lake/src/hooks/useUrqlQuery";
import { isNotEmpty, isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
import { countries } from "@swan-io/shared-business/src/constants/countries";
import { printIbanFormat } from "@swan-io/shared-business/src/utils/validation";
import { ScrollView, StyleSheet } from "react-native";
import { P, match } from "ts-pattern";
import { TransactionDetailsFragment } from "../graphql/partner";
import { TransactionDocument } from "../graphql/partner";
import { formatCurrency, formatDateTime, t } from "../utils/i18n";
import {
getFeesDescription,
Expand Down Expand Up @@ -86,11 +88,38 @@ const CopiableLine = ({ label, text }: { label: string; text: string }) => (
);

type Props = {
transaction: TransactionDetailsFragment;
transactionId: string;
large: boolean;
canQueryCardOnTransaction: boolean;
canViewAccount: boolean;
};

export const TransactionDetail = ({ transaction, large }: Props) => {
export const TransactionDetail = ({
transactionId,
large,
canQueryCardOnTransaction,
canViewAccount,
}: Props) => {
const { data } = useUrqlQuery(
{
query: TransactionDocument,
variables: { id: transactionId, canViewAccount, canQueryCardOnTransaction },
},
[transactionId],
);

if (data.isNotAsked() || data.isLoading()) {
return <LoadingView />;
}

const result = data.get();

if (result.isError()) {
return <ErrorView error={result.getError()} />;
}

const transaction = result.get().transaction;

if (transaction == null) {
return <ErrorView />;
}
Expand Down Expand Up @@ -164,7 +193,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
)
.otherwise(() => null);

const transactionId = (
const transactionIdLine = (
<CopiableLine label={t("transaction.id")} text={truncateTransactionId(transaction.id)} />
);

Expand Down Expand Up @@ -362,7 +391,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
.otherwise(() => null)}

{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
);
},
Expand Down Expand Up @@ -420,7 +449,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
);
},
Expand Down Expand Up @@ -500,7 +529,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
);
},
Expand Down Expand Up @@ -547,7 +576,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
),
)
Expand All @@ -566,7 +595,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
))
.with(
Expand All @@ -586,7 +615,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}

{originTransaction != null && (
<ReadOnlyFieldList>
Expand Down Expand Up @@ -724,7 +753,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}

<CopiableLine label={t("transaction.cmc7")} text={cmc7} />
<CopiableLine label={t("transaction.rlmcKey")} text={rlmcKey} />
Expand Down Expand Up @@ -793,7 +822,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {

{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
),
)
Expand All @@ -806,7 +835,7 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{rejectedDateTime}
{rejectedReason}
{reference}
{transactionId}
{transactionIdLine}
</ReadOnlyFieldList>
))}
</ScrollView>
Expand Down
7 changes: 6 additions & 1 deletion clients/banking/src/components/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ export const TransferList = ({
onClose={() => setActiveTransactionId(null)}
items={transactions}
render={(transaction, large) => (
<TransactionDetail large={large} transaction={transaction} />
<TransactionDetail
large={large}
transactionId={transaction.id}
canQueryCardOnTransaction={canQueryCardOnTransaction}
canViewAccount={canViewAccount}
/>
)}
closeLabel={t("common.closeButton")}
previousLabel={t("common.previous")}
Expand Down
6 changes: 6 additions & 0 deletions clients/banking/src/graphql/partner.gql
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,12 @@ query TransactionListPage(
}
}

query Transaction($id: ID!, $canViewAccount: Boolean!, $canQueryCardOnTransaction: Boolean!) {
transaction(id: $id) {
...TransactionDetails
}
}

query UpcomingTransactionListPage(
$accountId: ID!
$first: Int!
Expand Down
7 changes: 6 additions & 1 deletion clients/banking/src/pages/TransactionListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ export const TransactionListPage = ({
onClose={() => setActiveTransactionId(null)}
items={transactions}
render={(transaction, large) => (
<TransactionDetail large={large} transaction={transaction} />
<TransactionDetail
large={large}
transactionId={transaction.id}
canQueryCardOnTransaction={canQueryCardOnTransaction}
canViewAccount={canViewAccount}
/>
)}
closeLabel={t("common.closeButton")}
previousLabel={t("common.previous")}
Expand Down
7 changes: 6 additions & 1 deletion clients/banking/src/pages/UpcomingTransactionListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ export const UpcomingTransactionListPage = ({
onClose={() => setActiveTransactionId(null)}
items={transactions}
render={(transaction, large) => (
<TransactionDetail large={large} transaction={transaction} />
<TransactionDetail
large={large}
transactionId={transaction.id}
canQueryCardOnTransaction={canQueryCardOnTransaction}
canViewAccount={canViewAccount}
/>
)}
closeLabel={t("common.closeButton")}
previousLabel={t("common.previous")}
Expand Down
4 changes: 2 additions & 2 deletions clients/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"@sentry/react": "7.106.1",
"@swan-io/boxed": "2.1.0",
"@swan-io/chicane": "2.0.0-rc.2",
"@swan-io/lake": "7.1.3",
"@swan-io/lake": "7.1.4",
"@swan-io/request": "1.0.1",
"@swan-io/shared-business": "7.1.3",
"@swan-io/shared-business": "7.1.4",
"@swan-io/use-form": "2.0.0-rc.2",
"@urql/devtools": "2.0.3",
"@urql/exchange-graphcache": "6.5.0",
Expand Down
4 changes: 2 additions & 2 deletions clients/payment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@sentry/react": "7.106.1",
"@swan-io/boxed": "2.1.0",
"@swan-io/chicane": "2.0.0-rc.2",
"@swan-io/lake": "7.1.3",
"@swan-io/shared-business": "7.1.3",
"@swan-io/lake": "7.1.4",
"@swan-io/shared-business": "7.1.4",
"@swan-io/use-form": "2.0.0-rc.2",
"core-js": "3.36.0",
"dayjs": "1.11.10",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2106,10 +2106,10 @@
"@emotion/hash" "^0.9.1"
use-sync-external-store "^1.2.0"

"@swan-io/lake@7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@swan-io/lake/-/lake-7.1.3.tgz#ab6ddb8395ae303d63f2434f8a0c0d8ca2d8540a"
integrity sha512-b0pV1d8mSSm2ZwO0r42BnmP7+LLTBehgsPpVD/ImdbDL8PRzgbOzug7S9vFT85+mhGW0/DbbS0ZTa08BNJdUtw==
"@swan-io/lake@7.1.4":
version "7.1.4"
resolved "https://registry.yarnpkg.com/@swan-io/lake/-/lake-7.1.4.tgz#9d069f0b5c30bf48a96fbacf94c4952edba8fa28"
integrity sha512-1Mqnh29HPY8KDLsuPoRYxxosTNxOxUH2JA81LNWwjzhKG82Q1SwNjuu6hWPf76cTzcQwBgRm4jgQ/Svvn7Iodg==
dependencies:
"@react-three/drei" "^9.102.3"
"@react-three/fiber" "^8.15.19"
Expand All @@ -2135,10 +2135,10 @@
resolved "https://registry.yarnpkg.com/@swan-io/request/-/request-1.0.1.tgz#54a0a0d87ba609e81d31f6280d66b650818687d6"
integrity sha512-CbfliPNRYfeg/aBCcCVnuhMX7sjztH7nK3odmGJO1ua2BuhnUWOy2XeIsFEK8+1KzYIf5k0Uew9JKPHwknlGwA==

"@swan-io/shared-business@7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@swan-io/shared-business/-/shared-business-7.1.3.tgz#a727c44783703206289d58cdb7df018b4ffbf252"
integrity sha512-cJLy+nmSj2UpjHfijm06qqG35xmB7CAXQqUEZwx/uhMqixHA+OBSx9aQ2XXAdzMppw/IFzgSSZ05uKQOKPKY7g==
"@swan-io/shared-business@7.1.4":
version "7.1.4"
resolved "https://registry.yarnpkg.com/@swan-io/shared-business/-/shared-business-7.1.4.tgz#27056cf29b466cca4ef664345a4f8ea8b933235f"
integrity sha512-lM1kaVWWpbPpeCEtEz82zeB/vmXKALJcc4lonMOK812iGZBTgJhFZU1/om9kK7AGpcg3h5JBy6XmYNTErN1F6Q==
dependencies:
"@formatjs/intl" "^2.10.0"
"@placekit/client-js" "^2.3.0"
Expand Down
Loading