forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardFeeds.ts
142 lines (107 loc) · 3.89 KB
/
CardFeeds.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type * as OnyxCommon from './OnyxCommon';
/** Card feed */
type CompanyCardFeed = ValueOf<typeof CONST.COMPANY_CARD.FEED_BANK_NAME>;
/** Custom card feed with a number */
type CompanyCardFeedWithNumber = CompanyCardFeed | `${CompanyCardFeed}${number}`;
/** Card feed provider */
type CardFeedProvider =
| typeof CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD
| typeof CONST.COMPANY_CARD.FEED_BANK_NAME.VISA
| typeof CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX
| typeof CONST.COMPANY_CARD.FEED_BANK_NAME.STRIPE;
/** Custom card feed data */
type CustomCardFeedData = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Whether any actions are pending */
pending?: boolean;
/** Determines if Automated Statement Reconciliation (ASR) is enabled for the cards */
asrEnabled?: boolean;
/** Specifies if the expenses on this card should be force reimbursable */
forceReimbursable?: string;
/** Defines the type of liability for the card */
liabilityType?: string;
/** Preferred policy */
preferredPolicy?: string;
/** Specifies the format for the report title related to this card */
reportTitleFormat?: string;
/** Indicates the day when the statement period for this card ends */
statementPeriodEndDay?: string;
/** Broken connection errors */
errors?: OnyxCommon.Errors;
}>;
/** Direct card feed data */
type DirectCardFeedData = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** List of accounts */
accountList: string[];
/** Credentials info */
credentials: string;
/** Expiration number */
expiration: number;
/** Defines the type of liability for the card */
liabilityType?: string;
/** Whether any actions are pending */
pending?: boolean;
/** Broken connection errors */
errors?: OnyxCommon.Errors;
}>;
/** Card feed data */
type CardFeedData = CustomCardFeedData | DirectCardFeedData;
/** Both custom and direct company feeds */
type CompanyFeeds = Partial<Record<CompanyCardFeed, CardFeedData>>;
/** Custom feed names */
type CompanyCardNicknames = Partial<Record<CompanyCardFeed, string>>;
/** Card feeds model */
type CardFeeds = {
/** Feed settings */
settings: {
/** User-friendly feed nicknames */
companyCardNicknames?: CompanyCardNicknames;
/** Company cards feeds */
companyCards?: Partial<Record<CompanyCardFeed, CustomCardFeedData>>;
/** Account details */
oAuthAccountDetails?: Partial<Record<CompanyCardFeed, DirectCardFeedData>>;
};
/** Whether we are loading the data via the API */
isLoading?: boolean;
};
/** Data required to be sent to add a new card */
type AddNewCardFeedData = {
/** Card feed provider */
feedType: CardFeedProvider;
/** Name of the card */
cardTitle: string;
/** Selected bank */
selectedBank: ValueOf<typeof CONST.COMPANY_CARDS.BANKS>;
/** Selected feed type */
selectedFeedType: ValueOf<typeof CONST.COMPANY_CARDS.FEED_TYPE>;
/** Selected Amex bank custom feed */
selectedAmexCustomFeed: ValueOf<typeof CONST.COMPANY_CARDS.AMEX_CUSTOM_FEED>;
/** Name of the bank */
bankName?: string;
};
/** Issue new card flow steps */
type AddNewCardFeedStep = ValueOf<typeof CONST.COMPANY_CARDS.STEP>;
/** Model of Issue new card flow */
type AddNewCompanyCardFeed = {
/** The current step of the flow */
currentStep: AddNewCardFeedStep;
/** Data required to be sent to issue a new card */
data: AddNewCardFeedData;
/** Whether the user is editing step */
isEditing: boolean;
};
export default CardFeeds;
export type {
AddNewCardFeedStep,
AddNewCompanyCardFeed,
AddNewCardFeedData,
CardFeedData,
CustomCardFeedData,
CompanyCardFeed,
DirectCardFeedData,
CardFeedProvider,
CompanyFeeds,
CompanyCardNicknames,
CompanyCardFeedWithNumber,
};