Skip to content

Commit

Permalink
fix(WalletForm): update code snippet
Browse files Browse the repository at this point in the history
fix(WalletSnippet): add missing comma
  • Loading branch information
keellyp committed May 31, 2024
1 parent b7a72b8 commit a810978
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
2 changes: 2 additions & 0 deletions ditto/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@
"text_6657c34670561c0127132da4": "Dynamic top-up",
"text_6657c34670561c0127132da5": "Target ongoing balance",
"text_6657cdd8cea6bf010e1ce128": "Fixed top-up",
"text_66584178ee91f801012606a6": "Target ongoing balance should be higher than threshold",
"text_66584178ee91f801012606ac": "Threshold should be lower than target ongoing balance",
"text_64aeb7b998c4322918c84204": "Payment methods",
"text_64aeb7b998c4322918c84208": "Card",
"text_64aeb7b998c4322918c8420c": "SEPA Direct Debit",
Expand Down
56 changes: 34 additions & 22 deletions src/components/wallets/WalletCodeSnippet.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { CodeSnippet } from '~/components/CodeSnippet'
import { envGlobalVar } from '~/core/apolloClient'
import { serializeAmount } from '~/core/serializers/serializeAmount'
import { RecurringTransactionTriggerEnum } from '~/generated/graphql'
import {
RecurringTransactionMethodEnum,
RecurringTransactionTriggerEnum,
} from '~/generated/graphql'
import { TWalletDataForm } from '~/pages/WalletForm'

const { apiUrl } = envGlobalVar()
Expand Down Expand Up @@ -30,7 +33,7 @@ curl --location --request ${isEdition ? 'PUT' : 'POST'} "${apiUrl}/api/v1/wallet
}
"rate_amount": "${rateAmount}",
"currency": "${currency}",
"external_customer_id": "__EXTERNAL_CUSTOMER_ID__"${
"external_customer_id": "__EXTERNAL_CUSTOMER_ID__",${
wallet.expirationAt
? `,
"expiration_at": "${wallet.expirationAt}",`
Expand All @@ -55,6 +58,34 @@ curl --location --request ${isEdition ? 'PUT' : 'POST'} "${apiUrl}/api/v1/wallet
"lago_id": "${recurringTransactionRules[0].lagoId}",`
: ''
}
"method": "${wallet.recurringTransactionRules?.[0].method || '__MUST_BE_DEFINED__'}"${
wallet.recurringTransactionRules?.[0].method === RecurringTransactionMethodEnum.Fixed
? `
"paid_credits": "${
wallet.recurringTransactionRules?.[0].paidCredits
? serializeAmount(
wallet.recurringTransactionRules?.[0].paidCredits,
wallet.currency,
)
: '0'
}",
"granted_credits": "${
wallet.recurringTransactionRules?.[0].grantedCredits
? serializeAmount(
wallet.recurringTransactionRules?.[0].grantedCredits,
wallet.currency,
)
: '0'
}",`
: ''
}${
wallet.recurringTransactionRules?.[0].method === RecurringTransactionMethodEnum.Target
? `
"target_ongoing_balance": "${
wallet.recurringTransactionRules?.[0].targetOngoingBalance || '0'
}"`
: ''
}
"trigger": "${wallet.recurringTransactionRules?.[0].trigger || '__MUST_BE_DEFINED__'}"${
wallet.recurringTransactionRules?.[0].trigger ===
RecurringTransactionTriggerEnum.Interval
Expand All @@ -67,28 +98,9 @@ curl --location --request ${isEdition ? 'PUT' : 'POST'} "${apiUrl}/api/v1/wallet
wallet.recurringTransactionRules?.[0].trigger ===
RecurringTransactionTriggerEnum.Threshold
? `,
"threshold_credits": "${
wallet.recurringTransactionRules?.[0].thresholdCredits || '__MUST_BE_DEFINED__'
}"`
: ''
}${
wallet.recurringTransactionRules?.[0].paidCredits
? `,
"paid_credits": "${serializeAmount(
wallet.recurringTransactionRules?.[0].paidCredits,
wallet.currency,
)}"`
: ''
}${
wallet.recurringTransactionRules?.[0].grantedCredits
? `,
"granted_credits": "${serializeAmount(
wallet.recurringTransactionRules?.[0].grantedCredits,
wallet.currency,
)}"`
"threshold_credits": "${wallet.recurringTransactionRules?.[0].thresholdCredits || '0'}"`
: ''
}
}
]`
: ''
}
Expand Down
13 changes: 9 additions & 4 deletions src/pages/WalletForm/components/TopUpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const TopUpCard: FC<TopUpCardProps> = ({
error={
get(formikProps.errors, 'recurringTransactionRules.0.targetOngoingBalance') ===
walletFormErrorCodes.targetOngoingBalanceShouldBeGreaterThanThreshold
? translate('TODO: Target ongoing balance should be higher than threshold')
? translate('text_66584178ee91f801012606a6')
: undefined
}
helperText={translate('text_62d18855b22699e5cf55f88b', {
Expand Down Expand Up @@ -335,7 +335,7 @@ export const TopUpCard: FC<TopUpCardProps> = ({
}}
/>
{recurringTransactionRules?.trigger === RecurringTransactionTriggerEnum.Interval && (
<>
<Box className="span-2">
<ComboBoxField
name="recurringTransactionRules.0.interval"
disableClearable
Expand All @@ -362,18 +362,19 @@ export const TopUpCard: FC<TopUpCardProps> = ({
},
]}
/>
</>
</Box>
)}
{recurringTransactionRules?.trigger === RecurringTransactionTriggerEnum.Threshold && (
<AmountInputField
className="span-2"
name="recurringTransactionRules.0.thresholdCredits"
currency={formikProps.values.currency}
label={translate('text_6560809c38fb9de88d8a5315')}
formikProps={formikProps}
error={
get(formikProps.errors, 'recurringTransactionRules.0.thresholdCredits') ===
walletFormErrorCodes.thresholdShouldBeLessThanTargetOngoingBalance
? translate('TODO: Threshold should be lower than target ongoing balance')
? translate('text_66584178ee91f801012606ac')
: undefined
}
{...inputAdornment(translate('text_62d18855b22699e5cf55f889'))}
Expand Down Expand Up @@ -408,4 +409,8 @@ const InlineTopUpElements = styled.div`
> div {
flex: 1;
}
> div.span-2 {
flex: 2;
}
`

0 comments on commit a810978

Please sign in to comment.