diff --git a/apps/voucher/app/user/links/page.tsx b/apps/voucher/app/user/links/page.tsx index 0148ac1ace..c2d9218818 100644 --- a/apps/voucher/app/user/links/page.tsx +++ b/apps/voucher/app/user/links/page.tsx @@ -27,6 +27,8 @@ gql` status userId voucherAmountInCents + displayVoucherPrice + displayCurrency } } } diff --git a/apps/voucher/app/withdraw/[voucher-secret]/lnurl/lnurl.tsx b/apps/voucher/app/withdraw/[voucher-secret]/lnurl/lnurl.tsx index a4c81ad751..8bb5a92769 100644 --- a/apps/voucher/app/withdraw/[voucher-secret]/lnurl/lnurl.tsx +++ b/apps/voucher/app/withdraw/[voucher-secret]/lnurl/lnurl.tsx @@ -7,7 +7,11 @@ import Link from "next/link" import { encodeURLToLNURL } from "@/utils/helpers" import PageLoadingComponents from "@/components/loading/page-loading-component" -import { useGetWithdrawLinkQuery, Status } from "@/lib/graphql/generated" +import { + useGetWithdrawLinkQuery, + Status, + WithdrawLinkWithSecret, +} from "@/lib/graphql/generated" import Button from "@/components/button" import FundsPaid from "@/components/funds-paid" @@ -25,6 +29,8 @@ gql` userId voucherAmountInCents voucherSecret + displayVoucherPrice + displayCurrency } } ` @@ -35,13 +41,7 @@ type Props = { } type VoucherDetailsProps = { - withdrawLink: { - identifierCode: string - voucherAmountInCents: number - salesAmountInCents: number - commissionPercentage: number - voucherSecret: string - } + withdrawLink: WithdrawLinkWithSecret revealLNURL: boolean lnurl: string copyToClipboard: () => void @@ -151,10 +151,7 @@ const VoucherDetails = ({

- Price{" "} - - ${withdrawLink.salesAmountInCents / 100} USD - + Price {withdrawLink.displayVoucherPrice}
Commission{" "} @@ -174,7 +171,7 @@ const VoucherDetails = ({
- +
diff --git a/apps/voucher/components/create/confirm-modal/index.tsx b/apps/voucher/components/create/confirm-modal/index.tsx index ba6b438794..442071681d 100644 --- a/apps/voucher/components/create/confirm-modal/index.tsx +++ b/apps/voucher/components/create/confirm-modal/index.tsx @@ -89,7 +89,18 @@ const ConfirmModal = ({ setModalLoading(true) try { const createWithdrawLinkResult = await createWithdrawLink({ - variables: { input: { voucherAmountInCents, commissionPercentage, walletId } }, + variables: { + input: { + voucherAmountInCents, + commissionPercentage, + walletId, + displayCurrency: currency, + displayVoucherPrice: formatCurrency({ + amount: Number(amount), + currency, + }), + }, + }, }) update() diff --git a/apps/voucher/graphql/resolvers.ts b/apps/voucher/graphql/resolvers.ts index cd8cb988e8..d1216e75e7 100644 --- a/apps/voucher/graphql/resolvers.ts +++ b/apps/voucher/graphql/resolvers.ts @@ -76,6 +76,8 @@ const resolvers = { voucherAmountInCents: number walletId: string commissionPercentage: number + displayVoucherPrice: string + displayCurrency: string } }, ) => { @@ -152,6 +154,8 @@ const resolvers = { salesAmountInCents, userId: userData.me.id, platformFee: platformFeeInCents, + displayVoucherPrice: args.input.displayVoucherPrice, + displayCurrency: args.input.displayCurrency, }) if (createWithdrawLinkResponse instanceof Error) return createWithdrawLinkResponse @@ -194,6 +198,8 @@ const resolvers = { salesAmountInCents, userId: userData.me.id, platformFee: platformFeeInCents, + displayVoucherPrice: args.input.displayVoucherPrice, + displayCurrency: args.input.displayCurrency, }) if (createWithdrawLinkResponse instanceof Error) return createWithdrawLinkResponse diff --git a/apps/voucher/graphql/schema.ts b/apps/voucher/graphql/schema.ts index e2926f9e5b..053d2b272d 100644 --- a/apps/voucher/graphql/schema.ts +++ b/apps/voucher/graphql/schema.ts @@ -16,6 +16,8 @@ type WithdrawLink { salesAmountInCents: Float! commissionPercentage: Float! identifierCode: String! + displayVoucherPrice: String! + displayCurrency: String! } type WithdrawLinkWithSecret { @@ -30,6 +32,8 @@ type WithdrawLinkWithSecret { voucherSecret: String! commissionPercentage: Float! uniqueHash: String! + displayVoucherPrice: String! + displayCurrency: String! } type WithdrawLinksByUserIdResult { @@ -59,6 +63,8 @@ input CreateWithdrawLinkInput { voucherAmountInCents: Float! walletId: ID! commissionPercentage: Float + displayVoucherPrice: String! + displayCurrency: String! } input RedeemWithdrawLinkOnChainInput { diff --git a/apps/voucher/lib/graphql/generated/index.ts b/apps/voucher/lib/graphql/generated/index.ts index b9c95d0df8..265043f9c9 100644 --- a/apps/voucher/lib/graphql/generated/index.ts +++ b/apps/voucher/lib/graphql/generated/index.ts @@ -77,6 +77,8 @@ export type Scalars = { TotpRegistrationId: { input: any; output: any; } /** A secret to generate time-based one-time password */ TotpSecret: { input: any; output: any; } + /** An external reference id that can be optionally added for transactions. */ + TxExternalId: { input: any; output: any; } /** Unique identifier of a user */ Username: { input: any; output: any; } /** Unique identifier of a wallet */ @@ -85,6 +87,7 @@ export type Scalars = { export type Account = { callbackEndpoints: Array; + callbackPortalUrl: Scalars['String']['output']; csvTransactions: Scalars['String']['output']; defaultWallet: PublicWallet; /** @deprecated Shifting property to 'defaultWallet.id' */ @@ -361,6 +364,7 @@ export type CentAmountPayload = { export type ConsumerAccount = Account & { __typename?: 'ConsumerAccount'; callbackEndpoints: Array; + callbackPortalUrl: Scalars['String']['output']; /** return CSV stream, base64 encoded, of the list of transactions in the wallet */ csvTransactions: Scalars['String']['output']; defaultWallet: PublicWallet; @@ -429,6 +433,8 @@ export type Country = { export type CreateWithdrawLinkInput = { commissionPercentage?: InputMaybe; + displayCurrency: Scalars['String']['input']; + displayVoucherPrice: Scalars['String']['input']; voucherAmountInCents: Scalars['Float']['input']; walletId: Scalars['ID']['input']; }; @@ -575,6 +581,8 @@ export type IntraLedgerUsdPaymentSendInput = { /** A lightning invoice. */ export type Invoice = { createdAt: Scalars['Timestamp']['output']; + /** The unique external id set for the invoice. */ + externalId: Scalars['TxExternalId']['output']; /** The payment hash of the lightning invoice. */ paymentHash: Scalars['PaymentHash']['output']; /** The bolt11 invoice to be paid. */ @@ -621,6 +629,7 @@ export type LnAddressPaymentSendInput = { export type LnInvoice = Invoice & { __typename?: 'LnInvoice'; createdAt: Scalars['Timestamp']['output']; + externalId: Scalars['TxExternalId']['output']; paymentHash: Scalars['PaymentHash']['output']; paymentRequest: Scalars['LnPaymentRequest']['output']; paymentSecret: Scalars['LnPaymentSecret']['output']; @@ -639,6 +648,7 @@ export type LnInvoiceCreateInput = { amount: Scalars['SatAmount']['input']; /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. */ memo?: InputMaybe; /** Wallet ID for a BTC wallet belonging to the current account. */ @@ -651,6 +661,7 @@ export type LnInvoiceCreateOnBehalfOfRecipientInput = { descriptionHash?: InputMaybe; /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. */ memo?: InputMaybe; /** Wallet ID for a BTC wallet which belongs to any account. */ @@ -707,6 +718,7 @@ export type LnInvoicePaymentStatusPayload = { export type LnNoAmountInvoice = Invoice & { __typename?: 'LnNoAmountInvoice'; createdAt: Scalars['Timestamp']['output']; + externalId: Scalars['TxExternalId']['output']; paymentHash: Scalars['PaymentHash']['output']; paymentRequest: Scalars['LnPaymentRequest']['output']; paymentSecret: Scalars['LnPaymentSecret']['output']; @@ -716,6 +728,7 @@ export type LnNoAmountInvoice = Invoice & { export type LnNoAmountInvoiceCreateInput = { /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. */ memo?: InputMaybe; /** ID for either a USD or BTC wallet belonging to the account of the current user. */ @@ -725,6 +738,7 @@ export type LnNoAmountInvoiceCreateInput = { export type LnNoAmountInvoiceCreateOnBehalfOfRecipientInput = { /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. */ memo?: InputMaybe; /** ID for either a USD or BTC wallet which belongs to the account of any user. */ @@ -787,6 +801,7 @@ export type LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientInput = { descriptionHash?: InputMaybe; /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. Acts as a note to the recipient. */ memo?: InputMaybe; /** Wallet ID for a USD wallet which belongs to the account of any user. */ @@ -798,6 +813,7 @@ export type LnUsdInvoiceCreateInput = { amount: Scalars['CentAmount']['input']; /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. */ memo?: InputMaybe; /** Wallet ID for a USD wallet belonging to the current user. */ @@ -810,6 +826,7 @@ export type LnUsdInvoiceCreateOnBehalfOfRecipientInput = { descriptionHash?: InputMaybe; /** Optional invoice expiration time in minutes. */ expiresIn?: InputMaybe; + externalId?: InputMaybe; /** Optional memo for the lightning invoice. Acts as a note to the recipient. */ memo?: InputMaybe; /** Wallet ID for a USD wallet which belongs to the account of any user. */ @@ -986,6 +1003,7 @@ export type Mutation = { quizClaim: QuizClaimPayload; redeemWithdrawLinkOnChain: RedeemWithdrawLinkOnChainResult; supportChatMessageAdd: SupportChatMessageAddPayload; + supportChatReset: SuccessPayload; /** @deprecated will be moved to AccountContact */ userContactUpdateAlias: UserContactUpdateAliasPayload; userEmailDelete: UserEmailDeletePayload; @@ -1778,6 +1796,7 @@ export type Transaction = { __typename?: 'Transaction'; createdAt: Scalars['Timestamp']['output']; direction: TxDirection; + externalId?: Maybe; id: Scalars['ID']['output']; /** From which protocol the payment has been initiated. */ initiationVia: InitiationVia; @@ -2214,6 +2233,8 @@ export type WithdrawLink = { __typename?: 'WithdrawLink'; commissionPercentage: Scalars['Float']['output']; createdAt: Scalars['String']['output']; + displayCurrency: Scalars['String']['output']; + displayVoucherPrice: Scalars['String']['output']; id: Scalars['ID']['output']; identifierCode: Scalars['String']['output']; paidAt?: Maybe; @@ -2227,6 +2248,8 @@ export type WithdrawLinkWithSecret = { __typename?: 'WithdrawLinkWithSecret'; commissionPercentage: Scalars['Float']['output']; createdAt: Scalars['String']['output']; + displayCurrency: Scalars['String']['output']; + displayVoucherPrice: Scalars['String']['output']; id: Scalars['ID']['output']; identifierCode: Scalars['String']['output']; paidAt?: Maybe; @@ -2263,14 +2286,14 @@ export type GetWithdrawLinksByUserIdQueryVariables = Exact<{ }>; -export type GetWithdrawLinksByUserIdQuery = { __typename?: 'Query', getWithdrawLinksByUserId: { __typename?: 'WithdrawLinksByUserIdResult', withdrawLinks: Array<{ __typename?: 'WithdrawLink', commissionPercentage: number, id: string, createdAt: string, identifierCode: string, paidAt?: string | null, salesAmountInCents: number, status: Status, userId: string, voucherAmountInCents: number }> } }; +export type GetWithdrawLinksByUserIdQuery = { __typename?: 'Query', getWithdrawLinksByUserId: { __typename?: 'WithdrawLinksByUserIdResult', withdrawLinks: Array<{ __typename?: 'WithdrawLink', commissionPercentage: number, id: string, createdAt: string, identifierCode: string, paidAt?: string | null, salesAmountInCents: number, status: Status, userId: string, voucherAmountInCents: number, displayVoucherPrice: string, displayCurrency: string }> } }; export type GetWithdrawLinkQueryVariables = Exact<{ voucherSecret?: InputMaybe; }>; -export type GetWithdrawLinkQuery = { __typename?: 'Query', getWithdrawLink?: { __typename?: 'WithdrawLinkWithSecret', commissionPercentage: number, createdAt: string, id: string, identifierCode: string, paidAt?: string | null, salesAmountInCents: number, status: Status, uniqueHash: string, userId: string, voucherAmountInCents: number, voucherSecret: string } | null }; +export type GetWithdrawLinkQuery = { __typename?: 'Query', getWithdrawLink?: { __typename?: 'WithdrawLinkWithSecret', commissionPercentage: number, createdAt: string, id: string, identifierCode: string, paidAt?: string | null, salesAmountInCents: number, status: Status, uniqueHash: string, userId: string, voucherAmountInCents: number, voucherSecret: string, displayVoucherPrice: string, displayCurrency: string } | null }; export type OnChainWithdrawLinkMutationVariables = Exact<{ input: RedeemWithdrawLinkOnChainInput; @@ -2284,29 +2307,6 @@ export type CurrencyListQueryVariables = Exact<{ [key: string]: never; }>; export type CurrencyListQuery = { __typename?: 'Query', currencyList: Array<{ __typename?: 'Currency', id: string, symbol: string, name: string, flag: string, fractionDigits: number }> }; -export type RealtimePriceInitialQueryVariables = Exact<{ - currency: Scalars['DisplayCurrency']['input']; -}>; - - -export type RealtimePriceInitialQuery = { __typename?: 'Query', realtimePrice: { __typename?: 'RealtimePrice', timestamp: any, denominatorCurrency: any, btcSatPrice: { __typename?: 'PriceOfOneSatInMinorUnit', base: any, offset: number }, usdCentPrice: { __typename?: 'PriceOfOneUsdCentInMinorUnit', base: any, offset: number } } }; - -export type RealtimePriceWsSubscriptionVariables = Exact<{ - currency: Scalars['DisplayCurrency']['input']; -}>; - - -export type RealtimePriceWsSubscription = { __typename?: 'Subscription', realtimePrice: { __typename?: 'RealtimePricePayload', errors: Array<{ __typename?: 'GraphQLApplicationError', message: string }>, realtimePrice?: { __typename?: 'RealtimePrice', timestamp: any, denominatorCurrency: any, btcSatPrice: { __typename?: 'PriceOfOneSatInMinorUnit', base: any, offset: number }, usdCentPrice: { __typename?: 'PriceOfOneUsdCentInMinorUnit', base: any, offset: number } } | null } }; - -export type PriceSubscriptionVariables = Exact<{ - amount: Scalars['SatAmount']['input']; - amountCurrencyUnit: ExchangeCurrencyUnit; - priceCurrencyUnit: ExchangeCurrencyUnit; -}>; - - -export type PriceSubscription = { __typename?: 'Subscription', price: { __typename?: 'PricePayload', errors: Array<{ __typename?: 'GraphQLApplicationError', message: string }>, price?: { __typename?: 'Price', base: any, offset: number, currencyUnit: string, formattedAmount: string } | null } }; - export type LnInvoicePaymentSendMutationVariables = Exact<{ input: LnInvoicePaymentInput; }>; @@ -2453,6 +2453,8 @@ export const GetWithdrawLinksByUserIdDocument = gql` status userId voucherAmountInCents + displayVoucherPrice + displayCurrency } } } @@ -2499,6 +2501,8 @@ export const GetWithdrawLinkDocument = gql` userId voucherAmountInCents voucherSecret + displayVoucherPrice + displayCurrency } } `; @@ -2601,136 +2605,6 @@ export function useCurrencyListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptio export type CurrencyListQueryHookResult = ReturnType; export type CurrencyListLazyQueryHookResult = ReturnType; export type CurrencyListQueryResult = Apollo.QueryResult; -export const RealtimePriceInitialDocument = gql` - query RealtimePriceInitial($currency: DisplayCurrency!) { - realtimePrice(currency: $currency) { - timestamp - btcSatPrice { - base - offset - } - usdCentPrice { - base - offset - } - denominatorCurrency - } -} - `; - -/** - * __useRealtimePriceInitialQuery__ - * - * To run a query within a React component, call `useRealtimePriceInitialQuery` and pass it any options that fit your needs. - * When your component renders, `useRealtimePriceInitialQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useRealtimePriceInitialQuery({ - * variables: { - * currency: // value for 'currency' - * }, - * }); - */ -export function useRealtimePriceInitialQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(RealtimePriceInitialDocument, options); - } -export function useRealtimePriceInitialLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(RealtimePriceInitialDocument, options); - } -export type RealtimePriceInitialQueryHookResult = ReturnType; -export type RealtimePriceInitialLazyQueryHookResult = ReturnType; -export type RealtimePriceInitialQueryResult = Apollo.QueryResult; -export const RealtimePriceWsDocument = gql` - subscription realtimePriceWs($currency: DisplayCurrency!) { - realtimePrice(input: {currency: $currency}) { - errors { - message - } - realtimePrice { - timestamp - btcSatPrice { - base - offset - } - usdCentPrice { - base - offset - } - denominatorCurrency - } - } -} - `; - -/** - * __useRealtimePriceWsSubscription__ - * - * To run a query within a React component, call `useRealtimePriceWsSubscription` and pass it any options that fit your needs. - * When your component renders, `useRealtimePriceWsSubscription` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useRealtimePriceWsSubscription({ - * variables: { - * currency: // value for 'currency' - * }, - * }); - */ -export function useRealtimePriceWsSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(RealtimePriceWsDocument, options); - } -export type RealtimePriceWsSubscriptionHookResult = ReturnType; -export type RealtimePriceWsSubscriptionResult = Apollo.SubscriptionResult; -export const PriceDocument = gql` - subscription price($amount: SatAmount!, $amountCurrencyUnit: ExchangeCurrencyUnit!, $priceCurrencyUnit: ExchangeCurrencyUnit!) { - price( - input: {amount: $amount, amountCurrencyUnit: $amountCurrencyUnit, priceCurrencyUnit: $priceCurrencyUnit} - ) { - errors { - message - } - price { - base - offset - currencyUnit - formattedAmount - } - } -} - `; - -/** - * __usePriceSubscription__ - * - * To run a query within a React component, call `usePriceSubscription` and pass it any options that fit your needs. - * When your component renders, `usePriceSubscription` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = usePriceSubscription({ - * variables: { - * amount: // value for 'amount' - * amountCurrencyUnit: // value for 'amountCurrencyUnit' - * priceCurrencyUnit: // value for 'priceCurrencyUnit' - * }, - * }); - */ -export function usePriceSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(PriceDocument, options); - } -export type PriceSubscriptionHookResult = ReturnType; -export type PriceSubscriptionResult = Apollo.SubscriptionResult; export const LnInvoicePaymentSendDocument = gql` mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) { lnInvoicePaymentSend(input: $input) { @@ -3335,6 +3209,7 @@ export type ResolversTypes = { TransactionConnection: ResolverTypeWrapper; TransactionEdge: ResolverTypeWrapper; TxDirection: TxDirection; + TxExternalId: ResolverTypeWrapper; TxNotificationType: TxNotificationType; TxStatus: TxStatus; UpgradePayload: ResolverTypeWrapper; @@ -3542,6 +3417,7 @@ export type ResolversParentTypes = { Transaction: Omit & { initiationVia: ResolversParentTypes['InitiationVia'], settlementVia: ResolversParentTypes['SettlementVia'] }; TransactionConnection: TransactionConnection; TransactionEdge: TransactionEdge; + TxExternalId: Scalars['TxExternalId']['output']; UpgradePayload: UpgradePayload; UsdWallet: UsdWallet; User: User; @@ -3580,6 +3456,7 @@ export type ResolversParentTypes = { export type AccountResolvers = { __resolveType: TypeResolveFn<'ConsumerAccount', ParentType, ContextType>; callbackEndpoints?: Resolver, ParentType, ContextType>; + callbackPortalUrl?: Resolver; csvTransactions?: Resolver>; defaultWallet?: Resolver; defaultWalletId?: Resolver; @@ -3712,6 +3589,7 @@ export type CentAmountPayloadResolvers = { callbackEndpoints?: Resolver, ParentType, ContextType>; + callbackPortalUrl?: Resolver; csvTransactions?: Resolver>; defaultWallet?: Resolver; defaultWalletId?: Resolver; @@ -3872,6 +3750,7 @@ export type IntraLedgerUpdateResolvers = { __resolveType: TypeResolveFn<'LnInvoice' | 'LnNoAmountInvoice', ParentType, ContextType>; createdAt?: Resolver; + externalId?: Resolver; paymentHash?: Resolver; paymentRequest?: Resolver; paymentSecret?: Resolver; @@ -3896,6 +3775,7 @@ export interface LanguageScalarConfig extends GraphQLScalarTypeConfig = { createdAt?: Resolver; + externalId?: Resolver; paymentHash?: Resolver; paymentRequest?: Resolver; paymentSecret?: Resolver; @@ -3927,6 +3807,7 @@ export type LnInvoicePaymentStatusPayloadResolvers = { createdAt?: Resolver; + externalId?: Resolver; paymentHash?: Resolver; paymentRequest?: Resolver; paymentSecret?: Resolver; @@ -4047,6 +3928,7 @@ export type MutationResolvers>; redeemWithdrawLinkOnChain?: Resolver>; supportChatMessageAdd?: Resolver>; + supportChatReset?: Resolver; userContactUpdateAlias?: Resolver>; userEmailDelete?: Resolver; userEmailRegistrationInitiate?: Resolver>; @@ -4367,6 +4249,7 @@ export interface TotpSecretScalarConfig extends GraphQLScalarTypeConfig = { createdAt?: Resolver; direction?: Resolver; + externalId?: Resolver, ParentType, ContextType>; id?: Resolver; initiationVia?: Resolver; memo?: Resolver, ParentType, ContextType>; @@ -4394,6 +4277,10 @@ export type TransactionEdgeResolvers; }; +export interface TxExternalIdScalarConfig extends GraphQLScalarTypeConfig { + name: 'TxExternalId'; +} + export type UpgradePayloadResolvers = { authToken?: Resolver, ParentType, ContextType>; errors?: Resolver, ParentType, ContextType>; @@ -4544,6 +4431,8 @@ export interface WalletIdScalarConfig extends GraphQLScalarTypeConfig = { commissionPercentage?: Resolver; createdAt?: Resolver; + displayCurrency?: Resolver; + displayVoucherPrice?: Resolver; id?: Resolver; identifierCode?: Resolver; paidAt?: Resolver, ParentType, ContextType>; @@ -4557,6 +4446,8 @@ export type WithdrawLinkResolvers = { commissionPercentage?: Resolver; createdAt?: Resolver; + displayCurrency?: Resolver; + displayVoucherPrice?: Resolver; id?: Resolver; identifierCode?: Resolver; paidAt?: Resolver, ParentType, ContextType>; @@ -4691,6 +4582,7 @@ export type Resolvers = { Transaction?: TransactionResolvers; TransactionConnection?: TransactionConnectionResolvers; TransactionEdge?: TransactionEdgeResolvers; + TxExternalId?: GraphQLScalarType; UpgradePayload?: UpgradePayloadResolvers; UsdWallet?: UsdWalletResolvers; User?: UserResolvers; diff --git a/apps/voucher/services/db/index.ts b/apps/voucher/services/db/index.ts index 3deb8f60b8..567b92f366 100644 --- a/apps/voucher/services/db/index.ts +++ b/apps/voucher/services/db/index.ts @@ -18,6 +18,8 @@ type WithdrawLink = { voucherAmountInCents: number salesAmountInCents: number commissionPercentage: number + displayVoucherPrice: string + displayCurrency: string } export async function getWithdrawLinkBySecret({ @@ -91,6 +93,8 @@ export async function createWithdrawLinkMutation(input: { salesAmountInCents: number commissionPercentage: number platformFee: number + displayVoucherPrice: string + displayCurrency: string }): Promise { try { let identifierCode = generateCode(6) diff --git a/apps/voucher/services/db/migrations/20240530124319_adding_display_voucher_price.mjs b/apps/voucher/services/db/migrations/20240530124319_adding_display_voucher_price.mjs new file mode 100644 index 0000000000..57f9410a6a --- /dev/null +++ b/apps/voucher/services/db/migrations/20240530124319_adding_display_voucher_price.mjs @@ -0,0 +1,25 @@ +export const up = async (knex) => { + await knex.schema.table("WithdrawLinks", (table) => { + table.text("displayVoucherPrice").nullable() + table.text("displayCurrency").nullable() + }) + + await knex("WithdrawLinks").update({ + displayCurrency: "USD", + displayVoucherPrice: knex.raw( + `TO_CHAR("salesAmountInCents" / 100.0, 'FM999999990.00') || ' USD'`, + ), + }) + + await knex.schema.table("WithdrawLinks", (table) => { + table.text("displayVoucherPrice").notNullable().alter() + table.text("displayCurrency").notNullable().alter() + }) +} + +export const down = async (knex) => { + await knex.schema.table("WithdrawLinks", (table) => { + table.dropColumn("displayVoucherPrice") + table.dropColumn("displayCurrency") + }) +}