-
Notifications
You must be signed in to change notification settings - Fork 5
✨ app: add card limit kyc flow #903
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@exactly/mobile": patch | ||
| --- | ||
|
|
||
| ✨ add card limit kyc flow |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,12 @@ import queryClient from "../../utils/queryClient"; | |
| import reportError from "../../utils/reportError"; | ||
| import { cardModeMutationOptions } from "../../utils/server"; | ||
| import useAccount from "../../utils/useAccount"; | ||
| import useCardLimit from "../../utils/useCardLimit"; | ||
| import useMarkets from "../../utils/useMarkets"; | ||
| import usePendingOperations from "../../utils/usePendingOperations"; | ||
| import usePortfolio from "../../utils/usePortfolio"; | ||
| import useTabPress from "../../utils/useTabPress"; | ||
| import weeklySpend from "../../utils/weeklySpend"; | ||
| import BenefitsSection from "../benefits/BenefitsSection"; | ||
| import CardDetailsSheet from "../card/CardDetails"; | ||
| import ManualRepaymentSheet from "../pay/ManualRepaymentSheet"; | ||
|
|
@@ -61,7 +63,7 @@ import SafeView from "../shared/SafeView"; | |
| import View from "../shared/View"; | ||
|
|
||
| import type { ActivityItem } from "../../utils/queryClient"; | ||
| import type { CardDetails, KYCStatus } from "../../utils/server"; | ||
| import type { CardActivity, CardDetails, KYCStatus } from "../../utils/server"; | ||
| import type { Credential } from "@exactly/common/validation"; | ||
|
|
||
| const HEALTH_FACTOR_THRESHOLD = (WAD * 11n) / 10n; | ||
|
|
@@ -138,6 +140,13 @@ export default function Home() { | |
| kycStatus && "code" in kycStatus && (kycStatus.code === "ok" || kycStatus.code === "legacy kyc"), | ||
| ); | ||
| const { data: card } = useQuery<CardDetails>({ queryKey: ["card", "details"], enabled: !!account && !!bytecode }); | ||
| const { data: cardActivity } = useQuery<CardActivity[]>({ queryKey: ["activity", "card"] }); | ||
|
dieguezguille marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Home mounts, this new Useful? React with 👍 / 👎. |
||
| const spendingLimitReached = !!card?.limit.amount && weeklySpend(cardActivity) / (card.limit.amount / 100) >= 0.9; | ||
| const { | ||
| increase: increaseLimit, | ||
| pending: cardLimitPending, | ||
| processing: cardLimitProcessing, | ||
| } = useCardLimit(spendingLimitReached); | ||
| const { data: spotlightShown } = useQuery<boolean>({ queryKey: ["settings", "installments-spotlight"] }); | ||
| const { data: lastInstallments } = useQuery<number>({ queryKey: ["settings", "installments"] }); | ||
| const { data: promoSeen } = useQuery<boolean>({ queryKey: ["settings", "promo-seen", PROMO.id] }); | ||
|
|
@@ -212,6 +221,9 @@ export default function Home() { | |
| const refresh = () => | ||
| Promise.all([ | ||
| queryClient.invalidateQueries({ queryKey: ["activity"], exact: true }), | ||
| queryClient.invalidateQueries({ queryKey: ["activity", "card"], exact: true }), | ||
| queryClient.invalidateQueries({ queryKey: ["card", "details"], exact: true }), | ||
| queryClient.invalidateQueries({ queryKey: ["kyc", "cardLimit"], exact: true }), | ||
| queryClient.invalidateQueries({ queryKey: ["kyc", "status"], exact: true }), | ||
| revalidateUnsupported(), | ||
| account ? refetchMarkets() : undefined, | ||
|
|
@@ -245,7 +257,7 @@ export default function Home() { | |
| <YStack backgroundColor="$backgroundSoft" padding="$s4" gap="$s4"> | ||
| {overdueMaturity !== undefined && ( | ||
| <InfoAlert | ||
| error | ||
| variant="error" | ||
| title={t("You have an overdue payment. Pay now to avoid additional interest.")} | ||
| actionText={t("Pay now")} | ||
| onPress={() => { | ||
|
|
@@ -254,6 +266,14 @@ export default function Home() { | |
| /> | ||
| )} | ||
| {markets && healthFactor(markets) < HEALTH_FACTOR_THRESHOLD && <LiquidationAlert />} | ||
| {spendingLimitReached && !cardLimitPending && !cardLimitProcessing && ( | ||
| <InfoAlert | ||
| variant="warning" | ||
| title={t("You've reached 90% of your weekly card spending limit.")} | ||
| actionText={t("Increase spending limit")} | ||
| onPress={increaseLimit} | ||
| /> | ||
| )} | ||
| {(showKYCMigration || showPluginOutdated) && ( | ||
| <InfoAlert | ||
| title={t( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.