@@ -151,7 +151,11 @@ export function getBasePlanFromGroup(billingPlanGroup: BillingPlanGroup): Models
151151 return proPlans . sort ( ( a , b ) => a . order - b . order ) [ 0 ] ;
152152}
153153
154- export function billingIdToPlan ( billingId : string ) : Models . BillingPlan | null {
154+ export function billingIdToPlan ( billingId : string | null | undefined ) : Models . BillingPlan | null {
155+ if ( ! billingId ) {
156+ return null ;
157+ }
158+
155159 const plansInfoStore = getPlansInfoStore ( ) ;
156160 if ( plansInfoStore . has ( billingId ) ) {
157161 return plansInfoStore . get ( billingId ) ;
@@ -287,9 +291,9 @@ export const actionRequiredInvoices = writable<Models.InvoiceList>(null);
287291export const showUsageRatesModal = writable < boolean > ( false ) ;
288292export const useNewPricingModal = derived ( currentPlan , ( $plan ) => $plan ?. usagePerProject === true ) ;
289293
290- export function checkForUsageFees ( plan : string , id : PlanServices ) {
294+ export function checkForUsageFees ( plan : string | null | undefined , id : PlanServices ) {
291295 const billingPlan = billingIdToPlan ( plan ) ;
292- const supportsUsage = Object . keys ( billingPlan . usage ) . length > 0 ;
296+ const supportsUsage = Object . keys ( billingPlan ? .usage ?? { } ) . length > 0 ;
293297
294298 if ( supportsUsage ) {
295299 switch ( id ) {
@@ -307,10 +311,10 @@ export function checkForUsageFees(plan: string, id: PlanServices) {
307311 } else return false ;
308312}
309313
310- export function checkForProjectLimitation ( plan : string , id : PlanServices ) {
314+ export function checkForProjectLimitation ( plan : string | null | undefined , id : PlanServices ) {
311315 if ( id === 'members' ) {
312316 const billingPlan = billingIdToPlan ( plan ) ;
313- const hasUnlimitedProjects = billingPlan . projects === 0 ;
317+ const hasUnlimitedProjects = billingPlan ? .projects === 0 ;
314318
315319 if ( hasUnlimitedProjects ) {
316320 return false ; // No project limitation for members on Pro/Scale plans
@@ -629,7 +633,7 @@ export async function checkForMissingPaymentMethod() {
629633// Display upgrade banner for new users after 1 week for 30 days
630634export async function checkForNewDevUpgradePro ( org : Models . Organization ) {
631635 // browser or plan check.
632- if ( ! browser || ! org . billingPlanDetails . supportsCredits ) return ;
636+ if ( ! browser || ! org ? .billingPlanDetails ? .supportsCredits ) return ;
633637
634638 // already dismissed by user!
635639 if ( localStorage . getItem ( 'newDevUpgradePro' ) ) return ;
@@ -640,6 +644,8 @@ export async function checkForNewDevUpgradePro(org: Models.Organization) {
640644
641645 const now = new Date ( ) . getTime ( ) ;
642646 const account = get ( user ) ;
647+ if ( ! account ?. $createdAt ) return ;
648+
643649 const accountCreated = new Date ( account . $createdAt ) . getTime ( ) ;
644650 if ( now - accountCreated < 1000 * 60 * 60 * 24 * 7 ) return ;
645651
0 commit comments