@@ -3,6 +3,7 @@ import { useMemo } from "react";
33
44import { useIsEmbed } from "@calcom/embed-core/embed-iframe" ;
55import UnconfirmedBookingBadge from "@calcom/features/bookings/UnconfirmedBookingBadge" ;
6+ import { useHasPaidPlan } from "@calcom/features/billing/hooks/useHasPaidPlan" ;
67import {
78 useOrgBranding ,
89 type OrganizationBranding ,
@@ -16,7 +17,19 @@ import { NavigationItem, MobileNavigationItem, MobileNavigationMoreItem } from "
1617
1718export const MORE_SEPARATOR_NAME = "more" ;
1819
19- const getNavigationItems = ( orgBranding : OrganizationBranding ) : NavigationItemType [ ] => [
20+ const preserveBookingsQueryParams = ( {
21+ prevPathname,
22+ nextPathname,
23+ } : {
24+ prevPathname : string | null ;
25+ nextPathname : string ;
26+ } ) => Boolean ( prevPathname ?. startsWith ( "/bookings/" ) ) && nextPathname . startsWith ( "/bookings/" ) ;
27+
28+ const getNavigationItems = (
29+ orgBranding : OrganizationBranding ,
30+ hasInsightsAccess : boolean
31+ ) : NavigationItemType [ ] => [
32+
2033 {
2134 name : "event_types_page_title" ,
2235 href : "/event-types" ,
@@ -106,29 +119,31 @@ const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemTy
106119 icon : "chart-bar" ,
107120 isCurrent : ( { pathname : path , item } ) => path ?. startsWith ( item . href ) ?? false ,
108121 moreOnMobile : true ,
109- child : [
110- {
111- name : "bookings" ,
112- href : "/insights" ,
113- isCurrent : ( { pathname : path } ) => path === "/insights" ,
114- } ,
115- {
116- name : "routing" ,
117- href : "/insights/routing" ,
118- isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/routing" ) ?? false ,
119- } ,
120- {
121- name : "router_position" ,
122- href : "/insights/router-position" ,
123- isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/router-position" ) ?? false ,
124- } ,
125- {
126- name : "call_history" ,
127- href : "/insights/call-history" ,
128- // icon: "phone",
129- isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/call-history" ) ?? false ,
130- } ,
131- ] ,
122+ child : hasInsightsAccess
123+ ? [
124+ {
125+ name : "bookings" ,
126+ href : "/insights" ,
127+ isCurrent : ( { pathname : path } ) => path === "/insights" ,
128+ } ,
129+ {
130+ name : "routing" ,
131+ href : "/insights/routing" ,
132+ isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/routing" ) ?? false ,
133+ } ,
134+ {
135+ name : "router_position" ,
136+ href : "/insights/router-position" ,
137+ isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/router-position" ) ?? false ,
138+ } ,
139+ {
140+ name : "call_history" ,
141+ href : "/insights/call-history" ,
142+ // icon: "phone",
143+ isCurrent : ( { pathname : path } ) => path ?. startsWith ( "/insights/call-history" ) ?? false ,
144+ } ,
145+ ]
146+ : undefined ,
132147 } ,
133148] ;
134149
@@ -184,8 +199,12 @@ const platformNavigationItems: NavigationItemType[] = [
184199
185200const useNavigationItems = ( isPlatformNavigation = false ) => {
186201 const orgBranding = useOrgBranding ( ) ;
202+ const { hasPaidPlan, isPending } = useHasPaidPlan ( ) ;
187203 return useMemo ( ( ) => {
188- const items = ! isPlatformNavigation ? getNavigationItems ( orgBranding ) : platformNavigationItems ;
204+ const hasInsightsAccess = ! isPending && ! ! hasPaidPlan ;
205+ const items = ! isPlatformNavigation
206+ ? getNavigationItems ( orgBranding , hasInsightsAccess )
207+ : platformNavigationItems ;
189208
190209 const desktopNavigationItems = items . filter ( ( item ) => item . name !== MORE_SEPARATOR_NAME ) ;
191210 const mobileNavigationBottomItems = items . filter (
@@ -196,7 +215,7 @@ const useNavigationItems = (isPlatformNavigation = false) => {
196215 ) ;
197216
198217 return { desktopNavigationItems, mobileNavigationBottomItems, mobileNavigationMoreItems } ;
199- } , [ isPlatformNavigation , orgBranding ] ) ;
218+ } , [ hasPaidPlan , isPending , isPlatformNavigation , orgBranding ] ) ;
200219} ;
201220
202221export const Navigation = ( { isPlatformNavigation = false } : { isPlatformNavigation ?: boolean } ) => {
0 commit comments