-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Permissions.ts
58 lines (47 loc) · 1.85 KB
/
Permissions.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
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import type Beta from '@src/types/onyx/Beta';
import * as SessionUtils from './SessionUtils';
const isAccountIDEven = (accountID: number) => accountID % 2 === 0;
function canUseAllBetas(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.ALL);
}
function canUseDefaultRooms(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas);
}
function canUseDupeDetection(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.DUPE_DETECTION) || canUseAllBetas(betas);
}
function canUseSpotnanaTravel(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.SPOTNANA_TRAVEL) || canUseAllBetas(betas);
}
function canUseNetSuiteUSATax(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NETSUITE_USA_TAX) || canUseAllBetas(betas);
}
function canUseCategoryAndTagApprovers(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas);
}
function canUseCombinedTrackSubmit(): boolean {
// We don't need to show this to all betas since this will be used for developing a feature for A/B testing.
const session = SessionUtils.getSession();
return isAccountIDEven(session?.accountID ?? -1);
}
function canUsePerDiem(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.PER_DIEM) || canUseAllBetas(betas);
}
/**
* Link previews are temporarily disabled.
*/
function canUseLinkPreviews(): boolean {
return false;
}
export default {
canUseDefaultRooms,
canUseLinkPreviews,
canUseDupeDetection,
canUseSpotnanaTravel,
canUseNetSuiteUSATax,
canUseCombinedTrackSubmit,
canUseCategoryAndTagApprovers,
canUsePerDiem,
};