@@ -5,6 +5,8 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
55import { hasCompanyCardFeeds } from '@libs/CardUtils' ;
66import { hasAccountingConnections , hasCustomCategories , hasNonDefaultRules , isPaidGroupPolicy , isPendingDeletePolicy } from '@libs/PolicyUtils' ;
77import isWithinGettingStartedPeriod from '@pages/home/GettingStartedSection/utils/isWithinGettingStartedPeriod' ;
8+ import { enablePolicyCategories } from '@userActions/Policy/Category' ;
9+ import { enableCompanyCards , enablePolicyConnections , enablePolicyRules } from '@userActions/Policy/Policy' ;
810import CONST from '@src/CONST' ;
911import ONYXKEYS from '@src/ONYXKEYS' ;
1012import ROUTES from '@src/ROUTES' ;
@@ -15,6 +17,8 @@ type GettingStartedItem = {
1517 label : string ;
1618 isComplete : boolean ;
1719 route : Route ;
20+ isFeatureEnabled ?: boolean ;
21+ enableFeature ?: ( ) => void ;
1822} ;
1923
2024type UseGettingStartedItemsResult = {
@@ -75,33 +79,37 @@ function useGettingStartedItems(): UseGettingStartedItemsResult {
7579 label : translate ( 'homePage.gettingStartedSection.connectAccounting' , { integrationName} ) ,
7680 isComplete : hasAccountingConnections ( policy ) ,
7781 route : ROUTES . WORKSPACE_ACCOUNTING . getRoute ( activePolicyID ) ,
82+ isFeatureEnabled : policy . areConnectionsEnabled ,
83+ enableFeature : ( ) => enablePolicyConnections ( activePolicyID , true , false ) ,
7884 } ) ;
7985 } else {
8086 items . push ( {
8187 key : 'customizeCategories' ,
8288 label : translate ( 'homePage.gettingStartedSection.customizeCategories' ) ,
8389 isComplete : hasCustomCategories ( policyCategories ) ,
8490 route : ROUTES . WORKSPACE_CATEGORIES . getRoute ( activePolicyID ) ,
91+ isFeatureEnabled : policy . areCategoriesEnabled ,
92+ enableFeature : ( ) => enablePolicyCategories ( { policy, categories : policyCategories ?? { } , tags : { } , reports : [ ] , transactionsAndViolations : { } } , true , false ) ,
8593 } ) ;
8694 }
8795
88- if ( policy . areCompanyCardsEnabled ) {
89- items . push ( {
90- key : ' linkCompanyCards',
91- label : translate ( 'homePage.gettingStartedSection.linkCompanyCards' ) ,
92- isComplete : hasCompanyCardFeeds ( allCardFeeds ) ,
93- route : ROUTES . WORKSPACE_COMPANY_CARDS . getRoute ( activePolicyID ) ,
94- } ) ;
95- }
96+ items . push ( {
97+ key : 'linkCompanyCards' ,
98+ label : translate ( 'homePage.gettingStartedSection. linkCompanyCards') ,
99+ isComplete : hasCompanyCardFeeds ( allCardFeeds ) ,
100+ route : ROUTES . WORKSPACE_COMPANY_CARDS . getRoute ( activePolicyID ) ,
101+ isFeatureEnabled : policy . areCompanyCardsEnabled ,
102+ enableFeature : ( ) => enableCompanyCards ( activePolicyID , true , false ) ,
103+ } ) ;
96104
97- if ( policy . areRulesEnabled ) {
98- items . push ( {
99- key : ' setupRules',
100- label : translate ( 'homePage.gettingStartedSection.setupRules' ) ,
101- isComplete : hasNonDefaultRules ( policy ) ,
102- route : ROUTES . WORKSPACE_RULES . getRoute ( activePolicyID ) ,
103- } ) ;
104- }
105+ items . push ( {
106+ key : 'setupRules' ,
107+ label : translate ( 'homePage.gettingStartedSection. setupRules') ,
108+ isComplete : hasNonDefaultRules ( policy ) ,
109+ route : ROUTES . WORKSPACE_RULES . getRoute ( activePolicyID ) ,
110+ isFeatureEnabled : policy . areRulesEnabled ,
111+ enableFeature : ( ) => enablePolicyRules ( policy , true , false ) ,
112+ } ) ;
105113
106114 return { shouldShowSection : true , items} ;
107115}
0 commit comments