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

refactor(pay): moving hooks to hooks folder #4435

Merged
merged 3 commits into from
May 15, 2024
Merged
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
2 changes: 1 addition & 1 deletion apps/pay/app/[username]/transaction/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useSession } from "next-auth/react"

import { useGetPaginatedTransactionsQuery, Transaction } from "@/lib/graphql/generated"
import LoadingComponent from "@/components/loading"
import { formatCreateAt, formatDate, formatTime } from "@/utils/date-util"
import { formatCreateAt, formatDate, formatTime } from "@/lib/utils/date-util"
import { sendDataToPosCompanion } from "@/app/print-companion-service"
import useCheckInstalledApps from "@/hooks/use-check-installed-apps"

Expand Down
8 changes: 4 additions & 4 deletions apps/pay/app/lnurlp/[username]/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { gql } from "@apollo/client"

import Redis from "ioredis"

import { env } from "../../../../env"
import { env } from "@/env"
import {
AccountDefaultWalletDocument,
AccountDefaultWalletQuery,
LnInvoiceCreateOnBehalfOfRecipientDocument,
LnInvoiceCreateOnBehalfOfRecipientMutation,
} from "../../../../lib/graphql/generated"
import { client } from "../graphql"
import { getOriginalRequestInfo } from "../../../../utils/utils"
} from "@/lib/graphql/generated"
import { client } from "@/app/lnurlp/[username]/graphql"
import { getOriginalRequestInfo } from "@/lib/utils"

gql`
mutation lnInvoiceCreateOnBehalfOfRecipient(
Expand Down
8 changes: 4 additions & 4 deletions apps/pay/app/lnurlp/[username]/route.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { NextResponse } from "next/server"

import { env } from "../../../env"
import { env } from "@/env"
import {
AccountDefaultWalletDocument,
AccountDefaultWalletQuery,
RealtimePriceInitialDocument,
RealtimePriceInitialQuery,
} from "../../../lib/graphql/generated"
} from "@/lib/graphql/generated"

import { getOriginalRequestInfo } from "../../../utils/utils"
import { getOriginalRequestInfo } from "@/lib/utils"

import { client } from "./graphql"
import { client } from "@/app/lnurlp/[username]/graphql"

const COMMENT_SIZE = 2000 // 2000 characters max for GET

Expand Down
14 changes: 7 additions & 7 deletions apps/pay/components/parse-pos-payment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import Image from "next/image"

import CurrencyInput, { formatValue } from "react-currency-input-field"

import { ACTION_TYPE, ACTIONS } from "../../app/reducer"
import { ACTION_TYPE, ACTIONS } from "@/app/reducer"
import {
safeAmount,
getLocaleConfig,
extractSearchParams,
parseDisplayCurrency,
} from "../../utils/utils"
} from "@/lib/utils"

import { useDisplayCurrency } from "../../lib/use-display-currency"
import { useDisplayCurrency } from "@/hooks/use-display-currency"

import Memo from "../memo"
import Memo from "@/components/memo"

import DigitButton from "./digit-button"
import styles from "./parse-payment.module.css"
import ReceiveInvoice from "./receive-invoice"
import DigitButton from "@/components/parse-pos-payment/digit-button"
import styles from "@/components/parse-pos-payment/parse-payment.module.css"
import ReceiveInvoice from "@/components/parse-pos-payment/receive-invoice"

import { satCurrencyMetadata } from "@/app/sats-currency-metadata"
import useDynamicFontSize from "@/hooks/use-dynamic-font-size"
Expand Down
24 changes: 12 additions & 12 deletions apps/pay/components/parse-pos-payment/receive-invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import Tooltip from "react-bootstrap/Tooltip"
import { QRCode } from "react-qrcode-logo"
import { useScreenshot } from "use-react-screenshot"

import { USD_INVOICE_EXPIRE_INTERVAL } from "../../config/config"
import useCreateInvoice from "../../hooks/use-create-Invoice"
import { LnInvoiceObject } from "../../lib/graphql/index.types"
import useSatPrice from "../../lib/use-sat-price"
import { ACTION_TYPE } from "../../app/reducer"
import PaymentOutcome from "../payment-outcome"
import { Share } from "../share"
import { USD_INVOICE_EXPIRE_INTERVAL } from "@/config/config"
import useCreateInvoice from "@/hooks/use-create-Invoice"
import { LnInvoiceObject } from "@/lib/graphql/index.types"
import useSatPrice from "@/hooks/use-sat-price"
import { ACTION_TYPE } from "@/app/reducer"
import PaymentOutcome from "@/components/payment-outcome"
import { Share } from "@/components/share"

import { extractSearchParams, safeAmount } from "../../utils/utils"
import { extractSearchParams, safeAmount } from "@/lib/utils"

import LoadingComponent from "../loading"
import LoadingComponent from "@/components/loading"

import styles from "./parse-payment.module.css"
import NFCComponent from "./nfc"
import styles from "@/components/parse-pos-payment/parse-payment.module.css"
import NFCComponent from "@/components/parse-pos-payment/nfc"

import useRealtimePrice from "@/lib/use-realtime-price"
import useRealtimePrice from "@/hooks/use-realtime-price"

interface Props {
recipientWalletCurrency?: string
Expand Down
2 changes: 1 addition & 1 deletion apps/pay/components/payment-outcome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useLnInvoicePaymentStatusSubscription } from "../../lib/graphql/generat
import styles from "./payment-outcome.module.css"
import Receipt from "./receipt"

import { extractSearchParams } from "@/utils/utils"
import { extractSearchParams } from "@/lib/utils"
import { useInvoiceContext } from "@/context/invoice-context"
import useCheckInstalledApps from "@/hooks/use-check-installed-apps"

Expand Down
6 changes: 3 additions & 3 deletions apps/pay/components/payment-outcome/receipt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import React from "react"
import Image from "react-bootstrap/Image"

import { formattedDate, formattedTime } from "../../utils/date-util"
import GaloyIcon from "@/components/payment-outcome/galoy-icon"
import styles from "@/components/payment-outcome/payment-outcome.module.css"

import GaloyIcon from "./galoy-icon"
import styles from "./payment-outcome.module.css"
import { formattedDate, formattedTime } from "@/lib/utils/date-util"

interface Props {
amount: string | string[] | undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { gql } from "@apollo/client"
import { useCurrencyListQuery } from "./graphql/generated"

import { useCallback, useMemo } from "react"

import { useCurrencyListQuery } from "@/lib/graphql/generated"

gql`
query currencyList {
currencyList {
Expand Down Expand Up @@ -52,10 +54,13 @@ export const useDisplayCurrency = () => {

const displayCurrencyDictionary = useMemo(() => {
const currencyList = dataCurrencyList?.currencyList || []
return currencyList.reduce((acc, currency) => {
acc[currency.id] = currency
return acc
}, {} as Record<string, typeof defaultDisplayCurrency>)
return currencyList.reduce(
(acc, currency) => {
acc[currency.id] = currency
return acc
},
{} as Record<string, typeof defaultDisplayCurrency>,
)
}, [dataCurrencyList?.currencyList])

const formatCurrency = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { gql, SubscriptionResult } from "@apollo/client"
import * as React from "react"

import {
RealtimePriceWsSubscription,
useRealtimePriceInitialQuery,
useRealtimePriceWsSubscription,
} from "../lib/graphql/generated"
import { useDisplayCurrency } from "../lib/use-display-currency"
} from "@/lib/graphql/generated"
import { useDisplayCurrency } from "@/hooks/use-display-currency"

gql`
subscription realtimePriceWs($currency: DisplayCurrency!) {
Expand Down Expand Up @@ -47,7 +48,7 @@ gql`
const useRealtimePrice = (
currency: string,
onSubscriptionDataCallback?: (
subscriptionData: SubscriptionResult<RealtimePriceWsSubscription, any>,
subscriptionData: SubscriptionResult<RealtimePriceWsSubscription, unknown>,
) => void,
) => {
const priceRef = React.useRef<number>(0)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading