Skip to content

Commit d43cef5

Browse files
authored
Merge pull request #873 from PayButton/fix/csv-download-default-currency
Fix/csv download default currency
2 parents 583a770 + 10417c9 commit d43cef5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

pages/api/paybutton/download/transactions/[paybuttonId].ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
NetworkTickersType,
1111
NETWORK_TICKERS,
1212
NETWORK_IDS,
13-
SUPPORTED_QUOTES_FROM_ID
13+
SUPPORTED_QUOTES_FROM_ID,
14+
USD_QUOTE_ID
1415
} from 'constants/index'
1516
import { TransactionWithAddressAndPrices, fetchTransactionsByPaybuttonId, getTransactionValueInCurrency } from 'services/transactionService'
1617
import { PaybuttonWithAddresses, fetchPaybuttonById } from 'services/paybuttonService'
@@ -147,7 +148,12 @@ export default async (req: any, res: any): Promise<void> => {
147148
const networkTickerReq = req.query.network as string
148149

149150
const networkTicker = (networkTickerReq !== '' && isNetworkValid(networkTickerReq as NetworkTickersType)) ? networkTickerReq.toUpperCase() as NetworkTickersType : undefined
150-
const quoteId = req.query.currency as number
151+
let quoteId: number
152+
if (req.query.currency === undefined || req.query.currency === '' || Number.isNaN(req.query.currency)) {
153+
quoteId = USD_QUOTE_ID
154+
} else {
155+
quoteId = req.query.currency as number
156+
}
151157
const quoteSlug = SUPPORTED_QUOTES_FROM_ID[quoteId]
152158
const paybutton = await fetchPaybuttonById(paybuttonId)
153159
if (paybutton.providerUserId !== userId) {

0 commit comments

Comments
 (0)