Skip to content

Commit

Permalink
feat: adding display voucher price
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 committed May 30, 2024
1 parent 4a3a862 commit 0f72eaf
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 169 deletions.
2 changes: 2 additions & 0 deletions apps/voucher/app/user/links/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ gql`
status
userId
voucherAmountInCents
displayVoucherPrice
displayCurrency
}
}
}
Expand Down
23 changes: 10 additions & 13 deletions apps/voucher/app/withdraw/[voucher-secret]/lnurl/lnurl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -25,6 +29,8 @@ gql`
userId
voucherAmountInCents
voucherSecret
displayVoucherPrice
displayCurrency
}
}
`
Expand All @@ -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
Expand Down Expand Up @@ -151,10 +151,7 @@ const VoucherDetails = ({
</p>
</div>
<div>
Price{" "}
<span className="font-bold">
${withdrawLink.salesAmountInCents / 100} USD
</span>
Price <span className="font-bold">{withdrawLink.displayVoucherPrice}</span>
</div>
<div>
Commission{" "}
Expand All @@ -174,7 +171,7 @@ const VoucherDetails = ({
<div
className={`flex flex-col gap-2 m-auto mt-4 ${revealLNURL ? "" : "blur-sm"}`}
>
<QRCode logoImage="/blink-logo.svg" size={300} value={lnurl} />
<QRCode logoImage="/blink-logo.svg" size={280} value={lnurl} />
</div>
</div>
<div className="flex justify-between mt-2 w-11/12 m-auto p-1">
Expand Down
13 changes: 12 additions & 1 deletion apps/voucher/components/create/confirm-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 6 additions & 0 deletions apps/voucher/graphql/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const resolvers = {
voucherAmountInCents: number
walletId: string
commissionPercentage: number
displayVoucherPrice: string
displayCurrency: string
}
},
) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions apps/voucher/graphql/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type WithdrawLink {
salesAmountInCents: Float!
commissionPercentage: Float!
identifierCode: String!
displayVoucherPrice: String!
displayCurrency: String!
}
type WithdrawLinkWithSecret {
Expand All @@ -30,6 +32,8 @@ type WithdrawLinkWithSecret {
voucherSecret: String!
commissionPercentage: Float!
uniqueHash: String!
displayVoucherPrice: String!
displayCurrency: String!
}
type WithdrawLinksByUserIdResult {
Expand Down Expand Up @@ -59,6 +63,8 @@ input CreateWithdrawLinkInput {
voucherAmountInCents: Float!
walletId: ID!
commissionPercentage: Float
displayVoucherPrice: String!
displayCurrency: String!
}
input RedeemWithdrawLinkOnChainInput {
Expand Down
Loading

0 comments on commit 0f72eaf

Please sign in to comment.