Skip to content

Commit

Permalink
fix(payment): updated invoice query contentType to handle 'cards' con…
Browse files Browse the repository at this point in the history
…tentType
  • Loading branch information
soyombo-baterdene committed Apr 5, 2024
1 parent c76d2ed commit af4a287
Showing 1 changed file with 5 additions and 11 deletions.
Expand Up @@ -36,15 +36,7 @@ const generateFilterQuery = (params: IParam) => {
query.contentType = contentType;

if (contentType.includes('cards')) {
const cardType = contentType.split(':')[1];

const lastCharacter = cardType.charAt(cardType.length - 1);

if (lastCharacter === 's') {
query.contentType = `cards:${cardType.slice(0, -1)}`;
} else {
query.contentType = `cards:${cardType}`;
}
query.contentType = { $in: [contentType, contentType.slice(0, -1)] };
}
}

Expand All @@ -66,10 +58,12 @@ const queries = {
page: number;
perPage: number;
},
{ models }: IContext,
{ models }: IContext
) {
const selector = generateFilterQuery(params);

console.log('selector', selector);

return paginate(models.Invoices.find(selector).sort({ createdAt: -1 }), {
...params,
});
Expand Down Expand Up @@ -120,7 +114,7 @@ const queries = {
async invoiceDetailByContent(
_root,
{ contentType, contentTypeId },
{ models }: IContext,
{ models }: IContext
) {
return models.Invoices.find({ contentType, contentTypeId }).lean();
},
Expand Down

0 comments on commit af4a287

Please sign in to comment.