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
| const buildFilter = (field) => (value) => ({ [field]: value });
|
| export const SCOPE_CONFIGS = {
| GLOBAL: {
| id: 'GLOBAL',
| labelKey: 'page.guarantee.scope.global',
| valueType: 'none',
| },
| MODEL: {
| id: 'MODEL',
| labelKey: 'page.guarantee.scope.model',
| valueType: 'reference',
| reference: 'agvModel',
| optionText: 'name',
| optionValue: 'id',
| filterToQuery: buildFilter('name'),
| },
| };
|
| export const DEFAULT_SCOPE_TYPE = SCOPE_CONFIGS.GLOBAL.id;
|
| export const SCOPE_OPTIONS = Object.values(SCOPE_CONFIGS);
|
| export const SCOPE_FILTER_CHOICES = SCOPE_OPTIONS.map(({ id, labelKey }) => ({
| id,
| name: labelKey,
| }));
|
| export const getScopeConfig = (scopeType) => SCOPE_CONFIGS[scopeType] || SCOPE_CONFIGS.GLOBAL;
|
| export const getScopeLabelKey = (scopeType) => getScopeConfig(scopeType).labelKey;
|
| export const getScopeLabel = (scopeType, translate) => {
| const key = getScopeLabelKey(scopeType);
| return translate ? translate(key) : key;
| };
|
|