Explorar o código

Default interstitial to monthly plans (#33706)

* Default interstitial to monthly plans except for upgrade, which defaults to user's existing subscription period

* Add tests for interstitial page period toggle defaults

GitOrigin-RevId: fa0ac41e7d8a7bf858b53e0940287b28ef21253d
Tim Down hai 5 meses
pai
achega
248e149701
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      services/web/app/src/Features/Subscription/PlansLocator.mjs

+ 10 - 1
services/web/app/src/Features/Subscription/PlansLocator.mjs

@@ -120,10 +120,19 @@ const recurlyPlanCodeToPlanTypeAndPeriod = {
 }
 
 /**
- * @param {RecurlyPlanCode} recurlyPlanCode
+ * @param {string} key
+ * @returns {key is RecurlyPlanCode}
+ */
+function isRecurlyPlanCode(key) {
+  return Object.hasOwn(recurlyPlanCodeToPlanTypeAndPeriod, key)
+}
+
+/**
+ * @param {string} recurlyPlanCode
  * @returns {PlanTypeAndPeriod | undefined}
  */
 function getPlanTypeAndPeriodFromRecurlyPlanCode(recurlyPlanCode) {
+  if (!isRecurlyPlanCode(recurlyPlanCode)) return undefined
   return recurlyPlanCodeToPlanTypeAndPeriod[recurlyPlanCode]
 }