@@ -8,15 +8,15 @@ import useLocalize from '@hooks/useLocalize';
8
8
import useNetwork from '@hooks/useNetwork' ;
9
9
import useTheme from '@hooks/useTheme' ;
10
10
import useThemeStyles from '@hooks/useThemeStyles' ;
11
- import * as CardUtils from '@libs/CardUtils' ;
11
+ import { getCompanyFeeds , getFilteredCardList , getSelectedFeed , hasOnlyOneCardToAssign , isSelectedFeedExpired } from '@libs/CardUtils' ;
12
12
import Navigation from '@libs/Navigation/Navigation' ;
13
13
import type { PlatformStackScreenProps } from '@libs/Navigation/PlatformStackNavigation/types' ;
14
14
import type { FullScreenNavigatorParamList } from '@libs/Navigation/types' ;
15
- import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils' ;
16
- import * as PolicyUtils from '@libs/PolicyUtils' ;
15
+ import { getPersonalDetailByEmail } from '@libs/PersonalDetailsUtils' ;
16
+ import { getWorkspaceAccountID , isDeletedPolicyEmployee } from '@libs/PolicyUtils' ;
17
17
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper' ;
18
18
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections' ;
19
- import * as CompanyCards from '@userActions/CompanyCards' ;
19
+ import { openPolicyCompanyCardsFeed , openPolicyCompanyCardsPage , setAssignCardStepAndData } from '@userActions/CompanyCards' ;
20
20
import CONST from '@src/CONST' ;
21
21
import ONYXKEYS from '@src/ONYXKEYS' ;
22
22
import ROUTES from '@src/ROUTES' ;
@@ -35,10 +35,10 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) {
35
35
const styles = useThemeStyles ( ) ;
36
36
const theme = useTheme ( ) ;
37
37
const policyID = route . params . policyID ;
38
- const workspaceAccountID = PolicyUtils . getWorkspaceAccountID ( policyID ) ;
38
+ const workspaceAccountID = getWorkspaceAccountID ( policyID ) ;
39
39
const [ lastSelectedFeed ] = useOnyx ( `${ ONYXKEYS . COLLECTION . LAST_SELECTED_FEED } ${ policyID } ` ) ;
40
40
const [ cardFeeds ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SHARED_NVP_PRIVATE_DOMAIN_MEMBER } ${ workspaceAccountID } ` ) ;
41
- const selectedFeed = CardUtils . getSelectedFeed ( lastSelectedFeed , cardFeeds ) ;
41
+ const selectedFeed = getSelectedFeed ( lastSelectedFeed , cardFeeds ) ;
42
42
const [ cardsList ] = useOnyx ( `${ ONYXKEYS . COLLECTION . WORKSPACE_CARDS_LIST } ${ workspaceAccountID } _${ selectedFeed } ` ) ;
43
43
44
44
const { cardList, ...cards } = cardsList ?? { } ;
@@ -47,17 +47,17 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) {
47
47
const [ isActingAsDelegate ] = useOnyx ( ONYXKEYS . ACCOUNT , { selector : ( account ) => ! ! account ?. delegatedAccess ?. delegate } ) ;
48
48
const [ isNoDelegateAccessMenuVisible , setIsNoDelegateAccessMenuVisible ] = useState ( false ) ;
49
49
50
- const filteredCardList = CardUtils . getFilteredCardList ( cardsList , selectedFeed ? cardFeeds ?. settings ?. oAuthAccountDetails ?. [ selectedFeed ] : undefined ) ;
50
+ const filteredCardList = getFilteredCardList ( cardsList , selectedFeed ? cardFeeds ?. settings ?. oAuthAccountDetails ?. [ selectedFeed ] : undefined ) ;
51
51
52
- const companyCards = CardUtils . getCompanyFeeds ( cardFeeds ) ;
52
+ const companyCards = getCompanyFeeds ( cardFeeds ) ;
53
53
const selectedFeedData = selectedFeed && companyCards [ selectedFeed ] ;
54
54
const isNoFeed = ! selectedFeedData ;
55
55
const isPending = ! ! selectedFeedData ?. pending ;
56
56
const isFeedAdded = ! isPending && ! isNoFeed ;
57
- const isFeedExpired = CardUtils . isSelectedFeedExpired ( selectedFeed ? cardFeeds ?. settings ?. oAuthAccountDetails ?. [ selectedFeed ] : undefined ) ;
57
+ const isFeedExpired = isSelectedFeedExpired ( selectedFeed ? cardFeeds ?. settings ?. oAuthAccountDetails ?. [ selectedFeed ] : undefined ) ;
58
58
59
59
const fetchCompanyCards = useCallback ( ( ) => {
60
- CompanyCards . openPolicyCompanyCardsPage ( policyID , workspaceAccountID ) ;
60
+ openPolicyCompanyCardsPage ( policyID , workspaceAccountID ) ;
61
61
} , [ policyID , workspaceAccountID ] ) ;
62
62
63
63
const { isOffline} = useNetwork ( { onReconnect : fetchCompanyCards } ) ;
@@ -70,7 +70,7 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) {
70
70
return ;
71
71
}
72
72
73
- CompanyCards . openPolicyCompanyCardsFeed ( policyID , selectedFeed ) ;
73
+ openPolicyCompanyCardsFeed ( policyID , selectedFeed ) ;
74
74
} , [ selectedFeed , isLoading , policyID , isPending ] ) ;
75
75
76
76
const handleAssignCard = ( ) => {
@@ -86,17 +86,17 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) {
86
86
} ;
87
87
88
88
let currentStep : AssignCardStep = CONST . COMPANY_CARD . STEP . ASSIGNEE ;
89
- const employeeList = Object . values ( policy ?. employeeList ?? { } ) . filter ( ( employee ) => ! PolicyUtils . isDeletedPolicyEmployee ( employee , isOffline ) ) ;
89
+ const employeeList = Object . values ( policy ?. employeeList ?? { } ) . filter ( ( employee ) => ! isDeletedPolicyEmployee ( employee , isOffline ) ) ;
90
90
91
91
if ( employeeList . length === 1 ) {
92
92
const userEmail = Object . keys ( policy ?. employeeList ?? { } ) . at ( 0 ) ?? '' ;
93
93
data . email = userEmail ;
94
- const personalDetails = PersonalDetailsUtils . getPersonalDetailByEmail ( userEmail ) ;
94
+ const personalDetails = getPersonalDetailByEmail ( userEmail ) ;
95
95
const memberName = personalDetails ?. firstName ? personalDetails . firstName : personalDetails ?. login ;
96
96
data . cardName = `${ memberName } 's card` ;
97
97
currentStep = CONST . COMPANY_CARD . STEP . CARD ;
98
98
99
- if ( CardUtils . hasOnlyOneCardToAssign ( filteredCardList ) ) {
99
+ if ( hasOnlyOneCardToAssign ( filteredCardList ) ) {
100
100
currentStep = CONST . COMPANY_CARD . STEP . TRANSACTION_START_DATE ;
101
101
data . cardNumber = Object . keys ( filteredCardList ) . at ( 0 ) ;
102
102
data . encryptedCardNumber = Object . values ( filteredCardList ) . at ( 0 ) ;
@@ -107,7 +107,7 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) {
107
107
currentStep = CONST . COMPANY_CARD . STEP . BANK_CONNECTION ;
108
108
}
109
109
110
- CompanyCards . setAssignCardStepAndData ( { data, currentStep} ) ;
110
+ setAssignCardStepAndData ( { data, currentStep} ) ;
111
111
Navigation . setNavigationActionToMicrotaskQueue ( ( ) => Navigation . navigate ( ROUTES . WORKSPACE_COMPANY_CARDS_ASSIGN_CARD . getRoute ( policyID , selectedFeed ) ) ) ;
112
112
} ;
113
113
0 commit comments