@@ -4,6 +4,7 @@ import { PlanEnum } from "@/ee/stripe/constants";
44import { ListOrderedIcon } from "lucide-react" ;
55import { toast } from "sonner" ;
66
7+ import { useFeatureFlags } from "@/lib/hooks/use-feature-flags" ;
78import { usePlan } from "@/lib/swr/use-billing" ;
89
910import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal" ;
@@ -30,17 +31,28 @@ export default function RebuildIndexButton({
3031 dataroomId,
3132 disabled = false ,
3233} : RebuildIndexButtonProps ) {
34+ const { isFeatureEnabled } = useFeatureFlags ( ) ;
3335 const { isDatarooms, isDataroomsPlus, isTrial } = usePlan ( ) ;
3436 const [ isLoading , setIsLoading ] = useState ( false ) ;
3537 const [ isOpen , setIsOpen ] = useState ( false ) ;
3638
37- // INFO: Don't render if user doesn't have a datarooms plan
38- if ( ! isDatarooms && ! isDataroomsPlus && ! isTrial ) {
39+ const isDataroomIndexEnabled = isFeatureEnabled ( "dataroomIndex" ) ;
40+ const hasDataroomsPlan = isDatarooms || isDataroomsPlus || isTrial ;
41+ const hasDataroomsPlusPlan = isDataroomsPlus ;
42+
43+ // Show button if: feature flag is enabled OR user has datarooms plan or higher
44+ const shouldShowButton = isDataroomIndexEnabled || hasDataroomsPlan ;
45+
46+ // Allow usage if: feature flag is enabled OR user has datarooms-plus plan
47+ const canUseFeature = isDataroomIndexEnabled || hasDataroomsPlusPlan ;
48+
49+ // Don't render if conditions aren't met
50+ if ( ! shouldShowButton ) {
3951 return null ;
4052 }
4153
4254 const handleRebuildIndex = async ( ) => {
43- if ( ! isDataroomsPlus ) {
55+ if ( ! canUseFeature ) {
4456 toast . error ( "Upgrade to Data Rooms Plus plan to use this feature." ) ;
4557 return ;
4658 }
@@ -127,7 +139,7 @@ export default function RebuildIndexButton({
127139 </ div >
128140
129141 < DialogFooter >
130- { isDataroomsPlus ? (
142+ { canUseFeature ? (
131143 < >
132144 < Button variant = "outline" onClick = { ( ) => setIsOpen ( false ) } >
133145 Cancel
0 commit comments