Fixed generating offers in data generator (#19495)

no issue

The data generator created an offer for the free product. This caused an
error in admin UI because it couldn't find the tier for the offer.

This fixes the issue in both the data generator and the admin UI.
This commit is contained in:
Simon Backx 2024-01-16 14:53:34 +01:00 committed by GitHub
parent 42e7f4f307
commit bc79293594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -36,12 +36,18 @@ export default class MembersController extends Controller {
const tier = this.tiers.find((p) => {
return p.id === offer.tier.id;
});
if (!tier) {
return false;
}
const price = offer.cadence === 'month' ? tier.monthlyPrice : tier.yearlyPrice;
return !!tier && tier.active && offer.status === this.type && !!price;
}).map((offer) => {
const tier = this.tiers.find((p) => {
return p.id === offer.tier.id;
});
if (!tier) {
return offer;
}
const price = offer.cadence === 'month' ? tier.monthlyPrice : tier.yearlyPrice;
offer.finalCurrency = offer.currency || tier.currency;
offer.originalPrice = price;

View File

@ -14,7 +14,7 @@ class OffersImporter extends TableImporter {
}
async import(quantity = this.defaultQuantity) {
this.products = await this.transaction.select('id', 'currency').from('products');
this.products = await this.transaction.select('id', 'currency').from('products').where('type', 'paid');
this.names = ['Black Friday', 'Free Trial'];
this.count = 0;