Skip to content

Commit

Permalink
update user hotmart subscriptions creation
Browse files Browse the repository at this point in the history
  • Loading branch information
claushaas committed Oct 24, 2024
1 parent b4f2c62 commit dda54a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/services/hotmart.service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ export class HotmartService {
logger.logDebug(`Got response: ${JSON.stringify(response.data)}`);

const {data: {items}} = response;
items.sort((a, b) => new Date(b.purchase.approved_date).getTime() - new Date(a.purchase.approved_date).getTime());
console.log(items);
if (items.length > 1) {
items.sort((a, b) => new Date(b.purchase.approved_date).getTime() - new Date(a.purchase.approved_date).getTime());
}

return {
status: 'SUCCESSFUL',
data: items ? this._mapFormationSubscriptions([items[0]], user) : [],
data: items.length > 0 ? this._mapFormationSubscriptions([items[0]], user) : [],
};
} catch (error) {
logger.logError(`Error getting user formation subscriptions on first try: ${JSON.stringify((error as Record<string, string>).data)}`);
Expand Down

0 comments on commit dda54a7

Please sign in to comment.