fix: 🐛 frontend bugs

This commit is contained in:
amianthus
2026-04-21 11:46:19 +01:00
parent b1b0b06830
commit 8374da14bd
5 changed files with 51 additions and 2 deletions

View File

@@ -97,6 +97,7 @@ export const mapToProductV2 = ({
items: items,
stripe_id: product.processor?.id || null,
archived: product.archived || false,
config: product.config ?? undefined,
};
return productV2;

View File

@@ -94,6 +94,34 @@ export const compareDetails = ({
return detailsSame;
};
export const compareConfig = ({
newConfig,
curConfig,
}: {
newConfig?: ProductV2["config"];
curConfig?: ProductV2["config"];
}) => {
const checks = {
ignore_past_due: {
condition: newConfig?.ignore_past_due === curConfig?.ignore_past_due,
message: `Ignore past due different: ${newConfig?.ignore_past_due} !== ${curConfig?.ignore_past_due}`,
},
};
const detailsSame = Object.values(checks).every((d) => d.condition);
// if (!detailsSame) {
// console.log(
// "Product details different:",
// Object.values(checks)
// .filter((d) => !d.condition)
// .map((d) => d.message),
// );
// }
return detailsSame;
};
export const prodOptionsAreSame = ({
curProduct,
newProduct,
@@ -150,6 +178,7 @@ export const productsAreSame = ({
let itemsSame = true;
let pricesChanged = false;
let detailsSame = true;
let configSame = true;
const newItems: ProductItem[] = [];
const removedItems: ProductItem[] = [];
@@ -158,6 +187,11 @@ export const productsAreSame = ({
curProductV2,
});
configSame = compareConfig({
newConfig: newProductV2?.config,
curConfig: curProductV2?.config,
});
if (items1.length !== items2.length) {
itemsSame = false;
}
@@ -250,5 +284,6 @@ export const productsAreSame = ({
removedItems,
detailsSame,
optionsSame,
configSame,
};
};

View File

@@ -93,6 +93,7 @@ export const mapToProductV2 = ({
items: items,
stripe_id: product.processor?.id || null,
archived: product.archived || false,
config: product.config ?? undefined,
};
return productV2;

View File

@@ -81,7 +81,8 @@ export const useHasChanges = () => {
return (
!comparison.itemsSame ||
!comparison.detailsSame ||
!comparison.freeTrialsSame
!comparison.freeTrialsSame ||
!comparison.configSame
);
}, [product, baseProduct, features]);
};

View File

@@ -43,7 +43,7 @@ export function EditPlanSheet({ isOnboarding }: { isOnboarding?: boolean }) {
{!showAdvanced && (
<SheetAccordion type="single" withSeparator={false}>
<SheetAccordionItem value="advanced" title="Advanced">
<div className="space-y-2">
<div className="space-y-4">
<AreaCheckbox
title="Group"
description="If your app has multiple groups of subscription tiers, you can choose which group this plan belongs to."
@@ -62,6 +62,17 @@ export function EditPlanSheet({ isOnboarding }: { isOnboarding?: boolean }) {
/>
)}
</AreaCheckbox>
<AreaCheckbox
title="Ignore past due"
description="Customers on this plan won't be treated as past due — balances keep resetting normally"
checked={product.config?.ignore_past_due}
onCheckedChange={(checked) =>
setProduct({
...product,
config: { ...product.config, ignore_past_due: checked },
})
}
/>
</div>
</SheetAccordionItem>
</SheetAccordion>