Skip to content

Commit

Permalink
Fix(account-transactions): Include new GraphQL args in query
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavlrsn committed Apr 8, 2024
1 parent aeb06a2 commit e41b4fb
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/server/controllers/account-transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ const transactionsQuery = gqlV2/* GraphQL */ `
includeGiftCardTransactions: $includeGiftCardTransactions
includeRegularTransactions: $includeRegularTransactions
paymentMethodType: $paymentMethodType
expenseType: $expenseType
expense: $expense
order: $order
isRefund: $isRefund
) {
...TransactionsFragment
}
Expand Down Expand Up @@ -259,6 +263,10 @@ const hostTransactionsQuery = gqlV2/* GraphQL */ `
includeChildrenTransactions: $includeChildrenTransactions
includeHost: $includeHost
paymentMethodType: $paymentMethodType
expenseType: $expenseType
expense: $expense
order: $order
isRefund: $isRefund
) {
...TransactionsFragment
}
Expand Down Expand Up @@ -436,6 +444,7 @@ const accountTransactions = async (req, res) => {
return res.status(405).send({ error: { message: 'Method not allowed' } });
}

let newVars = {};

Check failure on line 447 in src/server/controllers/account-transactions.js

View workflow job for this annotation

GitHub Actions / lint

'newVars' is assigned a value but never used

Check failure on line 447 in src/server/controllers/account-transactions.js

View workflow job for this annotation

GitHub Actions / lint

'newVars' is never reassigned. Use 'const' instead
const variables = pick({ ...req.params, ...req.query }, [
'account',
'slug',
Expand Down Expand Up @@ -557,22 +566,22 @@ const accountTransactions = async (req, res) => {
variables.kind = difference(variables.kind || allKinds, ['TAX']);
}

if (variables.expenseType) {
variables.expenseType = variables.expenseType.split(',').map(toUpper).map(trim);
}
// if (variables.expenseType) {
// variables.expenseType = variables.expenseType.split(',').map(toUpper).map(trim);
// }

if (variables.orderId) {
variables.order = { legacyId: parseInt(variables.orderId) };
}
// if (variables.orderId) {
// variables.order = { legacyId: parseInt(variables.orderId) };
// }

if (variables.expenseId) {
variables.expense = { legacyId: parseInt(variables.expenseId) };
}
// if (variables.expenseId) {
// variables.expense = { legacyId: parseInt(variables.expenseId) };
// }

// isRefund can be false but default should be undefined
if (!isNil(variables.isRefund)) {
variables.isRefund = parseToBooleanDefaultFalse(variables.isRefund);
}
// // isRefund can be false but default should be undefined
// if (!isNil(variables.isRefund)) {
// variables.isRefund = parseToBooleanDefaultFalse(variables.isRefund);
// }

if (req.query.fullDescription) {
variables.fullDescription = parseToBooleanDefaultFalse(req.query.fullDescription);
Expand Down

0 comments on commit e41b4fb

Please sign in to comment.