fix: 🐛 misc fixes

This commit is contained in:
amianthus
2025-09-25 13:39:42 +01:00
parent b4a9c731e4
commit dcec6f7f23
3 changed files with 11 additions and 4 deletions

View File

@@ -138,6 +138,14 @@ const validateProductItem = ({
});
}
if (item.included_usage === Infinite) {
throw new RecaseError({
message: `Included usage can't be '${Infinite}' for tiered prices`,
code: ErrCode.InvalidInputs,
statusCode: StatusCodes.BAD_REQUEST,
});
}
if (item.billing_units && item.billing_units <= 0) {
throw new RecaseError({
message: `Billing units must be greater than 0`,

View File

@@ -16,8 +16,7 @@ export function mapToProductV3({
is_add_on: product.is_add_on,
is_default: product.is_default,
version: product.version,
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
description: "",
created_at: product.created_at,
price: productV2ToBasePrice({ product }) || null,
};

View File

@@ -15,10 +15,10 @@ export function BillingType() {
const setBillingType = (type: "included" | "priced") => {
if (type === "included") {
// Remove tiers to switch to included
setItem({ ...item, tiers: null });
setItem({ ...item, tiers: null, billing_units: undefined });
} else {
// Add initial tier to switch to priced
setItem({ ...item, tiers: [{ to: 0, amount: 0 }] });
setItem({ ...item, tiers: [{ to: 0, amount: 0 }], billing_units: 1 });
}
};