Update partner packages, copy, and demo switcher
This commit is contained in:
@@ -9,7 +9,12 @@ export type PackageComparisonRow =
|
||||
| {
|
||||
id: string;
|
||||
type: 'limit';
|
||||
limitKey: 'max_photos' | 'max_guests' | 'gallery_days';
|
||||
limitKey: 'max_photos' | 'max_guests' | 'gallery_days' | 'max_events_per_year';
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
type: 'value';
|
||||
valueKey: 'included_package_slug';
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
@@ -62,6 +67,10 @@ export function classifyPackageChange(pkg: Package, active: Package | null): Pac
|
||||
return { isUpgrade: false, isDowngrade: false };
|
||||
}
|
||||
|
||||
if (pkg.type === 'reseller' || active.type === 'reseller') {
|
||||
return { isUpgrade: false, isDowngrade: false };
|
||||
}
|
||||
|
||||
const activeFeatures = collectFeatures(active);
|
||||
const candidateFeatures = collectFeatures(pkg);
|
||||
|
||||
@@ -106,6 +115,10 @@ export function selectRecommendedPackageId(
|
||||
return null;
|
||||
}
|
||||
|
||||
if (packages.some((pkg) => pkg.type === 'reseller')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const candidates = feature === 'watermark_allowed'
|
||||
? packages.filter((pkg) => pkg.watermark_allowed === true)
|
||||
: packages.filter((pkg) => normalizePackageFeatures(pkg).includes(feature));
|
||||
@@ -121,11 +134,20 @@ export function selectRecommendedPackageId(
|
||||
}
|
||||
|
||||
export function buildPackageComparisonRows(packages: Package[]): PackageComparisonRow[] {
|
||||
const limitRows: PackageComparisonRow[] = [
|
||||
{ id: 'limit.max_photos', type: 'limit', limitKey: 'max_photos' },
|
||||
{ id: 'limit.max_guests', type: 'limit', limitKey: 'max_guests' },
|
||||
{ id: 'limit.gallery_days', type: 'limit', limitKey: 'gallery_days' },
|
||||
];
|
||||
const isResellerCatalog = packages.some(
|
||||
(pkg) => pkg.type === 'reseller' || pkg.max_events_per_year !== undefined || pkg.included_package_slug !== undefined
|
||||
);
|
||||
|
||||
const limitRows: PackageComparisonRow[] = isResellerCatalog
|
||||
? [
|
||||
{ id: 'value.included_package_slug', type: 'value', valueKey: 'included_package_slug' },
|
||||
{ id: 'limit.max_events_per_year', type: 'limit', limitKey: 'max_events_per_year' },
|
||||
]
|
||||
: [
|
||||
{ id: 'limit.max_photos', type: 'limit', limitKey: 'max_photos' },
|
||||
{ id: 'limit.max_guests', type: 'limit', limitKey: 'max_guests' },
|
||||
{ id: 'limit.gallery_days', type: 'limit', limitKey: 'gallery_days' },
|
||||
];
|
||||
|
||||
const featureKeys = new Set<string>();
|
||||
packages.forEach((pkg) => {
|
||||
|
||||
@@ -174,13 +174,19 @@ export function formatPackageLimit(value: number | null | undefined, t: Translat
|
||||
export function getPackageLimitEntries(
|
||||
limits: Record<string, unknown> | null,
|
||||
t: Translate,
|
||||
usageOverrides: LimitUsageOverrides = {}
|
||||
usageOverrides: LimitUsageOverrides = {},
|
||||
options: { packageType?: string | null } = {}
|
||||
): PackageLimitEntry[] {
|
||||
if (!limits) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return LIMIT_LABELS.map(({ key, labelKey, fallback }) => ({
|
||||
const labels =
|
||||
options.packageType === 'reseller'
|
||||
? LIMIT_LABELS.filter(({ key }) => key === 'max_events_per_year')
|
||||
: LIMIT_LABELS;
|
||||
|
||||
return labels.map(({ key, labelKey, fallback }) => ({
|
||||
key,
|
||||
label: t(labelKey, fallback),
|
||||
value: formatLimitWithRemaining(
|
||||
@@ -231,11 +237,11 @@ export function collectPackageFeatures(pkg: TenantPackageSummary): string[] {
|
||||
}
|
||||
});
|
||||
|
||||
if (pkg.branding_allowed) {
|
||||
if (pkg.package_type !== 'reseller' && pkg.branding_allowed) {
|
||||
features.add('branding_allowed');
|
||||
}
|
||||
|
||||
if (pkg.watermark_allowed) {
|
||||
if (pkg.package_type !== 'reseller' && pkg.watermark_allowed) {
|
||||
features.add('watermark_allowed');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user